EmoCube commited on
Commit
4a188f9
·
verified ·
1 Parent(s): 73f5bda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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, num_inference_steps, negative):
95
  if prompt == "" or prompt == None:
96
  return None
97
 
@@ -103,7 +103,7 @@ def query(prompt, is_realistic, num_inference_steps, negative):
103
  payload = {
104
  "inputs": prompt,
105
  "seed": random.randint(1, 1000000000),
106
- "parameters": {"num_inference_steps": num_inference_steps, "width": 480, "height": 640, "negative_prompt": negative}
107
  }
108
 
109
  response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
@@ -169,12 +169,15 @@ with gr.Blocks(theme='gstaff/xkcd', css=css) as app:
169
  negative_prompt = gr.Textbox(label="Negative prompt", placeholder="Enter a negative prompt here", lines=2, elem_id="prompt-negative-input", value="")
170
  is_realistic = gr.Checkbox(label="Realistic filter", value=True)
171
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=50, step=1, value=4)
 
 
 
172
 
173
  with gr.Row():
174
  text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
175
  with gr.Row():
176
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
177
 
178
- text_button.click(query, inputs=[text_prompt, is_realistic, num_inference_steps, negative_prompt], outputs=image_output)
179
 
180
  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, width, height):
95
  if prompt == "" or prompt == None:
96
  return None
97
 
 
103
  payload = {
104
  "inputs": prompt,
105
  "seed": random.randint(1, 1000000000),
106
+ "parameters": {"num_inference_steps": num_inference_steps, "width": width, "height": height}
107
  }
108
 
109
  response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
 
169
  negative_prompt = gr.Textbox(label="Negative prompt", placeholder="Enter a negative prompt here", lines=2, elem_id="prompt-negative-input", value="")
170
  is_realistic = gr.Checkbox(label="Realistic filter", value=True)
171
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=50, step=1, value=4)
172
+ with gr.Row():
173
+ width = gr.Slider(label="Width", minimum = 128, maximum = 1024, step = 32, value = 480)
174
+ height = gr.Slider(label="Height", minimum = 128, maximum = 1024, step = 32, value = 640)
175
 
176
  with gr.Row():
177
  text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
178
  with gr.Row():
179
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
180
 
181
+ text_button.click(query, inputs=[text_prompt, is_realistic, num_inference_steps, width, height], outputs=image_output)
182
 
183
  app.launch(show_api=True, share=True)