zenafey commited on
Commit
88e3f0d
1 Parent(s): c4cfa7e

replace width\height sliders with dropdown

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -88,15 +88,17 @@ def image_to_base64(image_path):
88
 
89
  prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
90
 
91
- def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
 
 
92
 
93
  config_without_model_and_sampler = {
94
  "prompt": prompt,
95
  "negative_prompt": negative_prompt,
96
  "steps": steps,
97
  "cfg_scale": cfg_scale,
98
- "width": width,
99
- "height": height,
100
  "seed": seed
101
  }
102
 
@@ -119,6 +121,17 @@ css = """
119
  }
120
  """
121
 
 
 
 
 
 
 
 
 
 
 
 
122
  with gr.Blocks(css=css) as demo:
123
 
124
 
@@ -149,9 +162,7 @@ with gr.Blocks(css=css) as demo:
149
 
150
  with gr.Row():
151
  with gr.Column(scale=1):
152
- width = gr.Slider(label="Width", minimum=512, maximum=1536, value=1024, step=8)
153
- height = gr.Slider(label="Height", minimum=512, maximum=1536, value=1024, step=8)
154
- gr.Markdown(elem_id="resolution", value="*Resolution Maximum: 1MP (1048576 px)*")
155
 
156
  with gr.Column(scale=1):
157
  batch_size = gr.Slider(label="Batch Size", maximum=1, value=1)
@@ -164,6 +175,6 @@ with gr.Blocks(css=css) as demo:
164
  with gr.Column(scale=2):
165
  image_output = gr.Image(value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png")
166
 
167
- text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
168
 
169
  demo.queue(default_concurrency_limit=10, max_size=32, api_open=False).launch(max_threads=128)
 
88
 
89
  prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
90
 
91
+ def flip_text(prompt, negative_prompt, model, steps, sampler, cfg_scale, resolution, seed):
92
+
93
+ width, height = resolution.split("x")
94
 
95
  config_without_model_and_sampler = {
96
  "prompt": prompt,
97
  "negative_prompt": negative_prompt,
98
  "steps": steps,
99
  "cfg_scale": cfg_scale,
100
+ "width": int(width),
101
+ "height": int(height),
102
  "seed": seed
103
  }
104
 
 
121
  }
122
  """
123
 
124
+ list_resolutions = [
125
+ "1024x1024",
126
+ "1152x896",
127
+ "1216x832",
128
+ "1344x768",
129
+ "1536x640",
130
+ "640x1536",
131
+ "768x1344",
132
+ "832x1216"
133
+ ]
134
+
135
  with gr.Blocks(css=css) as demo:
136
 
137
 
 
162
 
163
  with gr.Row():
164
  with gr.Column(scale=1):
165
+ resolution = gr.Dropdown(value="1024x1024", show_label=True, label="Resolution", choices=list_resolutions)
 
 
166
 
167
  with gr.Column(scale=1):
168
  batch_size = gr.Slider(label="Batch Size", maximum=1, value=1)
 
175
  with gr.Column(scale=2):
176
  image_output = gr.Image(value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png")
177
 
178
+ text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, resolution, seed], outputs=image_output)
179
 
180
  demo.queue(default_concurrency_limit=10, max_size=32, api_open=False).launch(max_threads=128)