Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from diffusers import StableDiffusionPipeline
|
4 |
+
import torch
|
5 |
+
|
6 |
+
def dummy(images, **kwargs): return images, False
|
7 |
+
|
8 |
+
|
9 |
+
def generate_image(prompt):
|
10 |
+
model_id = "prompthero/openjourney-v4"
|
11 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
12 |
+
pipe.safety_checker = dummy
|
13 |
+
pipe = pipe.to("cuda")
|
14 |
+
image = pipe(prompt).images[0]
|
15 |
+
return image
|
16 |
+
|
17 |
+
|
18 |
+
iface = gr.Interface(
|
19 |
+
generate_image,
|
20 |
+
"textbox",
|
21 |
+
"image",
|
22 |
+
title="Image Generator",
|
23 |
+
description="Generate a realistic photo using prompts.",
|
24 |
+
examples=[["realistic! photoshoot for a new balenciaga lookbook, color film photography, portrait of a beautiful woman wearing a balaclava mask, photo in style of tyler mitchell, 35mm lens"]],
|
25 |
+
)
|
26 |
+
|
27 |
+
iface.launch()
|