Spaces:
Runtime error
Runtime error
feat: add more models and sideload
Browse files24 unmodified lines25262728293028293031333432333435363738394041424344454653 unmodified lines100101102941031041059810610710826 unmodified lines13513613713113813914013414114214314476 unmodified lines22122222321722422522622722858 unmodified lines28728828929029129229329429524 unmodified linesfrom modules.lora import LoRANetwork
models = [ ("AbyssOrangeMix2", "Korakoe/AbyssOrangeMix2-HF"), ("Basil Mix", "nuigurumi/basil_mix"), ("Pastal Mix", "andite/pastel-mix"), ("AbyssOrangeMix2 (fast)", "Korakoe/AbyssOrangeMix2-HF", 2), ("Pastal Mix (fast)", "andite/pastel-mix", 2),]
base_name, base_model, = models[0]clip_skip = 2alt_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)pipe.set_clip_skip(clip_skip)if torch.cuda.is_available(): pipe = pipe.to("cuda")
def get_model_list(): return models
26 unmodified lines g_lora = lora_cache[name] g_unet.set_attn_processor(CrossAttnProcessor()) g_lora.reset() return g_unet, g_lora return g_unet, g_lora, models[keys.index(name)][2]
# precache on huggingfacefor model in get_model_list():for model in models: get_model(model[0])
def error_str(error, title="Error"):76 unmodified lines restore_all() generator = torch.Generator("cuda").manual_seed(int(seed))
local_unet, local_lora = get_model(model) 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 lines if 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