Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,92 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
-
import random
|
3 |
|
4 |
model = gr.load("models/Purz/face-projection")
|
5 |
|
6 |
-
def generate_image(text):
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
examples = [
|
10 |
-
["Humanoid Cat Warrior, Full View"],
|
11 |
-
["Warhammer Sisterhood"],
|
12 |
-
["Future Robots war"],
|
13 |
-
["Fantasy dragon"]
|
14 |
]
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
prompt = gr.Textbox(
|
30 |
-
label="Type here your imagination:",
|
31 |
-
show_label=False,
|
32 |
-
max_lines=1,
|
33 |
-
placeholder="Type or click an example...",
|
34 |
-
container=False,
|
35 |
-
)
|
36 |
-
|
37 |
-
run_button = gr.Button("Generate Image", scale=0, variant="primary")
|
38 |
-
|
39 |
-
result = gr.Image(label="Generated Image", show_label=False)
|
40 |
-
|
41 |
-
with gr.Accordion("Advanced Settings", open=False):
|
42 |
-
negative_prompt = gr.Text(
|
43 |
-
label="Negative prompt",
|
44 |
-
max_lines=1,
|
45 |
-
placeholder="Enter a negative prompt",
|
46 |
-
visible=False,
|
47 |
-
)
|
48 |
-
|
49 |
-
with gr.Row():
|
50 |
-
width = gr.Slider(
|
51 |
-
label="Width",
|
52 |
-
minimum=256,
|
53 |
-
maximum=1024,
|
54 |
-
step=32,
|
55 |
-
value=1024
|
56 |
-
)
|
57 |
-
height = gr.Slider(
|
58 |
-
label="Height",
|
59 |
-
minimum=256,
|
60 |
-
maximum=1024,
|
61 |
-
step=32,
|
62 |
-
value=1024
|
63 |
-
)
|
64 |
-
|
65 |
-
with gr.Row():
|
66 |
-
guidance_scale = gr.Slider(
|
67 |
-
label="Guidance scale",
|
68 |
-
minimum=0.0,
|
69 |
-
maximum=10.0,
|
70 |
-
step=0.1,
|
71 |
-
value=0.0
|
72 |
-
)
|
73 |
-
|
74 |
-
num_inference_steps = gr.Slider(
|
75 |
-
label="Number of inference steps",
|
76 |
-
minimum=1,
|
77 |
-
maximum=50,
|
78 |
-
step=1,
|
79 |
-
value=2
|
80 |
-
)
|
81 |
-
|
82 |
-
gr.Examples(examples=examples, inputs=[prompt])
|
83 |
-
|
84 |
-
gr.on(
|
85 |
-
triggers=[run_button.click, prompt.submit],
|
86 |
-
fn=generate_image,
|
87 |
-
inputs=[prompt],
|
88 |
-
outputs=[result],
|
89 |
-
)
|
90 |
-
|
91 |
-
if __name__ == "__main__":
|
92 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
model = gr.load("models/Purz/face-projection")
|
4 |
|
5 |
+
def generate_image(text, negative_prompt=None):
|
6 |
+
if not negative_prompt:
|
7 |
+
negative_prompt = "low quality, distorted, overly saturated, text artifacts, out of focus"
|
8 |
+
|
9 |
+
print(f"Generating with prompt: {text}, negative prompt: {negative_prompt}")
|
10 |
+
|
11 |
+
return model(text, negative_prompt=negative_prompt)
|
12 |
|
13 |
examples = [
|
14 |
+
["Humanoid Cat Warrior, Full View", "blurry, low quality"],
|
15 |
+
["Warhammer Sisterhood", "overexposed, low resolution"],
|
16 |
+
["Future Robots war", "too dark, cluttered background"],
|
17 |
+
["Fantasy dragon", "distorted, unbalanced composition"]
|
18 |
]
|
19 |
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=generate_image,
|
22 |
+
inputs=[
|
23 |
+
gr.Textbox(label="Type here your imagination:", placeholder="Type or click an example..."),
|
24 |
+
gr.Textbox(label="Negative Prompt (optional)", placeholder="Describe what to avoid, e.g., blurry, overly saturated...")
|
25 |
+
],
|
26 |
+
outputs=gr.Image(label="Generated Image"),
|
27 |
+
examples=examples,
|
28 |
+
theme="NoCrypt/miku",
|
29 |
+
description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
30 |
+
)
|
31 |
+
|
32 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|