Sa-m commited on
Commit
fed1544
1 Parent(s): 4220436

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import torch
4
+
5
+
6
+ #Repo.clone_from("https://github.com/ultralytics/yolov5", "./content")
7
+ #subprocess.run(["git","clone", "https://github.com/ultralytics/yolov5"])
8
+ '''gdd.download_file_from_google_drive(file_id='1xJcr1zuuoC6bbu6wGvmyw5dl0mUEi-Jn',
9
+ dest_path='content/train_data.zip',
10
+ unzip=True)
11
+ gdd.download_file_from_google_drive(file_id='1UJ9Y2mw2KBRY0tO-TnBs5RALLya6C2dW',
12
+ dest_path='content/video.zip',
13
+ unzip=True) '''
14
+ #subprocess.run(["mv","content/custom_data.yaml","./yolov5/data"])
15
+
16
+ def find(name, path):
17
+ for root, dirs, files in os.walk(path):
18
+ if name in files:
19
+ return os.path.join(root, name)
20
+
21
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='/content/best.pt', force_reload=True)
22
+ def detect(inp):
23
+ output=model(inp)
24
+ #outPath=
25
+ #out_path='./yolov5/runs/detect/exp/'+inp_vid.split('/')[2]
26
+ return output
27
+
28
+ inp=gr.inputs.Image()
29
+ output=gr.outputs.Image()
30
+
31
+
32
+ io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detection',examples=['content/4.jpg'])
33
+ io.launch(debug=True,share=True)
34
+
35
+
36
+
37
+
38
+