Spaces:
Sleeping
Sleeping
Fix labeling_ui and save_labeled_data functions
Browse files# Key Changes:
## labeling_ui():
Removed the lines that were trying to use .update() on the components.
Created a new function initialize_labeling_ui() to set the initial values of the components. This function returns the initial image, metadata, and label count.
We call initialize_labeling_ui() and set the values of the components directly using image_component.value, metadata_text.value, and label_count_text.value.
## save_labeled_data():
The function now returns the new image, metadata, and count values. Gradio will automatically update the image_component, metadata_text, and label_count_text components with these returned values.
app.py
CHANGED
@@ -92,11 +92,17 @@ def labeling_ui():
|
|
92 |
)
|
93 |
|
94 |
# Initialize with the first sample
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
# --- Display UI ---
|
102 |
def display_ui():
|
|
|
92 |
)
|
93 |
|
94 |
# Initialize with the first sample
|
95 |
+
def initialize_labeling_ui():
|
96 |
+
image, metadata, count = get_next_sample()
|
97 |
+
if image is not None:
|
98 |
+
return image, str(metadata["bounds"]), f"Labeled {count} samples."
|
99 |
+
else:
|
100 |
+
return None, "", "No samples loaded."
|
101 |
+
|
102 |
+
initial_image, initial_metadata, initial_count = initialize_labeling_ui()
|
103 |
+
image_component.value = initial_image
|
104 |
+
metadata_text.value = initial_metadata
|
105 |
+
label_count_text.value = initial_count
|
106 |
|
107 |
# --- Display UI ---
|
108 |
def display_ui():
|