Spaces:
Runtime error
Runtime error
File size: 969 Bytes
61ab183 0ba3470 6d4f35c 61ab183 55a5a3a 6d4f35c 61ab183 6d4f35c 61ab183 6d4f35c 4cab89e 6d4f35c |
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 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
import os
import torch
print(f"Version Gradio: {gr.__version__}")
def update_value(val):
return f'Value is set to {val}'
def yolov7_inference(
image: gr.Image = None,
conf_threshold: gr.Slider = 0.20,
):
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
path = 'y7-prdef.pt'
model = torch.hub.load("WongKinYiu/yolov7","custom",f"{path}")
model.conf = conf_threshold
results = model([image], size=640)
return results.render()[0]
inputs = [
gr.Image(label="input image"),
gr.Slider(minimum=0, maximum=1, step=0.1, label='Value'),
]
outputs = [
gr.Image(label="output image"),
]
gr.Interface(
fn = yolov7_inference,
inputs = inputs,
outputs = outputs,
title = "- The detection of jar lid defects using Yolov7 -",
description = "contact: rrighart@googlemail.com",
examples = [["example1.JPG"], ["example2.JPG"], ["example3.JPG"]],
).launch(debug=True)
|