Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,18 @@
|
|
1 |
-
import
|
2 |
-
import
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
# Load the model
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("prompthero/openjourney-v4", torch_dtype=torch.float16).to("cuda")
|
7 |
+
|
8 |
+
def generate_image(prompt):
|
9 |
+
image = pipe(prompt).images[0]
|
10 |
+
return image
|
11 |
+
|
12 |
+
# Create Gradio interface
|
13 |
+
gr.Interface(
|
14 |
+
fn=generate_image,
|
15 |
+
inputs=gr.Textbox(label="Enter your prompt"),
|
16 |
+
outputs="image",
|
17 |
+
title="Hugging Face Image Generator"
|
18 |
+
).launch()
|