Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,9 @@ from sahi.prediction import ObjectPrediction
|
|
4 |
from sahi.utils.cv import visualize_object_predictions, read_image
|
5 |
from ultralyticsplus import YOLO
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
image_path = [['test_images/2a998cfb0901db5f8210.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],['test_images/2ce19ce0191acb44920b.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],
|
9 |
['test_images/2daab6ea3310e14eb801.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45], ['test_images/4a137deefb14294a7005 (1).jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],
|
@@ -30,32 +33,35 @@ def yolov8_img_inference(
|
|
30 |
model.conf = conf_threshold
|
31 |
model.iou = iou_threshold
|
32 |
results = model.predict(image, imgsz=image_size, return_outputs=True)
|
33 |
-
object_prediction_list = []
|
34 |
-
for _, image_results in enumerate(results):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
image = read_image(image)
|
57 |
-
output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
|
58 |
-
return output_image['image']
|
|
|
|
|
|
|
59 |
|
60 |
|
61 |
inputs_image = [
|
@@ -80,4 +86,9 @@ interface_image = gr.Interface(
|
|
80 |
theme='huggingface'
|
81 |
)
|
82 |
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from sahi.utils.cv import visualize_object_predictions, read_image
|
5 |
from ultralyticsplus import YOLO
|
6 |
|
7 |
+
from ultralyticsplus import render_result
|
8 |
+
import requests
|
9 |
+
import cv2
|
10 |
|
11 |
image_path = [['test_images/2a998cfb0901db5f8210.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],['test_images/2ce19ce0191acb44920b.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],
|
12 |
['test_images/2daab6ea3310e14eb801.jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45], ['test_images/4a137deefb14294a7005 (1).jpg','linhcuem/chamdiem_yolov8_ver10', 640, 0.25, 0.45],
|
|
|
33 |
model.conf = conf_threshold
|
34 |
model.iou = iou_threshold
|
35 |
results = model.predict(image, imgsz=image_size, return_outputs=True)
|
36 |
+
# object_prediction_list = []
|
37 |
+
# for _, image_results in enumerate(results):
|
38 |
+
# if len(image_results)!=0:
|
39 |
+
# image_predictions_in_xyxy_format = image_results['det']
|
40 |
+
# for pred in image_predictions_in_xyxy_format:
|
41 |
+
# x1, y1, x2, y2 = (
|
42 |
+
# int(pred[0]),
|
43 |
+
# int(pred[1]),
|
44 |
+
# int(pred[2]),
|
45 |
+
# int(pred[3]),
|
46 |
+
# )
|
47 |
+
# bbox = [x1, y1, x2, y2]
|
48 |
+
# score = pred[4]
|
49 |
+
# category_name = model.model.names[int(pred[5])]
|
50 |
+
# category_id = pred[5]
|
51 |
+
# object_prediction = ObjectPrediction(
|
52 |
+
# bbox=bbox,
|
53 |
+
# category_id=int(category_id),
|
54 |
+
# score=score,
|
55 |
+
# category_name=category_name,
|
56 |
+
# )
|
57 |
+
# object_prediction_list.append(object_prediction)
|
58 |
|
59 |
+
# image = read_image(image)
|
60 |
+
# output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
|
61 |
+
# return output_image['image']
|
62 |
+
render = render_result(model=model, image=image, result=results[0])
|
63 |
+
|
64 |
+
return render
|
65 |
|
66 |
|
67 |
inputs_image = [
|
|
|
86 |
theme='huggingface'
|
87 |
)
|
88 |
|
89 |
+
gr.TabbedInterface(
|
90 |
+
[interface_image],
|
91 |
+
tab_names=['Image inference']
|
92 |
+
).queue().launch()
|
93 |
+
|
94 |
+
# interface_image.launch(debug=True, enable_queue=True)
|