Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -183,6 +183,19 @@ Generate 768x768 multi-view images from a single image using SDXL <br>
|
|
183 |
index = int(index)
|
184 |
return imgs[index]
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
imgs = gr.State()
|
187 |
|
188 |
with gr.Column():
|
@@ -196,13 +209,30 @@ Generate 768x768 multi-view images from a single image using SDXL <br>
|
|
196 |
allow_preview=False,
|
197 |
)
|
198 |
|
|
|
|
|
199 |
if result:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
input_fg = gr.Image(type="numpy", label="Selected Image", height=480)
|
201 |
-
selected = gr.Number(visible=
|
202 |
-
result.select(use_orientation, None, selected)
|
203 |
-
add_button = gr.Button("Select orientation for processing")
|
204 |
-
add_button.click(add_orientation, [imgs, selected], input_fg)
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
# with gr.Row():
|
208 |
# gr.Examples(
|
|
|
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 |
imgs = gr.State()
|
200 |
|
201 |
with gr.Column():
|
|
|
209 |
allow_preview=False,
|
210 |
)
|
211 |
|
212 |
+
|
213 |
+
|
214 |
if result:
|
215 |
+
# Slider to select image index
|
216 |
+
slider = gr.Slider(
|
217 |
+
minimum=0,
|
218 |
+
maximum=5,
|
219 |
+
step=1,
|
220 |
+
label="Select Image Index",
|
221 |
+
value=0, # Default value
|
222 |
+
interactive=True
|
223 |
+
)
|
224 |
+
|
225 |
input_fg = gr.Image(type="numpy", label="Selected Image", height=480)
|
226 |
+
# selected = gr.Number(visible=True)
|
227 |
+
# result.select(use_orientation, None, selected).then()
|
228 |
+
# add_button = gr.Button("Select orientation for processing")
|
229 |
+
# add_button.click(add_orientation, [imgs, selected], input_fg)
|
230 |
+
slider.change(
|
231 |
+
fn=get_image_by_index,
|
232 |
+
inputs=[result, slider],
|
233 |
+
outputs=input_fg
|
234 |
+
)
|
235 |
+
|
236 |
|
237 |
# with gr.Row():
|
238 |
# gr.Examples(
|