File size: 1,434 Bytes
fed1544
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import os
import torch


#Repo.clone_from("https://github.com/ultralytics/yolov5", "./content")
#subprocess.run(["git","clone", "https://github.com/ultralytics/yolov5"])
'''gdd.download_file_from_google_drive(file_id='1xJcr1zuuoC6bbu6wGvmyw5dl0mUEi-Jn',
                                    dest_path='content/train_data.zip',
                                    unzip=True)
gdd.download_file_from_google_drive(file_id='1UJ9Y2mw2KBRY0tO-TnBs5RALLya6C2dW',
                                    dest_path='content/video.zip',
                                    unzip=True) '''                               
#subprocess.run(["mv","content/custom_data.yaml","./yolov5/data"])         

def find(name, path):
 for root, dirs, files in os.walk(path):
  if name in files:
   return os.path.join(root, name)

model = torch.hub.load('ultralytics/yolov5', 'custom', path='/content/best.pt', force_reload=True)    
def detect(inp):
 output=model(inp)
 #outPath=
  #out_path='./yolov5/runs/detect/exp/'+inp_vid.split('/')[2]
 return output

inp=gr.inputs.Image() 
output=gr.outputs.Image() 


io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detection',examples=['content/4.jpg'])
io.launch(debug=True,share=True)