Spaces:
Runtime error
Runtime error
File size: 1,564 Bytes
c4cc804 2b949d1 dec9f9f 3075cc3 dec9f9f 2b949d1 dec9f9f 2b949d1 dec9f9f d4d7506 3eb0af5 31c5edd 2b949d1 dec9f9f 3eb0af5 31c5edd 3eb0af5 d4d7506 bbb69ec d4d7506 dec9f9f d4d7506 50badfd 3eb0af5 e054aa0 3eb0af5 2b949d1 664c874 ff7dd03 |
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 32 33 34 35 36 37 |
from diffusers import StableDiffusionXLPipeline
import torch
from gradio import Interface, Image, Dropdown, Slider
import gradio as gr
import spaces
model_id = "RunDiffusion/Juggernaut-X-v10"
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")
@spaces.GPU()
def text_to_image(prompt, negative_prompt, steps, guidance_scale, add_4k_masterpiece, progress=gr.Progress(track_tqdm=True)):
if add_4k_masterpiece:
prompt += ", 4k, (masterpiece)"
image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
return image
# duplicate_button = gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
gradio_interface = Interface(
fn=text_to_image,
allow_duplication=False,
inputs=[
gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
gr.Textbox(label="Negative Prompt", lines=2, placeholder="What to exclude from the image..."),
gr.Slider(minimum=1, maximum=65, value=50, label="Steps", step=1),
gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1),
gr.Checkbox(label="Add recommended prompt items (4k, masterpiece)", value=False)
],
outputs=Image(type="pil", show_download_button=True),
examples=[
["1 young woman , 18 yo , full body shot , perfect teen body , Photorealistic, real photo,"],
],
cache_examples=False,
theme=gr.themes.Soft()
)
gradio_interface.launch() |