Ashoka74 commited on
Commit
6180e6c
·
verified ·
1 Parent(s): dda05b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -86
app.py CHANGED
@@ -85,28 +85,6 @@ def infer(
85
  return images, preprocessed_image, seed
86
 
87
 
88
- # examples = [
89
- # [
90
- # "A decorative figurine of a young anime-style girl",
91
- # "assets/demo/i2mv/A_decorative_figurine_of_a_young_anime-style_girl.png",
92
- # True,
93
- # 21,
94
- # ],
95
- # [
96
- # "A juvenile emperor penguin chick",
97
- # "assets/demo/i2mv/A_juvenile_emperor_penguin_chick.png",
98
- # True,
99
- # 0,
100
- # ],
101
- # [
102
- # "A striped tabby cat with white fur sitting upright",
103
- # "assets/demo/i2mv/A_striped_tabby_cat_with_white_fur_sitting_upright.png",
104
- # True,
105
- # 0,
106
- # ],
107
- # ]
108
-
109
-
110
  with gr.Blocks() as demo:
111
  with gr.Row():
112
  gr.Markdown(
@@ -175,35 +153,9 @@ Generate 768x768 multi-view images from a single image using SDXL <br>
175
  placeholder="Enter your negative prompt",
176
  value="watermark, ugly, deformed, noisy, blurry, low contrast",
177
  )
178
-
179
- def use_orientation(selected_image:gr.SelectData):
180
- return selected_image.index
181
-
182
- def add_orientation(imgs, index):
183
- index = int(index)
184
- return imgs[index]
185
-
186
- # def get_image_by_index(imgs, index):
187
- # """
188
- # Retrieves the image from the imgs list based on the provided index.
189
- # """
190
- # try:
191
- # index = int(index)
192
- # if 0 <= index < len(imgs):
193
- # return imgs[index]
194
- # else:
195
- # return None # Or return a placeholder image
196
- # except (ValueError, TypeError):
197
- # return None # Or return a placeholder image
198
-
199
-
200
- def set_slider_index(selected_image):
201
- return selected_image.index
202
-
203
-
204
 
205
  imgs = gr.State()
206
-
207
  with gr.Column():
208
  result = gr.Gallery(
209
  label="Result",
@@ -214,46 +166,34 @@ Generate 768x768 multi-view images from a single image using SDXL <br>
214
  height="auto",
215
  allow_preview=False,
216
  )
217
-
218
 
 
 
 
 
 
 
 
 
 
219
 
220
- if result:
221
- # Slider to select image index
222
- slider = gr.Slider(
223
- minimum=0,
224
- maximum=5,
225
- step=1,
226
- label="Select Image Index",
227
- value=0, # Default value
228
- interactive=True
229
- )
230
-
231
- input_fg = gr.Image(type="numpy", label="Selected Image", height=480)
232
- # selected = gr.Number(visible=True)
233
- # result.select(use_orientation, None, selected).then()
234
- # add_button = gr.Button("Select orientation for processing")
235
- # add_button.click(add_orientation, [imgs, selected], input_fg)
236
- result.select(
237
- fn=set_slider_index,
238
- inputs=result,
239
- outputs=slider
240
- )
241
-
242
- slider.change(
243
- fn=use_orientation,
244
- inputs=[result, slider],
245
  outputs=input_fg
246
- )
247
-
248
 
249
- # with gr.Row():
250
- # gr.Examples(
251
- # examples=examples,
252
- # fn=infer,
253
- # inputs=[prompt, input_image, do_rembg, seed],
254
- # outputs=[result, preprocessed_image, seed],
255
- # cache_examples=True,
256
- # )
257
 
258
  gr.on(
259
  triggers=[run_button.click, prompt.submit],
@@ -269,7 +209,7 @@ Generate 768x768 multi-view images from a single image using SDXL <br>
269
  reference_conditioning_scale,
270
  negative_prompt,
271
  ],
272
- outputs=[result, preprocessed_image, seed],
273
  )
274
 
275
  demo.launch()
 
85
  return images, preprocessed_image, seed
86
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  with gr.Blocks() as demo:
89
  with gr.Row():
90
  gr.Markdown(
 
153
  placeholder="Enter your negative prompt",
154
  value="watermark, ugly, deformed, noisy, blurry, low contrast",
155
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
  imgs = gr.State()
158
+
159
  with gr.Column():
160
  result = gr.Gallery(
161
  label="Result",
 
166
  height="auto",
167
  allow_preview=False,
168
  )
 
169
 
170
+ # Slider to select image index
171
+ slider = gr.Slider(
172
+ minimum=0,
173
+ maximum=5,
174
+ step=1,
175
+ label="Select Image Index",
176
+ value=0, # Default value
177
+ interactive=True
178
+ )
179
 
180
+ input_fg = gr.Image(type="numpy", label="Selected Image", height=480)
181
+
182
+ def update_selected_image(selected_index:int, images):
183
+ """Selects the appropriate image"""
184
+ try:
185
+ selected_index=int(selected_index)
186
+ if 0 <= selected_index < len(images):
187
+ return images[selected_index]
188
+ except (ValueError, TypeError):
189
+ return None
190
+
191
+ slider.change(
192
+ fn=update_selected_image,
193
+ inputs=[slider, imgs],
 
 
 
 
 
 
 
 
 
 
 
194
  outputs=input_fg
195
+ )
 
196
 
 
 
 
 
 
 
 
 
197
 
198
  gr.on(
199
  triggers=[run_button.click, prompt.submit],
 
209
  reference_conditioning_scale,
210
  negative_prompt,
211
  ],
212
+ outputs=[result, preprocessed_image, seed, imgs],
213
  )
214
 
215
  demo.launch()