Update app.py
Browse files20 unmodified lines2122232425262728293031323334353637388 unmodified lines4748495051525 unmodified lines5859606162636447 unmodified lines11211311411511611720 unmodified linesdevice = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")if torch.cuda.is_available():pipe = StableDiffusionXLPipeline.from_pretrained("sd-community/sdxl-flash",torch_dtype=torch.float16,use_safetensors=True,add_watermarker=False)pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)pipe.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle2")pipe.set_adapters(["dalle2"])pipe.to("cuda")def save_image(img):unique_name = str(uuid.uuid4()) + ".png"8 unmodified lines@spaces.GPU(duration=30, queue=False)def generate(prompt: str,negative_prompt: str = "",use_negative_prompt: bool = False,seed: int = 0,5 unmodified linesuse_resolution_binning: bool = True,progress=gr.Progress(track_tqdm=True),):pipe.to(device)seed = int(randomize_seed_fn(seed, randomize_seed))generator = torch.Generator().manual_seed(seed)47 unmodified lines)run_button = gr.Button("Run", scale=0)result = gr.Gallery(label="Result", columns=1)with gr.Accordion("Advanced options", open=False):with gr.Row():use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)20 unmodified lines212223242526272829303132338 unmodified lines424344454647485 unmodified lines54555657585960616263646566676869707172737475767778798047 unmodified lines12812913013113213313413520 unmodified linesdevice = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")pipe = StableDiffusionXLPipeline.from_pretrained("sd-community/sdxl-flash",torch_dtype=torch.float16,use_safetensors=True,add_watermarker=False)pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)def save_image(img):unique_name = str(uuid.uuid4()) + ".png"8 unmodified lines@spaces.GPU(duration=30, queue=False)def generate(prompt: str,style: str,negative_prompt: str = "",use_negative_prompt: bool = False,seed: int = 0,5 unmodified linesuse_resolution_binning: bool = True,progress=gr.Progress(track_tqdm=True),):if style=="BEST" :pipe.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle2")pipe.load_lora_weights("ehristoforu/dalle-3-xl", weight_name="dalle-3-xl-lora-v1.safetensors", adapter_name="dalle1")pipe.set_adapters(["dalle2","dalle1"], adapter_weights=[1.5, 0.5])elif style=="Origami":pipe.load_lora_weights("RalFinger/origami-style-sdxl-lora", weight_name="ral-orgmi-sdxl.safetensors", adapter_name="origami")pipe.set_adapters(["origami"], adapter_weights=[2])elif style=="3D":pipe.load_lora_weights("artificialguybr/3DRedmond-V1", weight_name="3DRedmond-3DRenderStyle-3DRenderAF.safetensors", adapter_name="dalle2")pipe.load_lora_weights("goofyai/3d_render_style_xl", weight_name="3d_render_style_xl.safetensors", adapter_name="dalle1")pipe.set_adapters(["dalle2","dalle1"], adapter_weights=[1.1, 0.8])elif style=="PixelART":pipe.load_lora_weights("artificialguybr/PixelArtRedmond", weight_name="PixelArtRedmond-Lite64.safetensors", adapter_name="lora")pipe.load_lora_weights("nerijs/pixel-art-xl", weight_name="pixel-art-xl.safetensors", adapter_name="pixel")pipe.set_adapters(["lora", "pixel"], adapter_weights=[1.0, 1.2])elif style=="Logo":pipe.load_lora_weights("artificialguybr/StickersRedmond", weight_name="StickersRedmond.safetensors", adapter_name="lora")pipe.load_lora_weights("artificialguybr/LogoRedmond-LogoLoraForSDXL", weight_name="LogoRedmond_LogoRedAF.safetensors", adapter_name="pixel")pipe.set_adapters(["lora", "pixel"], adapter_weights=[0.5, 1.2])else:pipe.to("cuda")seed = int(randomize_seed_fn(seed, randomize_seed))generator = torch.Generator().manual_seed(seed)47 unmodified lines)run_button = gr.Button("Run", scale=0)result = gr.Gallery(label="Result", columns=1)with gr.Row():style = gr.Radio(choices=["Default","BEST","3D", "PixelART","Logo","Origami"],label="Style", value="Default")with gr.Accordion("Advanced options", open=False):with gr.Row():use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)
app.py+31-13