Spaces:
Sleeping
Sleeping
Commit
·
74eb4ce
1
Parent(s):
bb82241
Update app.py
Browse files
app.py
CHANGED
@@ -133,13 +133,14 @@ def resize_crop(image, size=512):
|
|
133 |
# gr.Warning("NSFW content detected.")
|
134 |
# return Image.new("RGB", (512, 512))
|
135 |
# return results.images[0]
|
136 |
-
async def predict(prompt, strength, steps, seed=1231231):
|
137 |
generator = torch.manual_seed(seed)
|
138 |
last_time = time.time()
|
139 |
t2i_pipe.safety_checker = None
|
140 |
t2i_pipe.requires_safety_checker = False
|
141 |
results = t2i_pipe(
|
142 |
prompt=prompt,
|
|
|
143 |
generator=generator,
|
144 |
num_inference_steps=steps,
|
145 |
guidance_scale=0.0,
|
@@ -185,13 +186,19 @@ with gr.Blocks(css=css) as demo:
|
|
185 |
scale=5,
|
186 |
container=False,
|
187 |
)
|
188 |
-
neg_prompt = gr.Textbox(
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
)
|
193 |
generate_bt = gr.Button("Generate", scale=1)
|
194 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
# with gr.Column():
|
196 |
# image_input = gr.Image(
|
197 |
# sources=["upload", "webcam", "clipboard"],
|
@@ -240,10 +247,11 @@ with gr.Blocks(css=css) as demo:
|
|
240 |
# ```
|
241 |
# """
|
242 |
# )
|
243 |
-
inputs = [prompt, strength, steps, seed]
|
244 |
# inputs = [image_input, prompt, strength, steps, seed]
|
245 |
generate_bt.click(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
246 |
prompt.input(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
|
|
247 |
steps.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
248 |
seed.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
249 |
strength.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
|
|
133 |
# gr.Warning("NSFW content detected.")
|
134 |
# return Image.new("RGB", (512, 512))
|
135 |
# return results.images[0]
|
136 |
+
async def predict(prompt, neg_prompt, strength, steps, seed=1231231):
|
137 |
generator = torch.manual_seed(seed)
|
138 |
last_time = time.time()
|
139 |
t2i_pipe.safety_checker = None
|
140 |
t2i_pipe.requires_safety_checker = False
|
141 |
results = t2i_pipe(
|
142 |
prompt=prompt,
|
143 |
+
negative_prompt = neg_prompt,
|
144 |
generator=generator,
|
145 |
num_inference_steps=steps,
|
146 |
guidance_scale=0.0,
|
|
|
186 |
scale=5,
|
187 |
container=False,
|
188 |
)
|
189 |
+
# neg_prompt = gr.Textbox(
|
190 |
+
# placeholder="Insert your negative prompt here:",
|
191 |
+
# scale=5,
|
192 |
+
# container=False,
|
193 |
+
# )
|
194 |
generate_bt = gr.Button("Generate", scale=1)
|
195 |
with gr.Row():
|
196 |
+
with gr.Column():
|
197 |
+
neg_prompt = gr.Textbox(
|
198 |
+
placeholder="Insert your negative prompt here:",
|
199 |
+
scale=5,
|
200 |
+
container=False,
|
201 |
+
)
|
202 |
# with gr.Column():
|
203 |
# image_input = gr.Image(
|
204 |
# sources=["upload", "webcam", "clipboard"],
|
|
|
247 |
# ```
|
248 |
# """
|
249 |
# )
|
250 |
+
inputs = [prompt, neg_prompt, strength, steps, seed]
|
251 |
# inputs = [image_input, prompt, strength, steps, seed]
|
252 |
generate_bt.click(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
253 |
prompt.input(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
254 |
+
neg_prompt.input(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
255 |
steps.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
256 |
seed.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|
257 |
strength.change(fn=predict, inputs=inputs, outputs=image, show_progress=False)
|