capjamesg commited on
Commit
dbe0801
·
1 Parent(s): 343712f

work on plotting code

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -10,25 +10,18 @@ def plot_bounding_boxes(image, boxes, box_type):
10
 
11
  x0, y0, x1, y1 = [int(i.strip()) for i in boxes.split(",")]
12
 
13
- image_width = image.size[0]
14
- image_height = image.size[1]
15
-
16
  if box_type == "xywh":
17
- x1 = x0 + x1
18
- y1 = y0 + y1
19
-
20
- x0 = x0 * image_width
21
- x1 = x1 * image_width
22
-
23
- y0 = y0 * image_height
24
- y1 = y1 * image_height
25
 
26
  detections = sv.Detections(
27
  xyxy=np.array([[x0, y0, x1, y1]]),
28
  class_id=np.array([0]),
29
  confidence=np.array([1.0]),
30
  )
31
- # convert to cv2
32
  image = np.array(image)
33
 
34
  bounding_box_annotator = sv.BoundingBoxAnnotator()
 
10
 
11
  x0, y0, x1, y1 = [int(i.strip()) for i in boxes.split(",")]
12
 
 
 
 
13
  if box_type == "xywh":
14
+ x0 = x0 * image.size[0]
15
+ y0 = y0 * image.size[1]
16
+ x1 = x0 + (x1 * image.size[0])
17
+ y1 = y0 + (y1 * image.size[1])
 
 
 
 
18
 
19
  detections = sv.Detections(
20
  xyxy=np.array([[x0, y0, x1, y1]]),
21
  class_id=np.array([0]),
22
  confidence=np.array([1.0]),
23
  )
24
+
25
  image = np.array(image)
26
 
27
  bounding_box_annotator = sv.BoundingBoxAnnotator()