Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files74 unmodified lines7576777878798081164 unmodified lines24624724824924925025125225325425525525625725835 unmodified lines29429529629729729829930050 unmodified lines351352353354354355356357123 unmodified lines481482483484484485486487187 unmodified lines6756766776786786796806806816826832 unmodified lines68668768868968969069169277 unmodified lines770771772773773774775776158 unmodified lines93593693793893994094186 unmodified lines102810291030103110321033103410351036103710381039104010411042154 unmodified lines1197119811991190120012011202120396 unmodified lines130013011302130313041305130674 unmodified linesimport warningsfrom stablepy import loggerfrom diffusers import FluxPipeline# import urllib.parseimport urllib.parseimport subprocess
os.system("pip list")164 unmodified lines self.active_downloads.add(lock_key) break
yield f"Waiting for existing download to finish: {model_name}..." yield f"Waiting for existing download to finish: {escape_html(model_name)}..." time.sleep(1)
try: # download link model > model_name if model_name.startswith("http"): yield f"Downloading model: {model_name}" yield f"Downloading model: {escape_html(model_name)}" model_name = download_things(DIRECTORY_MODELS, model_name, HF_TOKEN, CIVITAI_API_KEY) if not model_name: raise ValueError("Error retrieving model information from URL")35 unmodified lines
self.status_loading = True
yield f"Loading model: {model_name}" yield f"Loading model: {escape_html(model_name)}"
if vae_model == "BakedVAE": vae_model = model_name50 unmodified lines self.last_load = datetime.now() self.status_loading = False
yield f"Model loaded: {model_name}" yield f"Model loaded: {escape_html(model_name)}"
# @spaces.GPU(duration=59) @torch.inference_mode()123 unmodified lines
vae_model = vae_model if vae_model != "None" else None loras_list = [lora1, lora2, lora3, lora4, lora5, lora6, lora7] vae_msg = f"VAE: {vae_model}" if vae_model else "" vae_msg = f"VAE: {escape_html(vae_model)}" if vae_model else "" msg_lora = ""
logger.debug(f"Config model: {model_name}, {vae_model}, {loras_list}")187 unmodified lines
for status, lora in zip(self.model.lora_status, self.model.lora_memory): if status: msg_lora += f"<br>Loaded: {lora}" msg_lora += f"<br>Loaded: {escape_html(lora)}" elif status is not None: msg_lora += f"<br>Error with: {lora}" msg_lora += f"<br>Error with: {escape_html(lora)}"
if msg_lora: info_images += msg_lora2 unmodified lines
download_links = "<br>".join( [ f'<a href="{path.replace("/images/", f"/gradio_api/file={allowed_path}/")}" download="{os.path.basename(path)}">Download Image {i + 1}</a>' f'<a href="{path.replace("/images/", f"/gradio_api/file={allowed_path}/")}" download="{escape_html(os.path.basename(path))}">Download Image {i + 1}</a>' for i, path in enumerate(image_path) ] )77 unmodified lines ) gr.Info(f"LoRAs in cache: {lora_cache_msg}")
msg_request = f"Requesting {gpu_duration_arg}s. of GPU time.\nModel: {sd_gen.model.base_model_id}" msg_request = f"Requesting {gpu_duration_arg}s. of GPU time.\nModel: {escape_html(sd_gen.model.base_model_id)}" if verbose_arg: gr.Info(msg_request) print(msg_request)158 unmodified lines "Image resolution": gr.update(value=1024), "Strength": gr.update(), "Prompt emphasis": gr.update(), "VAE": gr.update(), }
# Generate up to 7 LoRAs86 unmodified lines val = filtered_models[0] else: val = name_model if key == "VAE": val_unquote = urllib.parse.unquote(str(val)) filtered_vaes = [v for v in vae_model_list if str(val) in v or val_unquote in v] if filtered_vaes: val = filtered_vaes[0] elif val in ["None", "BakedVAE"]: val = val else: continue if key == "Hires upscaler": if val not in UPSCALER_KEYS: continue154 unmodified lines label="Style Prompt", interactive=True, ) style_json_gui = gr.File(label="Style JSON File") style_json_gui = gr.File(label="Style JSON File", file_count="single", file_types=[".json"]) style_button = gr.Button("Load styles")
def load_json_style_file(json):96 unmodified lines image_resolution_gui, strength_gui, prompt_syntax_gui, vae_model_gui, lora1_gui, lora_scale_1_gui, lora2_gui,app.py+22-11