File size: 661 Bytes
174ccbd
3614f1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174ccbd
 
3614f1d
174ccbd
 
 
 
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
import gradio as gr
import requests
import re

def getFilename_fromCd(cd):
    """
    Get filename from content-disposition
    """
    if not cd:
        return None
    fname = re.findall('filename=(.+)', cd)
    if len(fname) == 0:
        return None
    return fname[0]

def downloadVith():
    print("starting download")
    url = 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'
    r = requests.get(url, allow_redirects=True)
    open("sam_vit_h_4b8939.pth", 'wb').write(r.content)

def greet(name):
    downloadVith()
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()