Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -65,14 +65,18 @@ def Piper(_do, _dont):
|
|
65 |
height=512,
|
66 |
width=512,
|
67 |
negative_prompt=_dont,
|
68 |
-
num_inference_steps=
|
69 |
-
guidance_scale=
|
70 |
)
|
71 |
|
72 |
-
def infer(prompt1,prompt2,prompt3):
|
73 |
name = generate_random_string(12)+".png"
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
image = Piper(_do, _dont).images[0].save(name)
|
77 |
return name
|
78 |
|
@@ -99,29 +103,51 @@ with gr.Blocks(css=css) as demo:
|
|
99 |
""")
|
100 |
with gr.Column():
|
101 |
with gr.Row():
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
105 |
container=False,
|
|
|
106 |
)
|
107 |
with gr.Row():
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
111 |
container=False,
|
|
|
112 |
)
|
113 |
with gr.Row():
|
114 |
-
prompt3 = gr.
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
117 |
container=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
)
|
119 |
with gr.Row():
|
120 |
run_button = gr.Button("Run", scale=0)
|
121 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
122 |
run_button.click(
|
123 |
fn = infer,
|
124 |
-
inputs = [prompt1,prompt2,prompt3],
|
125 |
outputs = [result]
|
126 |
)
|
127 |
|
|
|
65 |
height=512,
|
66 |
width=512,
|
67 |
negative_prompt=_dont,
|
68 |
+
num_inference_steps=200,
|
69 |
+
guidance_scale=1.1
|
70 |
)
|
71 |
|
72 |
+
def infer(prompt1,prompt2,prompt3,prompt4):
|
73 |
name = generate_random_string(12)+".png"
|
74 |
+
prompt1 = " and ".join([translate(v,"english").upper() for v in prompt1])
|
75 |
+
prompt2 = " and ".join([translate(v,"english").upper() for v in prompt2])
|
76 |
+
prompt3 = " and ".join([translate(v,"english").upper() for v in prompt3])
|
77 |
+
prompt4 = " or ".join([translate(v,"english").upper() for v in prompt4])
|
78 |
+
_do = f'Show an authentic {prompt3} scene, while focusing on the details, of {prompt1}, as the main elements, and, showing {prompt2} in the background.'
|
79 |
+
_dont = f'ANY usage of {prompt4}...'
|
80 |
image = Piper(_do, _dont).images[0].save(name)
|
81 |
return name
|
82 |
|
|
|
103 |
""")
|
104 |
with gr.Column():
|
105 |
with gr.Row():
|
106 |
+
prompt1 = gr.Dropdown(
|
107 |
+
multiselect=True,
|
108 |
+
allow_custom_value=True,
|
109 |
+
max_choices=3,
|
110 |
+
label="Foreground Elements",
|
111 |
+
show_label=True,
|
112 |
container=False,
|
113 |
+
value="any"
|
114 |
)
|
115 |
with gr.Row():
|
116 |
+
prompt2 = gr.Dropdown(
|
117 |
+
multiselect=True,
|
118 |
+
allow_custom_value=True,
|
119 |
+
max_choices=4,
|
120 |
+
label="Background Elements",
|
121 |
+
show_label=True,
|
122 |
container=False,
|
123 |
+
value="any"
|
124 |
)
|
125 |
with gr.Row():
|
126 |
+
prompt3 = gr.Dropdown(
|
127 |
+
multiselect=True,
|
128 |
+
allow_custom_value=True,
|
129 |
+
max_choices=2,
|
130 |
+
label="Background Events",
|
131 |
+
show_label=True,
|
132 |
container=False,
|
133 |
+
value="any"
|
134 |
+
)
|
135 |
+
with gr.Row():
|
136 |
+
prompt4 = gr.Dropdown(
|
137 |
+
multiselect=True,
|
138 |
+
allow_custom_value=True,
|
139 |
+
max_choices=6,
|
140 |
+
label="Forbidden Elements/Events",
|
141 |
+
show_label=True,
|
142 |
+
container=False,
|
143 |
+
value="None"
|
144 |
)
|
145 |
with gr.Row():
|
146 |
run_button = gr.Button("Run", scale=0)
|
147 |
result = gr.Image(elem_id="image-container", label="Result", show_label=False, type='filepath')
|
148 |
run_button.click(
|
149 |
fn = infer,
|
150 |
+
inputs = [prompt1,prompt2,prompt3,prompt4],
|
151 |
outputs = [result]
|
152 |
)
|
153 |
|