llzzyy233 commited on
Commit
e466aa6
1 Parent(s): 416724a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -3,8 +3,8 @@ import torch
3
  from PIL import Image
4
  from ultralytics import YOLO
5
 
6
- model = YOLO(r'pcb-best.pt')
7
 
 
8
  def predict(img, conf, iou):
9
  results = model.predict(img, conf=conf, iou=iou)
10
  for i, r in enumerate(results):
@@ -19,6 +19,9 @@ def predict(img, conf, iou):
19
  base_conf, base_iou = 0.25, 0.45
20
  title = "基于YOLO-V8的PCB电路板缺陷检测"
21
  des = "鼠标点击上传图片即可检测缺陷,可通过鼠标调整预测置信度,还可点击网页最下方示例图片进行预测"
22
- gr.Interface(inputs=['image',gr.Slider(maximum=1, minimum=0, value=base_conf), gr.Slider(maximum=1, minimum=0, value=base_iou)],
23
- outputs=["image"], fn=predict, title=title, description=des).launch()
 
 
24
 
 
 
3
  from PIL import Image
4
  from ultralytics import YOLO
5
 
 
6
 
7
+ model = YOLO(r'pcb-best.pt')
8
  def predict(img, conf, iou):
9
  results = model.predict(img, conf=conf, iou=iou)
10
  for i, r in enumerate(results):
 
19
  base_conf, base_iou = 0.25, 0.45
20
  title = "基于YOLO-V8的PCB电路板缺陷检测"
21
  des = "鼠标点击上传图片即可检测缺陷,可通过鼠标调整预测置信度,还可点击网页最下方示例图片进行预测"
22
+ interface = gr.Interface(inputs=['image',gr.Slider(maximum=1, minimum=0, value=base_conf), gr.Slider(maximum=1, minimum=0, value=base_iou)],
23
+ outputs=["image"], fn=predict, title=title, description=des, examples=[["example1.jpg", base_conf, base_iou],
24
+ ["example2.jpg", base_conf, base_iou],
25
+ ["example3.jpg", base_conf, base_iou]])
26
 
27
+ interface.launch()