vumichien commited on
Commit
b135bd1
1 Parent(s): d3c6fe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -66,6 +66,7 @@ def yolov8_inference(
66
  area_image = image.width*image.height
67
  object_predictions = []
68
  html_bot_voice = ""
 
69
  if boxes is not None:
70
  det_ind = 0
71
  for xyxy, conf, cls in zip(boxes.xyxy, boxes.conf, boxes.cls):
@@ -81,17 +82,20 @@ def yolov8_inference(
81
  )
82
  object_predictions.append(object_prediction)
83
  det_ind += 1
84
- if area_rate >= area_thres:
85
- html_bot_voice = tts(defaul_bot_voice, language="ja")
 
 
 
86
 
87
- result = visualize_object_predictions(
88
- image=np_image,
89
- object_prediction_list=object_predictions,
90
- rect_th=2,
91
- text_th=2,
92
- )
93
-
94
- return Image.fromarray(result["image"]), html_bot_voice
95
 
96
 
97
  outputs = [gr.Image(type="filepath", label="Robot View"),
 
66
  area_image = image.width*image.height
67
  object_predictions = []
68
  html_bot_voice = ""
69
+ most_close = 0
70
  if boxes is not None:
71
  det_ind = 0
72
  for xyxy, conf, cls in zip(boxes.xyxy, boxes.conf, boxes.cls):
 
82
  )
83
  object_predictions.append(object_prediction)
84
  det_ind += 1
85
+ if area_rate >= most_close:
86
+ out_img = image.crop(tuple(box)).resize((image.width, image.height))
87
+ most_close = area_rate
88
+ if area_rate >= area_thres:
89
+ html_bot_voice = tts(defaul_bot_voice, language="ja")
90
 
91
+ # result = visualize_object_predictions(
92
+ # image=np_image,
93
+ # object_prediction_list=object_predictions,
94
+ # rect_th=2,
95
+ # text_th=2,
96
+ # )
97
+ # return Image.fromarray(result["image"]), html_bot_voice
98
+ return out_img, html_bot_voice
99
 
100
 
101
  outputs = [gr.Image(type="filepath", label="Robot View"),