File size: 1,103 Bytes
5a99f66
7a2c2f5
 
 
5a99f66
7a2c2f5
 
 
 
7b58fee
 
 
 
 
3370dd3
cb55d59
9a176f4
 
 
7a2c2f5
7b58fee
f1b51fb
ad9434f
f1b51fb
 
7a2c2f5
 
4c439f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

import torch
import gradio as gr

model = torch.hub.load('./', 'custom', path="best.pt", source='local', force_reload=True)
title = "                                               焊缝缺陷检测                                                      "
desc = ""
base_conf, base_iou = 0.30, 0.45

#def det_image(img, conf_thres, iou_thres):
    #model.conf = conf_thres
    #model.iou = iou_thres
    #return model(img).render()[0]

def det_image(img, model_path, conf_thres, iou_thres):
                
    
    model.conf = conf_thres
    model.iou = iou_thres

    return model(img).render()[0]
gr.Interface(inputs=["image", gr.inputs.Slider(minimum=0, maximum=1, default=base_conf), gr.inputs.Slider(minimum=0, maximum=1, default=base_iou)],
             outputs=["image"],
#gr.Interface(inputs=["image", gr.inputs.Dropdown(model_paths, label="选择模型"), gr.Slider(minimum=0, maximum=1, value=base_conf), gr.Slider(minimum=0, maximum=1, value=base_iou)],
             #outputs=["image"],
             fn=det_image,
             title=title,
             description=desc).launch(share=False)