Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load the model and set up the pipeline
|
6 |
+
model_id = "prompthero/openjourney"
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
8 |
+
pipe = pipe.to("cuda")
|
9 |
+
|
10 |
+
def generate_image(prompt):
|
11 |
+
image = pipe(prompt).images[0]
|
12 |
+
return image
|
13 |
+
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_image,
|
16 |
+
inputs=gr.Textbox(prompt="Enter a prompt:"),
|
17 |
+
outputs=gr.Image(),
|
18 |
+
title="Image Generation Model",
|
19 |
+
description="Generate images from text prompts using the OpenJourney model.",
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|