Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline,DDIMScheduler | |
| import torch | |
| # Load the model | |
| model_id = "s3nh/artwork-arcane-stable-diffusion" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) | |
| if pipe.scheduler is not None: | |
| pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config) | |
| else: | |
| pipe.scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=True) | |
| # Define the image generation function | |
| def generate_image(prompt): | |
| image = pipe(prompt, num_inference_steps=30).images[0] | |
| return image | |
| # Create the Gradio interface | |
| interface = gr.Interface( | |
| fn=generate_image, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs=gr.Image(label="Generated Image"), | |
| title="Image Generator", | |
| description="Enter a prompt to generate an image using Stable Diffusion." | |
| ) | |
| # Launch the interface | |
| interface.launch() | |