Spaces:
Sleeping
Sleeping
File size: 1,137 Bytes
e984a2c a8c9598 e984a2c b9a20a2 e984a2c ef0cbae e984a2c a8c9598 e984a2c a8c9598 e984a2c a8c9598 e984a2c a8c9598 |
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 |
import gradio as gr
import numpy as np
import random
from diffusers import DiffusionPipeline
from diffusers import StableDiffusionXLPipeline, DPMSolverSinglestepScheduler
import torch
import spaces
pipe = StableDiffusionXLPipeline.from_pretrained("sd-community/sdxl-flash").to("cuda")
@spaces.GPU(duration=50)
def generate_image(prompt, negative_prompt):
# Run the diffusion model to generate an image
output = pipe(prompt, negative_prompt, num_inference_steps=7, guidance_scale=3.5)
return output.images[0]
prompt = gr.Textbox(label = "Prompt", info = "Describe the subject, the background and the style of image", placeholder = "Describe what you want to see", lines = 2)
negative_prompt = gr.Textbox(label = "Negative prompt", placeholder = "Describe what you do NOT want to see", value = "Ugly, malformed, noise, blur, watermark")
gr_interface = gr.Interface(
fn=generate_image,
inputs=[prompt, negative_prompt],
outputs="image",
title="Real-time Image Generation with Diffusion",
description="Enter a prompt to generate an image",
theme="soft"
)
# Launch the Gradio app
gr_interface.launch() |