Update app.py
Browse files
app.py
CHANGED
@@ -40,12 +40,14 @@ def detect_objects(image: Image.Image):
|
|
40 |
image_with_boxes = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
|
41 |
return Image.fromarray(image_with_boxes)
|
42 |
|
|
|
43 |
|
44 |
|
45 |
app = gr.Interface(
|
46 |
fn=detect_objects, # 检测函数
|
47 |
inputs=gr.Image(type="pil"), # 接收输入图片,返回 PIL 格式
|
48 |
outputs=gr.Image(type="pil"), # 返回叠框后的图片
|
|
|
49 |
title="YOLO Object Detection",
|
50 |
description="Upload an image to detect objects using YOLO."
|
51 |
)
|
|
|
40 |
image_with_boxes = cv2.cvtColor(image_np, cv2.COLOR_BGR2RGB)
|
41 |
return Image.fromarray(image_with_boxes)
|
42 |
|
43 |
+
example_image_paths = ["image1.jpg", "image2.jpg", "image3.jpg"] # 替换为你的图片路径
|
44 |
|
45 |
|
46 |
app = gr.Interface(
|
47 |
fn=detect_objects, # 检测函数
|
48 |
inputs=gr.Image(type="pil"), # 接收输入图片,返回 PIL 格式
|
49 |
outputs=gr.Image(type="pil"), # 返回叠框后的图片
|
50 |
+
examples=example_image_paths,
|
51 |
title="YOLO Object Detection",
|
52 |
description="Upload an image to detect objects using YOLO."
|
53 |
)
|