Spaces:
Runtime error
Runtime error
File size: 1,304 Bytes
b6e706c bc0fe56 b6e706c a8bb51e b6e706c dac5c68 b6e706c |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
from diffusers import StableDiffusionXLPipeline
import torch
from transformers.pipelines.image_to_text import Image
import gradio as gr
pipe = StableDiffusionXLPipeline.from_pretrained(
"segmind/SSD-1B",
torch_dtype = torch.float32,
use_safetensors=True,
# for cuda -- variant = "fp16",
)
#pipe.to("cuda")
prompt = "astronaut riding a green horse"
neg_prompt = "ugly, blurry, poor quality"
def generate_image(prompt, neg_prompt):
image = pipe(
prompt=prompt,
negative_prompt=neg_prompt
).images[0]
return image
prompt = gr.Text(
label="Prompt",
show_label=False,
max_lines=1,
placeholder="Enter your prompt :",
container=False
)
neg_prompt = gr.Text(
label="Negative Prompt",
show_label=False,
max_lines=1,
placeholder="Enter your negative prompt",
container=False
)
iface = gr.Interface(
fn=generate_image,
inputs=[prompt, neg_prompt],
outputs="image",
title="Text to Image Generation",
examples=[
["a painting of a cute cat sitting on a chair","ugly, blurry"],
["an assortment riding a horse on mars","poorly down"]
],
allow_flagging=False
)
iface.launch(share=True)
#image = pipe(prompt=prompt, negative_prompt = neg_prompt).images[0]
# print(image)
|