Spaces:
Sleeping
Sleeping
File size: 997 Bytes
174f10e 4abc347 174f10e 4abc347 174f10e 4abc347 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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)
pipe = pipe.to("cuda")
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()
|