Spaces:
Running
Running
Zengyf-CVer
commited on
Commit
·
07d53b8
1
Parent(s):
e1cb70c
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
-
# Gradio YOLOv8 Det v1.2.
|
2 |
# 创建人:曾逸夫
|
3 |
-
# 创建时间:2023-
|
4 |
-
# pip install gradio>=4.
|
|
|
|
|
5 |
|
6 |
import argparse
|
7 |
import csv
|
@@ -32,7 +34,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
32 |
from util.fonts_opt import is_fonts
|
33 |
|
34 |
# Gradio YOLOv8 Det版本
|
35 |
-
GYD_VERSION = "Gradio YOLOv8 Det v1.2.
|
36 |
|
37 |
# 文件后缀
|
38 |
suffix_list = [".csv", ".yaml"]
|
@@ -503,14 +505,15 @@ def main(args):
|
|
503 |
device_opt = gr.Radio(choices=["cpu", "0", "1", "2", "3"], value="cpu", label="设备")
|
504 |
with gr.Row():
|
505 |
inputs_model = gr.Dropdown(choices=model_names, value=model_name, type="value", label="模型")
|
506 |
-
with gr.
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
514 |
with gr.Row():
|
515 |
gr.ClearButton(inputs_img, value="清除")
|
516 |
det_btn_img = gr.Button(value='检测', variant="primary")
|
@@ -559,6 +562,47 @@ def main(args):
|
|
559 |
outputs_img_cls = gr.Image(type="pil", label="检测图片")
|
560 |
with gr.Row():
|
561 |
outputs_ratio_cls = gr.Label(label="图像分类结果")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
det_btn_img.click(fn=yolo_det_img,
|
564 |
inputs=[
|
|
|
1 |
+
# Gradio YOLOv8 Det v1.2.1
|
2 |
# 创建人:曾逸夫
|
3 |
+
# 创建时间:2023-12-7
|
4 |
+
# pip install gradio>=4.8.0
|
5 |
+
# python gradio_yolov8_det_v1.py
|
6 |
+
|
7 |
|
8 |
import argparse
|
9 |
import csv
|
|
|
34 |
from util.fonts_opt import is_fonts
|
35 |
|
36 |
# Gradio YOLOv8 Det版本
|
37 |
+
GYD_VERSION = "Gradio YOLOv8 Det v1.2.1"
|
38 |
|
39 |
# 文件后缀
|
40 |
suffix_list = [".csv", ".yaml"]
|
|
|
505 |
device_opt = gr.Radio(choices=["cpu", "0", "1", "2", "3"], value="cpu", label="设备")
|
506 |
with gr.Row():
|
507 |
inputs_model = gr.Dropdown(choices=model_names, value=model_name, type="value", label="模型")
|
508 |
+
with gr.Accordion("高级设置", open=True):
|
509 |
+
with gr.Row():
|
510 |
+
inputs_size = gr.Slider(320, 1600, step=1, value=inference_size, label="推理尺寸")
|
511 |
+
max_det = gr.Slider(1, 1000, step=1, value=max_detnum, label="最大检测数")
|
512 |
+
with gr.Row():
|
513 |
+
input_conf = gr.Slider(0, 1, step=slider_step, value=nms_conf, label="置信度阈值")
|
514 |
+
inputs_iou = gr.Slider(0, 1, step=slider_step, value=nms_iou, label="IoU 阈值")
|
515 |
+
with gr.Row():
|
516 |
+
obj_size = gr.Radio(choices=["所有尺寸", "小目标", "中目标", "大目标"], value="所有尺寸", label="目标尺寸")
|
517 |
with gr.Row():
|
518 |
gr.ClearButton(inputs_img, value="清除")
|
519 |
det_btn_img = gr.Button(value='检测', variant="primary")
|
|
|
562 |
outputs_img_cls = gr.Image(type="pil", label="检测图片")
|
563 |
with gr.Row():
|
564 |
outputs_ratio_cls = gr.Label(label="图像分类结果")
|
565 |
+
with gr.Accordion("Gradio YOLOv8 Det 安装与使用教程"):
|
566 |
+
gr.Markdown(
|
567 |
+
"""## Gradio YOLOv8 Det 安装与使用教程
|
568 |
+
```shell
|
569 |
+
conda create -n yolo python==3.8
|
570 |
+
conda activate yolo # 进入环境
|
571 |
+
git clone https://gitee.com/CV_Lab/gradio-yolov8-det.git
|
572 |
+
cd gradio-yolov8-det
|
573 |
+
pip install -r ./requirements.txt -U
|
574 |
+
```
|
575 |
+
```shell
|
576 |
+
# 共享模式
|
577 |
+
python gradio_yolov8_det_v1.py -is # 在浏览器中以共享模式打开,https://**.gradio.app/
|
578 |
+
|
579 |
+
# 自定义模型配置
|
580 |
+
python gradio_yolov8_det_v1.py -mc ./model_config/model_name_all.yaml
|
581 |
+
|
582 |
+
# 自定义下拉框默认模型名称
|
583 |
+
python gradio_yolov8_det_v1.py -mn yolov8m
|
584 |
+
|
585 |
+
# 自定义类别名称
|
586 |
+
python gradio_yolov8_det_v1.py -cls ./cls_name/cls_name_zh.yaml (目标检测与图像分割)
|
587 |
+
python gradio_yolov8_det_v1.py -cin ./cls_name/cls_imgnet_name_zh.yaml (图像分类)
|
588 |
+
|
589 |
+
# 自定义NMS置信度阈值
|
590 |
+
python gradio_yolov8_det_v1.py -conf 0.8
|
591 |
+
|
592 |
+
# 自定义NMS IoU阈值
|
593 |
+
python gradio_yolov8_det_v1.py -iou 0.5
|
594 |
+
|
595 |
+
# 设置推理尺寸,默认为640
|
596 |
+
python gradio_yolov8_det_v1.py -isz 320
|
597 |
+
|
598 |
+
# 设置最大检测数,默认为50
|
599 |
+
python gradio_yolov8_det_v1.py -mdn 100
|
600 |
+
|
601 |
+
# 设置滑块步长,默认为0.05
|
602 |
+
python gradio_yolov8_det_v1.py -ss 0.01
|
603 |
+
```
|
604 |
+
"""
|
605 |
+
)
|
606 |
|
607 |
det_btn_img.click(fn=yolo_det_img,
|
608 |
inputs=[
|