turhancan97 commited on
Commit
778a7dd
1 Parent(s): cb2f09c

add class name

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -104,6 +104,10 @@ def show_preds_image(image_path):
104
  dim=(width,height)
105
 
106
  outputs = model.predict(source=img_res_toshow)
 
 
 
 
107
  angle_list = []
108
  for object in range(len(outputs[0].masks.masks)):
109
  #obtain BW image
@@ -126,10 +130,12 @@ def show_preds_image(image_path):
126
  # Find the orientation of each shape
127
  angle_deg = getOrientation(c, img)
128
  angle_list.append(angle_deg)
129
- text = 'The orientation of the objects are: '
130
- for angle in angle_list:
131
- text += str(angle) + ' '
132
- text += 'degrees'
 
 
133
  results = outputs[0].cpu().numpy()
134
  for i, det in enumerate(results.boxes.xyxy):
135
  cv2.rectangle(
 
104
  dim=(width,height)
105
 
106
  outputs = model.predict(source=img_res_toshow)
107
+ boxes = outputs[0].boxes.cls
108
+ class_list = []
109
+ for class_n in boxes.cpu().numpy():
110
+ class_list.append(outputs[0].names[class_n])
111
  angle_list = []
112
  for object in range(len(outputs[0].masks.masks)):
113
  #obtain BW image
 
130
  # Find the orientation of each shape
131
  angle_deg = getOrientation(c, img)
132
  angle_list.append(angle_deg)
133
+
134
+ # Create a text string for the orientation of the objects and the class of the objects
135
+ text = ""
136
+ for i in range(len(angle_list)):
137
+ text = text + "Object " + str(i+1) + ": " + str(angle_list[i]) + " deg, " + class_list[i] + "\n"
138
+
139
  results = outputs[0].cpu().numpy()
140
  for i, det in enumerate(results.boxes.xyxy):
141
  cv2.rectangle(