Spaces:
Runtime error
Runtime error
| 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) | |