Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from ultralyticsplus import YOLO
|
3 |
from ultralytics.yolo.utils.plotting import Annotator
|
4 |
|
5 |
def yolov8_inference(
|
@@ -24,23 +24,23 @@ def yolov8_inference(
|
|
24 |
model.iou = iou_threshold
|
25 |
# results = model.predict(image, return_outputs=True)
|
26 |
results = model.predict(image)
|
27 |
-
object_prediction_list = []
|
28 |
-
annotator = Annotator(image)
|
29 |
-
for _, image_results in enumerate(results):
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
# object_prediction = ObjectPrediction(
|
45 |
# bbox=bbox,
|
46 |
# category_id=int(category_id),
|
@@ -53,7 +53,9 @@ def yolov8_inference(
|
|
53 |
# output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
|
54 |
|
55 |
# return output_image['image']
|
56 |
-
return annotator.result()
|
|
|
|
|
57 |
|
58 |
|
59 |
inputs = [
|
|
|
1 |
import gradio as gr
|
2 |
+
from ultralyticsplus import YOLO, render_result
|
3 |
from ultralytics.yolo.utils.plotting import Annotator
|
4 |
|
5 |
def yolov8_inference(
|
|
|
24 |
model.iou = iou_threshold
|
25 |
# results = model.predict(image, return_outputs=True)
|
26 |
results = model.predict(image)
|
27 |
+
# object_prediction_list = []
|
28 |
+
# annotator = Annotator(image)
|
29 |
+
# for _, image_results in enumerate(results):
|
30 |
+
# if len(image_results)!=0:
|
31 |
+
# image_predictions_in_xyxy_format = image_results['det']
|
32 |
+
# for pred in image_predictions_in_xyxy_format:
|
33 |
+
# x1, y1, x2, y2 = (
|
34 |
+
# int(pred[0]),
|
35 |
+
# int(pred[1]),
|
36 |
+
# int(pred[2]),
|
37 |
+
# int(pred[3]),
|
38 |
+
# )
|
39 |
+
# bbox = [x1, y1, x2, y2]
|
40 |
+
# score = pred[4]
|
41 |
+
# category_name = model.model.names[int(pred[5])]
|
42 |
+
# category_id = pred[5]
|
43 |
+
# annotator.box_label(bbox, f"{category_name} {score}")
|
44 |
# object_prediction = ObjectPrediction(
|
45 |
# bbox=bbox,
|
46 |
# category_id=int(category_id),
|
|
|
53 |
# output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
|
54 |
|
55 |
# return output_image['image']
|
56 |
+
# return annotator.result()
|
57 |
+
render = render_result(model=model, image=image, result=results[0])
|
58 |
+
return render
|
59 |
|
60 |
|
61 |
inputs = [
|