Spaces:
Running
Running
Commit
·
c5578ec
1
Parent(s):
62709a7
Update scripts/mainrunpodA1111.py
Browse files- scripts/mainrunpodA1111.py +29 -6
scripts/mainrunpodA1111.py
CHANGED
|
@@ -10,6 +10,7 @@ from torch.hub import download_url_to_file
|
|
| 10 |
from urllib.parse import urlparse, parse_qs, unquote
|
| 11 |
import re
|
| 12 |
import six
|
|
|
|
| 13 |
|
| 14 |
from urllib.request import urlopen, Request
|
| 15 |
import tempfile
|
|
@@ -217,8 +218,7 @@ def mdl(Original_Model_Version, Path_to_MODEL, MODEL_LINK):
|
|
| 217 |
|
| 218 |
return model
|
| 219 |
def modeldwn(model_LINK):
|
| 220 |
-
|
| 221 |
-
|
| 222 |
if model_LINK=='':
|
| 223 |
print('[1;33mNothing to do')
|
| 224 |
else:
|
|
@@ -235,7 +235,7 @@ def modeldwn(model_LINK):
|
|
| 235 |
else:
|
| 236 |
print('[1;33mModel already exists')
|
| 237 |
elif src=='gdrive':
|
| 238 |
-
modelname=
|
| 239 |
loramodel=f'/workspace/sd/stable-diffusion-webui/models/Stable-diffusion/{modelname}'
|
| 240 |
if not os.path.exists(loramodel):
|
| 241 |
gdown.download(url=model_LINK, output=loramodel, quiet=False, fuzzy=True)
|
|
@@ -257,8 +257,7 @@ def modeldwn(model_LINK):
|
|
| 257 |
print('[1;31mWrong link, check that the link is valid')
|
| 258 |
|
| 259 |
def loradwn(LoRA_LINK):
|
| 260 |
-
|
| 261 |
-
|
| 262 |
if LoRA_LINK=='':
|
| 263 |
print('[1;33mNothing to do')
|
| 264 |
else:
|
|
@@ -275,7 +274,7 @@ def loradwn(LoRA_LINK):
|
|
| 275 |
else:
|
| 276 |
print('[1;33mModel already exists')
|
| 277 |
elif src=='gdrive':
|
| 278 |
-
modelname=
|
| 279 |
loramodel=f'/workspace/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
| 280 |
if not os.path.exists(loramodel):
|
| 281 |
gdown.download(url=LoRA_LINK, output=loramodel, quiet=False, fuzzy=True)
|
|
@@ -498,7 +497,31 @@ def getsrc(url):
|
|
| 498 |
src='others'
|
| 499 |
return src
|
| 500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
|
| 503 |
def get_name(url, gdrive):
|
| 504 |
|
|
|
|
| 10 |
from urllib.parse import urlparse, parse_qs, unquote
|
| 11 |
import re
|
| 12 |
import six
|
| 13 |
+
import gdown
|
| 14 |
|
| 15 |
from urllib.request import urlopen, Request
|
| 16 |
import tempfile
|
|
|
|
| 218 |
|
| 219 |
return model
|
| 220 |
def modeldwn(model_LINK):
|
| 221 |
+
|
|
|
|
| 222 |
if model_LINK=='':
|
| 223 |
print('[1;33mNothing to do')
|
| 224 |
else:
|
|
|
|
| 235 |
else:
|
| 236 |
print('[1;33mModel already exists')
|
| 237 |
elif src=='gdrive':
|
| 238 |
+
modelname=get_true_name(model_LINK)
|
| 239 |
loramodel=f'/workspace/sd/stable-diffusion-webui/models/Stable-diffusion/{modelname}'
|
| 240 |
if not os.path.exists(loramodel):
|
| 241 |
gdown.download(url=model_LINK, output=loramodel, quiet=False, fuzzy=True)
|
|
|
|
| 257 |
print('[1;31mWrong link, check that the link is valid')
|
| 258 |
|
| 259 |
def loradwn(LoRA_LINK):
|
| 260 |
+
|
|
|
|
| 261 |
if LoRA_LINK=='':
|
| 262 |
print('[1;33mNothing to do')
|
| 263 |
else:
|
|
|
|
| 274 |
else:
|
| 275 |
print('[1;33mModel already exists')
|
| 276 |
elif src=='gdrive':
|
| 277 |
+
modelname=get_true_name(LoRA_LINK)
|
| 278 |
loramodel=f'/workspace/sd/stable-diffusion-webui/models/Lora/{modelname}'
|
| 279 |
if not os.path.exists(loramodel):
|
| 280 |
gdown.download(url=LoRA_LINK, output=loramodel, quiet=False, fuzzy=True)
|
|
|
|
| 497 |
src='others'
|
| 498 |
return src
|
| 499 |
|
| 500 |
+
def get_true_name(url):
|
| 501 |
+
import requests
|
| 502 |
+
from bs4 import BeautifulSoup
|
| 503 |
+
|
| 504 |
+
# Отправляем запрос на страницу предпросмотра файла
|
| 505 |
+
response = requests.get(url)
|
| 506 |
+
|
| 507 |
+
# Проверяем, успешно ли выполнен запрос
|
| 508 |
+
if response.status_code != 200:
|
| 509 |
+
print(f"Failed to retrieve the page: {response.status_code}")
|
| 510 |
+
return None
|
| 511 |
|
| 512 |
+
# Используем BeautifulSoup для парсинга HTML
|
| 513 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 514 |
+
|
| 515 |
+
# Ищем тег <title>, который может содержать имя файла
|
| 516 |
+
title_tag = soup.find('title')
|
| 517 |
+
if title_tag:
|
| 518 |
+
# Имя файла может быть в формате "file_name.extension - Google Drive" в теге <title>
|
| 519 |
+
# Поэтому мы разделяем строку по ' - ' и берем первую часть
|
| 520 |
+
file_name = title_tag.text.split(' - ')[0]
|
| 521 |
+
return file_name
|
| 522 |
+
else:
|
| 523 |
+
print("Failed to find the title tag")
|
| 524 |
+
return None
|
| 525 |
|
| 526 |
def get_name(url, gdrive):
|
| 527 |
|