Spaces:
Running
on
Zero
Running
on
Zero
Upload 2 files
Browse files
app.py
CHANGED
@@ -996,7 +996,7 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css, delete_ca
|
|
996 |
queue=False,
|
997 |
trigger_mode="once",
|
998 |
show_api=False,
|
999 |
-
).success(get_repo_safetensors, [lora_repo[i]], [lora_weights[i]], queue=False, show_api=False
|
1000 |
).success(apply_lora_prompt_flux, [lora_info[i]], [lora_trigger[i]], queue=False, show_api=False
|
1001 |
).success(compose_lora_json, [lora_repo_json, lora_num[i], lora_repo[i], lora_wt[i], lora_weights[i], lora_trigger[i]], [lora_repo_json], queue=False, show_api=False)
|
1002 |
|
|
|
996 |
queue=False,
|
997 |
trigger_mode="once",
|
998 |
show_api=False,
|
999 |
+
).success(get_repo_safetensors, [lora_repo[i]], [lora_weights[i], lora_info[i]], queue=False, show_api=False
|
1000 |
).success(apply_lora_prompt_flux, [lora_info[i]], [lora_trigger[i]], queue=False, show_api=False
|
1001 |
).success(compose_lora_json, [lora_repo_json, lora_num[i], lora_repo[i], lora_wt[i], lora_weights[i], lora_trigger[i]], [lora_repo_json], queue=False, show_api=False)
|
1002 |
|
mod.py
CHANGED
@@ -8,7 +8,7 @@ import subprocess
|
|
8 |
import os
|
9 |
import re
|
10 |
from translatepy import Translator
|
11 |
-
from huggingface_hub import HfApi, hf_hub_download
|
12 |
from env import num_cns, model_trigger, HF_TOKEN, CIVITAI_API_KEY, DOWNLOAD_LORA_LIST, DIRECTORY_LORAS
|
13 |
from modutils import download_things
|
14 |
|
@@ -72,16 +72,19 @@ def clear_cache():
|
|
72 |
def get_repo_safetensors(repo_id: str):
|
73 |
api = HfApi(token=HF_TOKEN)
|
74 |
try:
|
75 |
-
|
|
|
76 |
files = api.list_repo_files(repo_id=repo_id)
|
|
|
|
|
77 |
except Exception as e:
|
78 |
print(f"Error: Failed to get {repo_id}'s info.")
|
79 |
print(e)
|
80 |
gr.Warning(f"Error: Failed to get {repo_id}'s info.")
|
81 |
-
return gr.update(choices=[])
|
82 |
files = [f for f in files if f.endswith(".safetensors")]
|
83 |
-
if len(files) == 0: return gr.update(value="", choices=[])
|
84 |
-
else: return gr.update(value=files[0], choices=files)
|
85 |
|
86 |
|
87 |
def expand2square(pil_img: Image.Image, background_color: tuple=(0, 0, 0)):
|
|
|
8 |
import os
|
9 |
import re
|
10 |
from translatepy import Translator
|
11 |
+
from huggingface_hub import HfApi, hf_hub_download, ModelCard
|
12 |
from env import num_cns, model_trigger, HF_TOKEN, CIVITAI_API_KEY, DOWNLOAD_LORA_LIST, DIRECTORY_LORAS
|
13 |
from modutils import download_things
|
14 |
|
|
|
72 |
def get_repo_safetensors(repo_id: str):
|
73 |
api = HfApi(token=HF_TOKEN)
|
74 |
try:
|
75 |
+
tag = "None"
|
76 |
+
if not is_repo_name(repo_id) or not is_repo_exists(repo_id): return gr.update(value="", choices=[]), tag
|
77 |
files = api.list_repo_files(repo_id=repo_id)
|
78 |
+
model_card = ModelCard.load(repo_id, token=HF_TOKEN)
|
79 |
+
tag = model_card.data.get("instance_prompt", "")
|
80 |
except Exception as e:
|
81 |
print(f"Error: Failed to get {repo_id}'s info.")
|
82 |
print(e)
|
83 |
gr.Warning(f"Error: Failed to get {repo_id}'s info.")
|
84 |
+
return gr.update(choices=[]), tag
|
85 |
files = [f for f in files if f.endswith(".safetensors")]
|
86 |
+
if len(files) == 0: return gr.update(value="", choices=[]), "None"
|
87 |
+
else: return gr.update(value=files[0], choices=files), tag
|
88 |
|
89 |
|
90 |
def expand2square(pil_img: Image.Image, background_color: tuple=(0, 0, 0)):
|