Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -458,34 +458,6 @@ if uploaded_file is not None:
|
|
| 458 |
image = cv2.imdecode(file_bytes, 1)
|
| 459 |
|
| 460 |
# st.image(image, caption='Uploaded Image.', use_column_width=True)
|
| 461 |
-
|
| 462 |
-
if st.button('Detect'):
|
| 463 |
-
st.write("Processing...")
|
| 464 |
-
input_image = preprocess_image(image)
|
| 465 |
-
pred_bbox, pred_label, pred_label_confidence = predict(model_detection, input_image)
|
| 466 |
-
|
| 467 |
-
# Updated label mapping based on the dataset
|
| 468 |
-
label_mapping = {
|
| 469 |
-
0: 'Atelectasis',
|
| 470 |
-
1: 'Cardiomegaly',
|
| 471 |
-
2: 'Effusion',
|
| 472 |
-
3: 'Infiltrate',
|
| 473 |
-
4: 'Mass',
|
| 474 |
-
5: 'Nodule',
|
| 475 |
-
6: 'Pneumonia',
|
| 476 |
-
7: 'Pneumothorax'
|
| 477 |
-
}
|
| 478 |
-
|
| 479 |
-
if pred_label_confidence < 0.2:
|
| 480 |
-
st.write("May not detect a disease.")
|
| 481 |
-
else:
|
| 482 |
-
pred_label_name = label_mapping[pred_label]
|
| 483 |
-
st.write(f"Prediction Label: {pred_label_name}")
|
| 484 |
-
st.write(f"Prediction Bounding Box: {pred_bbox}")
|
| 485 |
-
st.write(f"Prediction Confidence: {pred_label_confidence:.2f}")
|
| 486 |
-
|
| 487 |
-
output_image = draw_bbox(image.copy(), pred_bbox)
|
| 488 |
-
st.image(output_image, caption='Detected Image.', use_column_width=True)
|
| 489 |
|
| 490 |
col1, col2 = st.columns(2)
|
| 491 |
# Check the number of dimensions of the image
|
|
|
|
| 458 |
image = cv2.imdecode(file_bytes, 1)
|
| 459 |
|
| 460 |
# st.image(image, caption='Uploaded Image.', use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
|
| 462 |
col1, col2 = st.columns(2)
|
| 463 |
# Check the number of dimensions of the image
|