Spaces:
Runtime error
Runtime error
osanseviero
commited on
Commit
•
c3029dd
1
Parent(s):
578bab4
Update app.py
Browse files
app.py
CHANGED
@@ -55,7 +55,7 @@ with gr.Blocks() as demo:
|
|
55 |
# workaround we just delete the repo
|
56 |
delete_repo(repo_id="active-learning/to_label_samples", repo_type="dataset")
|
57 |
|
58 |
-
#
|
59 |
labeled_dataset = load_dataset("active-learning/labeled_samples")["train"]
|
60 |
feature = datasets.Image(decode=False)
|
61 |
for img, label in labeled_data:
|
@@ -64,16 +64,20 @@ with gr.Blocks() as demo:
|
|
64 |
"image": feature.encode_example(Image.fromarray(img)),
|
65 |
"label": label
|
66 |
})
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
else:
|
78 |
return {
|
79 |
img_to_label: gr.update(value=get_image())
|
@@ -82,6 +86,8 @@ with gr.Blocks() as demo:
|
|
82 |
def reload_data():
|
83 |
global data_to_label
|
84 |
global imgs
|
|
|
|
|
85 |
data_to_label = load_dataset("active-learning/to_label_samples")
|
86 |
imgs = data_to_label["train"]["image"]
|
87 |
if len(imgs) == 0:
|
|
|
55 |
# workaround we just delete the repo
|
56 |
delete_repo(repo_id="active-learning/to_label_samples", repo_type="dataset")
|
57 |
|
58 |
+
# Push to training dataset
|
59 |
labeled_dataset = load_dataset("active-learning/labeled_samples")["train"]
|
60 |
feature = datasets.Image(decode=False)
|
61 |
for img, label in labeled_data:
|
|
|
64 |
"image": feature.encode_example(Image.fromarray(img)),
|
65 |
"label": label
|
66 |
})
|
67 |
+
labeled_dataset.push_to_hub("active-learning/labeled_samples")
|
68 |
+
|
69 |
+
# Clean up data
|
70 |
+
labeled_data = []
|
71 |
+
idx = 0
|
72 |
+
|
73 |
+
# Update UI
|
74 |
+
return {
|
75 |
+
img_to_label: gr.update(visible=False),
|
76 |
+
label_dropdown: gr.update(visible=False),
|
77 |
+
save_btn: gr.update(visible=False),
|
78 |
+
output_box: gr.update(visible=True),
|
79 |
+
reload_btn: gr.update(visible=True)
|
80 |
+
}
|
81 |
else:
|
82 |
return {
|
83 |
img_to_label: gr.update(value=get_image())
|
|
|
86 |
def reload_data():
|
87 |
global data_to_label
|
88 |
global imgs
|
89 |
+
|
90 |
+
# See if there is new data to be labeled
|
91 |
data_to_label = load_dataset("active-learning/to_label_samples")
|
92 |
imgs = data_to_label["train"]["image"]
|
93 |
if len(imgs) == 0:
|