Rohankumar31 commited on
Commit
f203369
·
verified ·
1 Parent(s): 6e35d53

Update sample.py

Browse files
Files changed (1) hide show
  1. sample.py +7 -5
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
- boxes = result['boxes'] # Assuming 'boxes' is a list of bounding box coordinates [x_min, y_min, x_max, y_max]
62
- for box in boxes:
63
- x_min, y_min, x_max, y_max = box # Extract coordinates
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()