Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,8 +47,8 @@ def yolov8_img_inference(
|
|
47 |
# image = read_image
|
48 |
results = model.predict(image)
|
49 |
render = render_result(model=model, image=image, result=results[0])
|
50 |
-
count_result = results[0].boxes.cls.tolist().count('name')
|
51 |
-
|
52 |
return render, count_result
|
53 |
|
54 |
# results = model.predict(image, imgsz=image_size, return_outputs=True)
|
@@ -93,15 +93,15 @@ inputs_image = [
|
|
93 |
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
|
94 |
]
|
95 |
|
96 |
-
|
97 |
-
|
98 |
|
99 |
title = "Tất cả do anh Đạt"
|
100 |
|
101 |
interface_image = gr.Interface(
|
102 |
fn=yolov8_img_inference,
|
103 |
inputs=inputs_image,
|
104 |
-
outputs=[
|
105 |
title=title,
|
106 |
examples=image_path,
|
107 |
cache_examples=True,
|
|
|
47 |
# image = read_image
|
48 |
results = model.predict(image)
|
49 |
render = render_result(model=model, image=image, result=results[0])
|
50 |
+
# count_result = results[0].boxes.cls.tolist().count('name')
|
51 |
+
count_result = results.pandas().xyxy[0].value_counts('name')
|
52 |
return render, count_result
|
53 |
|
54 |
# results = model.predict(image, imgsz=image_size, return_outputs=True)
|
|
|
93 |
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
|
94 |
]
|
95 |
|
96 |
+
outputs_image =gr.outputs.Image(type="filepath", label="Output Image")
|
97 |
+
count_obj = gr.outputs.Textbox(show_label=False)
|
98 |
|
99 |
title = "Tất cả do anh Đạt"
|
100 |
|
101 |
interface_image = gr.Interface(
|
102 |
fn=yolov8_img_inference,
|
103 |
inputs=inputs_image,
|
104 |
+
outputs=[outputs_image, count_obj],
|
105 |
title=title,
|
106 |
examples=image_path,
|
107 |
cache_examples=True,
|