File size: 1,024 Bytes
2cf6be0 |
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 |
import gradio as gr
import numpy as np
from PIL import Image
import torch
import safetensors.torch as st
from diffusers import DiffusionPipeline
model_id = "./ckpts/snckrsgen.safetensors"
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_safe_tensors=True)
pipe.to("cuda")
# Function to generate an image from text using diffusion
def generate_image(prompt):
images = pipe(prompt=prompt)
return images[0]
# Gradio interface
inputs = gr.inputs.Textbox(lines=5, label="Enter text to generate image:")
outputs = gr.outputs.Image(label="Generated Image")
title = "ShoeGen: Generate an Image of a Shoe"
description = "Enter a text description of a shoe to generate an image of the shoe."
examples = [["A red shoe with white laces and black sole."], ["A blue sneaker with a white stripe."], ["A brown boot with a buckle."]]
gr.Interface(
fn=generate_image,
inputs=inputs,
outputs=outputs,
title=title,
description=description,
examples=examples
).launch()
|