Spaces:
Runtime error
Runtime error
Rohankumar31
commited on
Update sample.py
Browse files
sample.py
CHANGED
@@ -51,18 +51,20 @@ def main():
|
|
51 |
# Process uploaded image
|
52 |
# image_l = Image.open(uploaded_file)
|
53 |
image = plt.imread(uploaded_file)
|
|
|
|
|
54 |
st.image(image, caption='Original Image', use_column_width=True)
|
55 |
|
56 |
# output_l = process_image(image)
|
57 |
# output = np.asarray(output_l)
|
58 |
# output_image = Image.fromarray(output)
|
59 |
results = model(image)
|
60 |
-
for result in results:
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
cv2.rectangle(image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
65 |
st.image(image, caption='Processed Image', use_column_width=True)
|
66 |
|
|
|
67 |
if __name__ == '__main__':
|
68 |
main()
|
|
|
51 |
# Process uploaded image
|
52 |
# image_l = Image.open(uploaded_file)
|
53 |
image = plt.imread(uploaded_file)
|
54 |
+
# Process uploaded image
|
55 |
+
# image = Image.open(uploaded_file)
|
56 |
st.image(image, caption='Original Image', use_column_width=True)
|
57 |
|
58 |
# output_l = process_image(image)
|
59 |
# output = np.asarray(output_l)
|
60 |
# output_image = Image.fromarray(output)
|
61 |
results = model(image)
|
62 |
+
for result in results.pred[0]:
|
63 |
+
box = result.xyxy[0].tolist() # Extract bounding box coordinates as a list [x_min, y_min, x_max, y_max]
|
64 |
+
x_min, y_min, x_max, y_max = box
|
65 |
+
cv2.rectangle(image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
|
|
66 |
st.image(image, caption='Processed Image', use_column_width=True)
|
67 |
|
68 |
+
|
69 |
if __name__ == '__main__':
|
70 |
main()
|