Spaces:
Runtime error
Runtime error
Update app.py
Browse files18 unmodified lines19202122232425262728293018 unmodified linesdef generate(prompt):image = pipe(prompt, num_inference_steps=1, guidance_scale=0).images[0]return image# Ensure using the same inference steps as the loaded model and CFG set to 0.# @spaces.GPU# def greet(prompt):# image = pipe(prompt, num_inference_steps=1, guidance_scale=0).images[0].save("output.png")# return imageoutput_image = gr.Image(type="pil")demo = gr.Interface(fn=generate, inputs="text", outputs=output_image)demo.launch()18 unmodified lines192021222324252627282930313218 unmodified linesdef generate(prompt):image = pipe(prompt, num_inference_steps=1, guidance_scale=0).images[0]return imageoutput_image = gr.Image(type="pil")demo = gr.Interface(fn=generate, inputs="text", outputs=output_image)if __name__ == "__main__":unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")# Ensure sampler uses "trailing" timesteps and "sample" prediction type.pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", prediction_type="sample")demo.launch()
app.py+8-6