Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 >=
|
85 |
-
|
|
|
|
|
|
|
86 |
|
87 |
-
result = visualize_object_predictions(
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
)
|
93 |
-
|
94 |
-
return
|
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"),
|