Update app.py
Browse files
app.py
CHANGED
@@ -63,11 +63,12 @@ for file, link in files.items():
|
|
63 |
def download_from_url(url, model):
|
64 |
if model =='':
|
65 |
try:
|
66 |
-
model =
|
67 |
except:
|
68 |
return "You need to name your model. For example: My-Model", {"choices":show_available("assets/weights"),"__type__":"update"}
|
69 |
url=url.replace('/blob/main/','/resolve/main/')
|
70 |
model=model.replace('.pth','').replace('.index','').replace('.zip','')
|
|
|
71 |
if url == '':
|
72 |
return "URL cannot be left empty.", {"choices":show_available("assets/weights"),"__type__":"update"}
|
73 |
url = url.strip()
|
@@ -83,7 +84,7 @@ def download_from_url(url, model):
|
|
83 |
if url.endswith('.pth'):
|
84 |
subprocess.run(["wget", url, "-O", f'./assets/weights/{model}.pth'])
|
85 |
return f"Sucessfully downloaded as {model}.pth", {"choices":show_available("assets/weights"),"__type__":"update"}
|
86 |
-
|
87 |
if not os.path.exists(f'./logs/{model}'): os.makedirs(f'./logs/{model}')
|
88 |
subprocess.run(["wget", url, "-O", f'./logs/{model}/added_{model}.index'])
|
89 |
return f"Successfully downloaded as added_{model}.index", {"choices":show_available("assets/weights"),"__type__":"update"}
|
|
|
63 |
def download_from_url(url, model):
|
64 |
if model =='':
|
65 |
try:
|
66 |
+
model = url.split('/')[-1].split('?')[0]
|
67 |
except:
|
68 |
return "You need to name your model. For example: My-Model", {"choices":show_available("assets/weights"),"__type__":"update"}
|
69 |
url=url.replace('/blob/main/','/resolve/main/')
|
70 |
model=model.replace('.pth','').replace('.index','').replace('.zip','')
|
71 |
+
print(f"Model name: {model}")
|
72 |
if url == '':
|
73 |
return "URL cannot be left empty.", {"choices":show_available("assets/weights"),"__type__":"update"}
|
74 |
url = url.strip()
|
|
|
84 |
if url.endswith('.pth'):
|
85 |
subprocess.run(["wget", url, "-O", f'./assets/weights/{model}.pth'])
|
86 |
return f"Sucessfully downloaded as {model}.pth", {"choices":show_available("assets/weights"),"__type__":"update"}
|
87 |
+
elif url.endswith('.index'):
|
88 |
if not os.path.exists(f'./logs/{model}'): os.makedirs(f'./logs/{model}')
|
89 |
subprocess.run(["wget", url, "-O", f'./logs/{model}/added_{model}.index'])
|
90 |
return f"Successfully downloaded as added_{model}.index", {"choices":show_available("assets/weights"),"__type__":"update"}
|