Spaces:
Runtime error
Runtime error
Update gradio_app.py
Browse files17 unmodified lines181920212223100 unmodified lines12412512612712812913014 unmodified lines1451461471481491501511 unmodified line15315415515615715815916031 unmodified lines1921931941951961971981999 unmodified lines20921021121221321421517 unmodified lines# Ensure necessary devices are availabledevice = "cuda" if torch.cuda.is_available() else "cpu"accelerator = Accelerator(mixed_precision='bf16', device_placement=True)# Model paths (replace these with your actual model paths)100 unmodified linesinfo = lora_model.load_state_dict(weights_sd, strict=True)logger.info(f"Loaded LoRA weights from {LORA_WEIGHTS_PATH}: {info}")lora_model.eval()lora_model.to("cuda")# Process the seedif randomize_seed:14 unmodified lineslogger.debug("Conditional image preprocessed.")# Encode the image to latentsae.to("cuda")latents = ae.encode(image)logger.debug("Image encoded to latents.")1 unmodified lineconditions[prompt] = latents.to("cpu")ae.to("cpu")clip_l.to("cuda")t5xxl.to("cuda")# Encode the prompttokenize_strategy = strategy_flux.FluxTokenizeStrategy(512)31 unmodified linesclip_l.to("cpu")t5xxl.to("cpu")torch.cuda.empty_cache()model.to("cuda")# import pdb# pdb.set_trace()9 unmodified linesx = x.float()x = flux_utils.unpack_latents(x, packed_latent_height, packed_latent_width)model.to("cpu")ae.to("cuda")with accelerator.autocast(), torch.no_grad():x = ae.decode(x)logger.debug("Latents decoded into image.")17 unmodified lines1819202122232425100 unmodified lines12612712812913013113214 unmodified lines1471481491501511521531 unmodified line15515615715815916016116231 unmodified lines1941951961971981992009 unmodified lines21021121221321421521617 unmodified lines# Ensure necessary devices are availabledevice = "cuda" if torch.cuda.is_available() else "cpu"logger.info("device: ", device)accelerator = Accelerator(mixed_precision='bf16', device_placement=True)# Model paths (replace these with your actual model paths)100 unmodified linesinfo = lora_model.load_state_dict(weights_sd, strict=True)logger.info(f"Loaded LoRA weights from {LORA_WEIGHTS_PATH}: {info}")lora_model.eval()lora_model.to(device)# Process the seedif randomize_seed:14 unmodified lineslogger.debug("Conditional image preprocessed.")# Encode the image to latentsae.to(device)latents = ae.encode(image)logger.debug("Image encoded to latents.")1 unmodified lineconditions[prompt] = latents.to("cpu")ae.to("cpu")clip_l.to(device)t5xxl.to(device)# Encode the prompttokenize_strategy = strategy_flux.FluxTokenizeStrategy(512)31 unmodified linesclip_l.to("cpu")t5xxl.to("cpu")model.to(device)# import pdb# pdb.set_trace()9 unmodified linesx = x.float()x = flux_utils.unpack_latents(x, packed_latent_height, packed_latent_width)model.to("cpu")ae.to(device)with accelerator.autocast(), torch.no_grad():x = ae.decode(x)logger.debug("Latents decoded into image.")
gradio_app.py+8-7