Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ def compress_image(image, quality=50):
|
|
91 |
compressed_image = Image.open(buffer)
|
92 |
return compressed_image
|
93 |
|
94 |
-
def query(prompt, is_realistic):
|
95 |
if prompt == "" or prompt == None:
|
96 |
return None
|
97 |
|
@@ -102,7 +102,8 @@ def query(prompt, is_realistic):
|
|
102 |
|
103 |
payload = {
|
104 |
"inputs": prompt,
|
105 |
-
"seed": random.randint(1, 1000000000)
|
|
|
106 |
}
|
107 |
|
108 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
@@ -166,12 +167,13 @@ with gr.Blocks(theme='gstaff/xkcd', css=css) as app:
|
|
166 |
with gr.Column(elem_id="prompt-container"):
|
167 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input", value=test_prompt)
|
168 |
is_realistic = gr.Checkbox(label="Realistic filter", value=True)
|
|
|
169 |
|
170 |
with gr.Row():
|
171 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
172 |
with gr.Row():
|
173 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
174 |
|
175 |
-
text_button.click(query, inputs=[text_prompt, is_realistic], outputs=image_output)
|
176 |
|
177 |
app.launch(show_api=True, share=True)
|
|
|
91 |
compressed_image = Image.open(buffer)
|
92 |
return compressed_image
|
93 |
|
94 |
+
def query(prompt, is_realistic, num_inference_steps):
|
95 |
if prompt == "" or prompt == None:
|
96 |
return None
|
97 |
|
|
|
102 |
|
103 |
payload = {
|
104 |
"inputs": prompt,
|
105 |
+
"seed": random.randint(1, 1000000000),
|
106 |
+
"parameters": {"num_inference_steps": num_inference_steps}
|
107 |
}
|
108 |
|
109 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
|
|
167 |
with gr.Column(elem_id="prompt-container"):
|
168 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input", value=test_prompt)
|
169 |
is_realistic = gr.Checkbox(label="Realistic filter", value=True)
|
170 |
+
num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=50, step=1, value=4)
|
171 |
|
172 |
with gr.Row():
|
173 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
174 |
with gr.Row():
|
175 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
176 |
|
177 |
+
text_button.click(query, inputs=[text_prompt, is_realistic, num_inference_steps], outputs=image_output)
|
178 |
|
179 |
app.launch(show_api=True, share=True)
|