Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,21 +28,29 @@ with st.sidebar:
|
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
# predictions = model.predict(image)
|
| 34 |
# labels, boxes, scores = predictions
|
| 35 |
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
#img_array = img_to_array(img)
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
+
def detect_object(IMAGE_PATH):
|
| 32 |
+
image = utils.read_image(IMAGE_PATH)
|
| 33 |
# predictions = model.predict(image)
|
| 34 |
# labels, boxes, scores = predictions
|
| 35 |
|
| 36 |
|
| 37 |
+
thresh=0.2
|
| 38 |
+
filtered_indices=np.where(scores>thresh)
|
| 39 |
+
filtered_scores=scores[filtered_indices]
|
| 40 |
+
filtered_boxes=boxes[filtered_indices]
|
| 41 |
+
num_list = filtered_indices[0].tolist()
|
| 42 |
+
filtered_labels = [labels[i] for i in num_list]
|
| 43 |
+
st.show_labeled_image(image, filtered_boxes, filtered_labels)
|
| 44 |
#img_array = img_to_array(img)
|
| 45 |
|
| 46 |
+
file = st.file_uploader('Upload an Image',type=(["jpeg","jpg","png"]))
|
| 47 |
+
|
| 48 |
+
if file is None:
|
| 49 |
+
st.write("Please upload an image file")
|
| 50 |
+
else:
|
| 51 |
+
image= Image.open(file)
|
| 52 |
+
st.image(image,use_column_width = True)
|
| 53 |
+
detect_object(file)
|
| 54 |
|
| 55 |
|
| 56 |
|