Spaces:
Runtime error
Runtime error
feat: add more models and sideload
Browse files24 unmodified lines2526272829303132333435363753 unmodified lines91929394959697989910010126 unmodified lines12812913013113213313413513613776 unmodified lines21421521621721821922058 unmodified lines27928028128228328424 unmodified linesfrom modules.lora import LoRANetworkmodels = [("AbyssOrangeMix2", "Korakoe/AbyssOrangeMix2-HF"),("Basil Mix", "nuigurumi/basil_mix"),("Pastal Mix", "andite/pastel-mix"),]base_name, base_model, = models[0]clip_skip = 2samplers_k_diffusion = [("Euler a", "sample_euler_ancestral", {}),53 unmodified lines)unet.set_attn_processor(CrossAttnProcessor)pipe.set_clip_skip(clip_skip)if torch.cuda.is_available():pipe = pipe.to("cuda")def get_model_list():return models26 unmodified linesg_lora = lora_cache[name]g_unet.set_attn_processor(CrossAttnProcessor())g_lora.reset()return g_unet, g_lora# precache on huggingfacefor model in get_model_list():get_model(model[0])def error_str(error, title="Error"):76 unmodified linesrestore_all()generator = torch.Generator("cuda").manual_seed(int(seed))local_unet, local_lora = get_model(model)if lora_state is not None and lora_state != "":local_lora.load(lora_state, lora_scale)local_lora.to(local_unet.device, dtype=local_unet.dtype)58 unmodified linesif embs is not None and len(embs) > 0:restore_all()end_time = time.time()vram_free, vram_total = torch.cuda.mem_get_info()print(f"done: res={width}x{height}, step={steps}, time={round(end_time-start_time, 2)}s, vram_alloc={convert_size(vram_total-vram_free)}/{convert_size(vram_total)}")24 unmodified lines2526272829303132333435363738394041424344454653 unmodified lines10010110210310410510610710826 unmodified lines13513613713813914014114214314476 unmodified lines22122222322422522622722858 unmodified lines28728828929029129229329429524 unmodified linesfrom modules.lora import LoRANetworkmodels = [("AbyssOrangeMix2 (fast)", "Korakoe/AbyssOrangeMix2-HF", 2),("Pastal Mix (fast)", "andite/pastel-mix", 2),]alt_models = [("ACertainModel", "JosephusCheung/ACertainModel", 2),("Basil Mix", "nuigurumi/basil_mix", 2),("Stable Diffusion V1.5", "runwayml/stable-diffusion-v1-5", 1),("Anything V3.0", "Linaqruf/anything-v3.0", 2),("Open Journey", "prompthero/openjourney", 1),("Eimis AnimeDiffusion", "eimiss/EimisAnimeDiffusion_1.0v", 2)("Dreamlike Photoreal 2.0", "dreamlike-art/dreamlike-photoreal-2.0", 1)("Redshift Diffusion", "nitrosocke/redshift-diffusion", 1)]base_name, base_model, clip_skip = models[0]samplers_k_diffusion = [("Euler a", "sample_euler_ancestral", {}),53 unmodified lines)unet.set_attn_processor(CrossAttnProcessor)if torch.cuda.is_available():pipe = pipe.to("cuda")def get_model_list():return models26 unmodified linesg_lora = lora_cache[name]g_unet.set_attn_processor(CrossAttnProcessor())g_lora.reset()return g_unet, g_lora, models[keys.index(name)][2]# precache on huggingfacefor model in models:get_model(model[0])def error_str(error, title="Error"):76 unmodified linesrestore_all()generator = torch.Generator("cuda").manual_seed(int(seed))local_unet, local_lora, clip_skip = get_model(model)pipe.set_clip_skip(clip_skip)if lora_state is not None and lora_state != "":local_lora.load(lora_state, lora_scale)local_lora.to(local_unet.device, dtype=local_unet.dtype)58 unmodified linesif embs is not None and len(embs) > 0:restore_all()if model in [key[0] for key in alt_models]:local_unet.to("cpu")end_time = time.time()vram_free, vram_total = torch.cuda.mem_get_info()print(f"done: res={width}x{height}, step={steps}, time={round(end_time-start_time, 2)}s, vram_alloc={convert_size(vram_total-vram_free)}/{convert_size(vram_total)}")
app.py+21-10