import gradio as gr | |
import numpy as np | |
import torch | |
model = torch.hub.load('ultralytics/yolov5', 'custom', path='last2.pt', force_reload=True) | |
def detect(im): | |
results = model(im) | |
return [np.squeeze(results.render())] | |
#return [im] | |
demo = gr.Interface( | |
detect, | |
[gr.Image(source="webcam", tool=None)], | |
["image"], | |
) | |
if __name__ == "__main__": | |
demo.launch() | |