Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL, AutoPip
|
|
6 |
from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
|
7 |
from diffusers.utils import load_image
|
8 |
from diffusers import FluxControlNetPipeline, FluxControlNetModel, FluxMultiControlNetModel, FluxControlNetImg2ImgPipeline
|
9 |
-
from huggingface_hub import hf_hub_download, HfFileSystem, ModelCard, snapshot_download
|
10 |
import os
|
11 |
import copy
|
12 |
import random
|
@@ -117,6 +117,15 @@ def download_file_mod(url, directory=os.getcwd()):
|
|
117 |
if not path: raise Exception(f"Download error: {url}")
|
118 |
return path
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
class calculateDuration:
|
121 |
def __init__(self, activity_name=""):
|
122 |
self.activity_name = activity_name
|
@@ -245,6 +254,7 @@ def add_custom_lora(custom_lora, selected_indices, current_loras, gallery):
|
|
245 |
if custom_lora:
|
246 |
try:
|
247 |
title, repo, path, trigger_word, image = check_custom_model(custom_lora)
|
|
|
248 |
print(f"Loaded custom LoRA: {repo}")
|
249 |
existing_item_index = next((index for (index, item) in enumerate(current_loras) if item['repo'] == repo), None)
|
250 |
if existing_item_index is None:
|
|
|
6 |
from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
|
7 |
from diffusers.utils import load_image
|
8 |
from diffusers import FluxControlNetPipeline, FluxControlNetModel, FluxMultiControlNetModel, FluxControlNetImg2ImgPipeline
|
9 |
+
from huggingface_hub import hf_hub_download, HfFileSystem, ModelCard, snapshot_download, HfApi
|
10 |
import os
|
11 |
import copy
|
12 |
import random
|
|
|
117 |
if not path: raise Exception(f"Download error: {url}")
|
118 |
return path
|
119 |
|
120 |
+
def is_repo_public(repo_id: str):
|
121 |
+
api = HfApi()
|
122 |
+
try:
|
123 |
+
if api.repo_exists(repo_id=repo_id, token=False): return True
|
124 |
+
else: return False
|
125 |
+
except Exception as e:
|
126 |
+
print(f"Error: Failed to connect {repo_id}. {e}")
|
127 |
+
return False
|
128 |
+
|
129 |
class calculateDuration:
|
130 |
def __init__(self, activity_name=""):
|
131 |
self.activity_name = activity_name
|
|
|
254 |
if custom_lora:
|
255 |
try:
|
256 |
title, repo, path, trigger_word, image = check_custom_model(custom_lora)
|
257 |
+
image = image if is_repo_public(repo) else None
|
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:
|