Spaces:
Sleeping
Sleeping
Fix display_ui function
Browse files# Key Changes:
## Removed .update(): The line new_image_component.update(value=image) has been removed.
## Initialize Component Values:
Created a new function initialize_display_ui() to set the initial values of the components. This function returns the initial image, and gallery arrays.
We call initialize_display_ui() and set the values of the components directly using new_image_component.value = initial_image and cool_images_gallery.value = initial_gallery.
With this correction, your display_ui() function should work as intended. The error AttributeError: 'Image' object has no attribute 'update' should be resolved.
app.py
CHANGED
@@ -151,9 +151,13 @@ def display_ui():
|
|
151 |
refresh_button.click(fn=refresh_display, inputs=[], outputs=[gr.Textbox(label="Debug"), new_image_component, cool_images_gallery])
|
152 |
|
153 |
# Initialize
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
157 |
|
158 |
# --- Main Interface ---
|
159 |
with gr.Blocks() as demo:
|
|
|
151 |
refresh_button.click(fn=refresh_display, inputs=[], outputs=[gr.Textbox(label="Debug"), new_image_component, cool_images_gallery])
|
152 |
|
153 |
# Initialize
|
154 |
+
def initialize_display_ui():
|
155 |
+
debug, image, gallery = refresh_display()
|
156 |
+
return debug, image, gallery
|
157 |
+
|
158 |
+
debug, initial_image, initial_gallery = initialize_display_ui()
|
159 |
+
new_image_component.value = initial_image
|
160 |
+
cool_images_gallery.value = initial_gallery
|
161 |
|
162 |
# --- Main Interface ---
|
163 |
with gr.Blocks() as demo:
|