Mrahsanahmad commited on
Commit
3614f1d
1 Parent(s): 67698b4

download file

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,6 +1,26 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
 
4
  return "Hello " + name + "!!"
5
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
1
  import gradio as gr
2
+ import requests
3
+ import re
4
+
5
+ def getFilename_fromCd(cd):
6
+ """
7
+ Get filename from content-disposition
8
+ """
9
+ if not cd:
10
+ return None
11
+ fname = re.findall('filename=(.+)', cd)
12
+ if len(fname) == 0:
13
+ return None
14
+ return fname[0]
15
+
16
+ def downloadVith():
17
+ print("starting download")
18
+ url = 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'
19
+ r = requests.get(url, allow_redirects=True)
20
+ open("sam_vit_h_4b8939.pth", 'wb').write(r.content)
21
 
22
  def greet(name):
23
+ downloadVith()
24
  return "Hello " + name + "!!"
25
 
26
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")