Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import re
|
|
| 9 |
import uuid
|
| 10 |
from typing import Optional
|
| 11 |
import json
|
|
|
|
| 12 |
|
| 13 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 14 |
from huggingface_hub import Repository, HfApi
|
|
@@ -26,6 +27,7 @@ BOOLPARM = {
|
|
| 26 |
False: "false",
|
| 27 |
None: "", # Should not pass parm in this case.
|
| 28 |
}
|
|
|
|
| 29 |
|
| 30 |
def download_file(url, file_path, folder, api_key=None):
|
| 31 |
headers = {}
|
|
@@ -38,6 +40,7 @@ def download_file(url, file_path, folder, api_key=None):
|
|
| 38 |
curl_cmd.extend(['-H', f'Authorization: Bearer {api_key}'])
|
| 39 |
try:
|
| 40 |
result = subprocess.run(curl_cmd, check=True, capture_output=True, text=True)
|
|
|
|
| 41 |
except subprocess.CalledProcessError as e:
|
| 42 |
if ('401' in e.stderr or '403' in e.stderr) and not api_key:
|
| 43 |
# Try again with authorization
|
|
@@ -390,7 +393,7 @@ Once uploaded, it will add this repository to CivitaiArchive.com as a mirror.
|
|
| 390 |
submit_source_civit = gr.Textbox(
|
| 391 |
placeholder="https://civitai.com/models/144684 or https://civitai.com/user/username",
|
| 392 |
label="CivitAI URL",
|
| 393 |
-
info="Enter either a model URL or user profile URL",
|
| 394 |
)
|
| 395 |
destination_repo = gr.Textbox(
|
| 396 |
placeholder="my-awesome-model",
|
|
|
|
| 9 |
import uuid
|
| 10 |
from typing import Optional
|
| 11 |
import json
|
| 12 |
+
import time
|
| 13 |
|
| 14 |
from apscheduler.schedulers.background import BackgroundScheduler
|
| 15 |
from huggingface_hub import Repository, HfApi
|
|
|
|
| 27 |
False: "false",
|
| 28 |
None: "", # Should not pass parm in this case.
|
| 29 |
}
|
| 30 |
+
SLPDL = 5 # Seconds to wait between downloads - eases strain on the servers.
|
| 31 |
|
| 32 |
def download_file(url, file_path, folder, api_key=None):
|
| 33 |
headers = {}
|
|
|
|
| 40 |
curl_cmd.extend(['-H', f'Authorization: Bearer {api_key}'])
|
| 41 |
try:
|
| 42 |
result = subprocess.run(curl_cmd, check=True, capture_output=True, text=True)
|
| 43 |
+
time.sleep(SLPDL)
|
| 44 |
except subprocess.CalledProcessError as e:
|
| 45 |
if ('401' in e.stderr or '403' in e.stderr) and not api_key:
|
| 46 |
# Try again with authorization
|
|
|
|
| 393 |
submit_source_civit = gr.Textbox(
|
| 394 |
placeholder="https://civitai.com/models/144684 or https://civitai.com/user/username",
|
| 395 |
label="CivitAI URL",
|
| 396 |
+
info="Enter either a model URL or user profile URL; OPTIONAL when favourites is toggled",
|
| 397 |
)
|
| 398 |
destination_repo = gr.Textbox(
|
| 399 |
placeholder="my-awesome-model",
|