File size: 600 Bytes
189f0af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch

# Load the model and set up the pipeline
model_id = "prompthero/openjourney"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

def generate_image(prompt):
    image = pipe(prompt).images[0]
    return image

iface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(prompt="Enter a prompt:"),
    outputs=gr.Image(),
    title="Image Generation Model",
    description="Generate images from text prompts using the OpenJourney model.",
)

iface.launch()