ysharma HF staff commited on
Commit
6cb6b76
1 Parent(s): a205be7
Files changed (1) hide show
  1. app.py +86 -47
app.py CHANGED
@@ -115,60 +115,99 @@ def get_image(height, width, seed, prompt, cfg, timesteps, stage_a_tiled):
115
  #print('finished! Results ')
116
 
117
 
 
 
 
 
 
118
  with gr.Blocks() as demo:
119
- with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  with gr.Row():
121
- with gr.Column():
122
- height = gr.Slider(value=2304, step=32, minimum=1536, maximum=4096, label='Height')
123
- width = gr.Slider(value=4096, step=32, minimum=1536, maximum=5120, label='Width')
124
- seed = gr.Number(value=123, step=1, label='Random Seed')
125
- prompt = gr.Textbox(value='', max_lines=4, label='Text Prompt')
126
- cfg = gr.Slider(value=4, step=0.1, minimum=3, maximum=10, label='CFG')
127
- timesteps = gr.Slider(value=20, step=1, minimum=10, maximum=50, label='Timesteps')
128
- stage_a_tiled = gr.Checkbox(value=False, label='Stage_a_tiled')
129
- with gr.Row():
130
- clear_button = gr.Button("Clear!")
131
- polish_button = gr.Button("Submit!")
132
- with gr.Column():
133
- output_img = gr.Image(label='Output Image', sources=None)
134
- with gr.Column():
135
- prompt2 = gr.Textbox(
136
- value='''
137
- A detailed view of a blooming magnolia tree, with large, white flowers and dark green leaves, set against a
138
- clear blue sky.
139
-
140
- A close-up portrait of a young woman with flawless skin, vibrant red lipstick, and wavy brown hair, wearing
141
- a vintage floral dress and standing in front of a blooming garden.
142
-
143
- The image features a snow-covered mountain range with a large, snow-covered mountain in the background.
144
- The mountain is surrounded by a forest of trees, and the sky is filled with clouds. The scene is set during the
145
- winter season, with snow covering the ground and the trees.
146
-
147
- Crocodile in a sweater.
148
-
149
- A vibrant anime scene of a young girl with long, flowing pink hair, big sparkling blue eyes, and a school
150
- uniform, standing under a cherry blossom tree with petals falling around her. The background shows a
151
- traditional Japanese school with cherry blossoms in full bloom.
152
 
153
- A playful Labrador retriever puppy with a shiny, golden coat, chasing a red ball in a spacious backyard, with
154
- green grass and a wooden fence.
155
-
156
- A cozy, rustic log cabin nestled in a snow-covered forest, with smoke rising from the stone chimney, warm
157
- lights glowing from the windows, and a path of footprints leading to the front door.
158
-
159
- A highly detailed, high-quality image of the Banff National Park in Canada. The turquoise waters of Lake
160
- Louise are surrounded by snow-capped mountains and dense pine forests. A wooden canoe is docked at the
161
- edge of the lake. The sky is a clear, bright blue, and the air is crisp and fresh.
 
 
 
 
 
 
 
162
 
163
- A highly detailed, high-quality image of a Shih Tzu receiving a bath in a home bathroom. The dog is standing
164
- in a tub, covered in suds, with a slightly wet and adorable look. The background includes bathroom fixtures,
165
- towels, and a clean, tiled floor.
166
- ''', label='Text prompt examples'
167
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  polish_button.click(get_image, inputs=[height, width, seed, prompt, cfg, timesteps, stage_a_tiled], outputs=output_img)
170
  polish_button.click(clear_image, inputs=[], outputs=output_img)
171
-
 
172
  if __name__ == "__main__":
173
 
174
  args = parse_args()
 
115
  #print('finished! Results ')
116
 
117
 
118
+ def process_examples(prompt):
119
+ # Get inference from the function
120
+ output_img = get_image(height=2304, width=4096, seed=123, prompt=prompt, cfg=4, timesteps=20, stage_a_tiled=False)
121
+ return output_img
122
+
123
  with gr.Blocks() as demo:
124
+ with gr.Column(elem_id="col-container"):
125
+ gr.Markdown("<h1><center>UltraPixel: Advancing Ultra-High-Resolution Image Synthesis to New Peaks </center></h1>")
126
+
127
+ with gr.Row():
128
+ prompt = gr.Textbox(
129
+ label="Text Prompt",
130
+ show_label=False,
131
+ max_lines=1,
132
+ placeholder="Enter your prompt",
133
+ container=False
134
+ )
135
+ polish_button = gr.Button("Submit!", scale=0)
136
+
137
+ output_img = gr.Image(label="Output Image", show_label=False)
138
+
139
+ with gr.Accordion("Advanced Settings", open=False):
140
+ seed = gr.Number(
141
+ label="Random Seed",
142
+ value=123,
143
+ step=1,
144
+ minimum=0,
145
+ #maximum=MAX_SEED
146
+ )
147
+
148
+ #randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
149
+
150
  with gr.Row():
151
+ width = gr.Slider(
152
+ label="Width",
153
+ minimum=1536,
154
+ maximum=5120,
155
+ step=32,
156
+ value=4096
157
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
+ height = gr.Slider(
160
+ label="Height",
161
+ minimum=1536,
162
+ maximum=4096,
163
+ step=32,
164
+ value=2304
165
+ )
166
+
167
+ with gr.Row():
168
+ cfg = gr.Slider(
169
+ label="CFG",
170
+ minimum=3,
171
+ maximum=10,
172
+ step=0.1,
173
+ value=4
174
+ )
175
 
176
+ timesteps = gr.Slider(
177
+ label="Timesteps",
178
+ minimum=10,
179
+ maximum=50,
180
+ step=1,
181
+ value=20
182
+ )
183
+
184
+ stage_a_tiled = gr.Checkbox(label="Stage_a_tiled", value=False)
185
+
186
+ clear_button = gr.Button("Clear!")
187
+
188
+ gr.Examples(
189
+ examples=[
190
+ "A detailed view of a blooming magnolia tree, with large, white flowers and dark green leaves, set against a clear blue sky.",
191
+ "A close-up portrait of a young woman with flawless skin, vibrant red lipstick, and wavy brown hair, wearing a vintage floral dress and standing in front of a blooming garden.",
192
+ "The image features a snow-covered mountain range with a large, snow-covered mountain in the background. The mountain is surrounded by a forest of trees, and the sky is filled with clouds. The scene is set during the winter season, with snow covering the ground and the trees.",
193
+ "Crocodile in a sweater.",
194
+ "A vibrant anime scene of a young girl with long, flowing pink hair, big sparkling blue eyes, and a school uniform, standing under a cherry blossom tree with petals falling around her. The background shows a traditional Japanese school with cherry blossoms in full bloom.",
195
+ "A playful Labrador retriever puppy with a shiny, golden coat, chasing a red ball in a spacious backyard, with green grass and a wooden fence.",
196
+ "A cozy, rustic log cabin nestled in a snow-covered forest, with smoke rising from the stone chimney, warm lights glowing from the windows, and a path of footprints leading to the front door.",
197
+ "A highly detailed, high-quality image of the Banff National Park in Canada. The turquoise waters of Lake Louise are surrounded by snow-capped mountains and dense pine forests. A wooden canoe is docked at the edge of the lake. The sky is a clear, bright blue, and the air is crisp and fresh.",
198
+ "A highly detailed, high-quality image of a Shih Tzu receiving a bath in a home bathroom. The dog is standing in a tub, covered in suds, with a slightly wet and adorable look. The background includes bathroom fixtures, towels, and a clean, tiled floor.",
199
+ ],
200
+ inputs=[prompt],
201
+ outputs=[output_img],
202
+ fn=process_examples,
203
+ cache_examples=True,
204
+ examples_per_page=5
205
+ )
206
 
207
  polish_button.click(get_image, inputs=[height, width, seed, prompt, cfg, timesteps, stage_a_tiled], outputs=output_img)
208
  polish_button.click(clear_image, inputs=[], outputs=output_img)
209
+
210
+
211
  if __name__ == "__main__":
212
 
213
  args = parse_args()