Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +9 -3
- modutils.py +4 -2
app.py
CHANGED
|
@@ -22,7 +22,7 @@ from mod import (clear_cache, get_repo_safetensors, is_repo_name, is_repo_exists
|
|
| 22 |
from flux import (search_civitai_lora, select_civitai_lora, search_civitai_lora_json,
|
| 23 |
download_my_lora, get_all_lora_tupled_list, apply_lora_prompt,
|
| 24 |
update_loras)
|
| 25 |
-
from modutils import get_t2i_model_info,
|
| 26 |
from tagger.tagger import predict_tags_wd, compose_prompt_to_copy
|
| 27 |
from tagger.fl2flux import predict_tags_fl2_flux
|
| 28 |
|
|
@@ -113,7 +113,7 @@ def change_base_model(repo_id: str, cn_on: bool, disable_model_cache: bool, prog
|
|
| 113 |
change_base_model.zerogpu = True
|
| 114 |
|
| 115 |
def download_file_mod(url, directory=os.getcwd()):
|
| 116 |
-
path =
|
| 117 |
if not path: raise Exception(f"Download error: {url}")
|
| 118 |
return path
|
| 119 |
|
|
@@ -254,7 +254,13 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
|
| 254 |
if custom_lora:
|
| 255 |
try:
|
| 256 |
title, repo, path, trigger_word, image = check_custom_model(custom_lora)
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
print(f"Loaded custom LoRA: {repo}")
|
| 259 |
existing_item_index = next((index for (index, item) in enumerate(current_loras) if item['repo'] == repo), None)
|
| 260 |
if existing_item_index is None:
|
|
|
|
| 22 |
from flux import (search_civitai_lora, select_civitai_lora, search_civitai_lora_json,
|
| 23 |
download_my_lora, get_all_lora_tupled_list, apply_lora_prompt,
|
| 24 |
update_loras)
|
| 25 |
+
from modutils import get_t2i_model_info, download_hf_file
|
| 26 |
from tagger.tagger import predict_tags_wd, compose_prompt_to_copy
|
| 27 |
from tagger.fl2flux import predict_tags_fl2_flux
|
| 28 |
|
|
|
|
| 113 |
change_base_model.zerogpu = True
|
| 114 |
|
| 115 |
def download_file_mod(url, directory=os.getcwd()):
|
| 116 |
+
path = download_hf_file(directory, url)
|
| 117 |
if not path: raise Exception(f"Download error: {url}")
|
| 118 |
return path
|
| 119 |
|
|
|
|
| 254 |
if custom_lora:
|
| 255 |
try:
|
| 256 |
title, repo, path, trigger_word, image = check_custom_model(custom_lora)
|
| 257 |
+
if "http" in image and not is_repo_public(repo):
|
| 258 |
+
try:
|
| 259 |
+
image = download_file_mod(image)
|
| 260 |
+
except Exception as e:
|
| 261 |
+
print(e)
|
| 262 |
+
image = None
|
| 263 |
+
#image = image if is_repo_public(repo) else None
|
| 264 |
print(f"Loaded custom LoRA: {repo}")
|
| 265 |
existing_item_index = next((index for (index, item) in enumerate(current_loras) if item['repo'] == repo), None)
|
| 266 |
if existing_item_index is None:
|
modutils.py
CHANGED
|
@@ -99,10 +99,12 @@ def download_hf_file(directory, url, progress=gr.Progress(track_tqdm=True)):
|
|
| 99 |
repo_id, filename, subfolder, repo_type = split_hf_url(url)
|
| 100 |
try:
|
| 101 |
print(f"Downloading {url} to {directory}")
|
| 102 |
-
if subfolder is not None: hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, repo_type=repo_type, local_dir=directory, token=hf_token)
|
| 103 |
-
else: hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory, token=hf_token)
|
|
|
|
| 104 |
except Exception as e:
|
| 105 |
print(f"Failed to download: {e}")
|
|
|
|
| 106 |
|
| 107 |
|
| 108 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|
|
|
|
| 99 |
repo_id, filename, subfolder, repo_type = split_hf_url(url)
|
| 100 |
try:
|
| 101 |
print(f"Downloading {url} to {directory}")
|
| 102 |
+
if subfolder is not None: path = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, repo_type=repo_type, local_dir=directory, token=hf_token)
|
| 103 |
+
else: path = hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory, token=hf_token)
|
| 104 |
+
return path
|
| 105 |
except Exception as e:
|
| 106 |
print(f"Failed to download: {e}")
|
| 107 |
+
return None
|
| 108 |
|
| 109 |
|
| 110 |
def download_things(directory, url, hf_token="", civitai_api_key=""):
|