Spaces:
Sleeping
Sleeping
Update app.py
Browse filesFix display error that prevented startup
===== Application Startup at 2024-12-23 17:29:12 =====
Traceback (most recent call last):
File "/home/user/app/app.py", line 143, in <module>
display_ui()
File "/home/user/app/app.py", line 122, in display_ui
cool_images_gallery.style(grid=DISPLAY_N_COOL)
AttributeError: 'Gallery' object has no attribute 'style'. Did you mean: 'scale'?
app.py
CHANGED
@@ -85,12 +85,12 @@ def labeling_ui():
|
|
85 |
|
86 |
# --- Display UI ---
|
87 |
def display_ui():
|
88 |
-
|
89 |
def get_random_cool_images(n):
|
90 |
cool_samples = [d for d in labeled_data if d["label"] == "cool"]
|
91 |
if len(cool_samples) < n:
|
92 |
return [Image.frombytes("RGB", (384,384), s["image"]) for s in cool_samples]
|
93 |
-
|
94 |
selected_cool = random.sample(cool_samples, n)
|
95 |
return [Image.frombytes("RGB", (384,384), s["image"]) for s in selected_cool]
|
96 |
|
@@ -109,7 +109,7 @@ def display_ui():
|
|
109 |
new_image, new_metadata = get_new_unlabeled_image()
|
110 |
if new_image is None:
|
111 |
return "No more samples", gr.Image.update(value=None), gr.Gallery.update(value=[])
|
112 |
-
|
113 |
cool_images = get_random_cool_images(DISPLAY_N_COOL)
|
114 |
return "", new_image, cool_images
|
115 |
|
@@ -118,8 +118,11 @@ def display_ui():
|
|
118 |
metadata_display = gr.Textbox(label="Metadata (Bounds)")
|
119 |
|
120 |
with gr.Row():
|
121 |
-
cool_images_gallery = gr.Gallery(
|
122 |
-
|
|
|
|
|
|
|
123 |
|
124 |
with gr.Row():
|
125 |
refresh_button = gr.Button("Refresh")
|
|
|
85 |
|
86 |
# --- Display UI ---
|
87 |
def display_ui():
|
88 |
+
|
89 |
def get_random_cool_images(n):
|
90 |
cool_samples = [d for d in labeled_data if d["label"] == "cool"]
|
91 |
if len(cool_samples) < n:
|
92 |
return [Image.frombytes("RGB", (384,384), s["image"]) for s in cool_samples]
|
93 |
+
|
94 |
selected_cool = random.sample(cool_samples, n)
|
95 |
return [Image.frombytes("RGB", (384,384), s["image"]) for s in selected_cool]
|
96 |
|
|
|
109 |
new_image, new_metadata = get_new_unlabeled_image()
|
110 |
if new_image is None:
|
111 |
return "No more samples", gr.Image.update(value=None), gr.Gallery.update(value=[])
|
112 |
+
|
113 |
cool_images = get_random_cool_images(DISPLAY_N_COOL)
|
114 |
return "", new_image, cool_images
|
115 |
|
|
|
118 |
metadata_display = gr.Textbox(label="Metadata (Bounds)")
|
119 |
|
120 |
with gr.Row():
|
121 |
+
cool_images_gallery = gr.Gallery(
|
122 |
+
label="Cool Examples",
|
123 |
+
value=[],
|
124 |
+
columns=DISPLAY_N_COOL # Set grid layout here
|
125 |
+
)
|
126 |
|
127 |
with gr.Row():
|
128 |
refresh_button = gr.Button("Refresh")
|