Spaces:
Sleeping
Sleeping
Commit ·
a854ff8
1
Parent(s): 4c25e94
updated app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ import requests
|
|
| 15 |
import csv
|
| 16 |
import json
|
| 17 |
import threading
|
|
|
|
| 18 |
from io import BytesIO
|
| 19 |
from PIL import Image
|
| 20 |
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -190,21 +191,23 @@ def render_workspace(mode, history, specific_index=None, move_back=False):
|
|
| 190 |
except: target_idx = 0
|
| 191 |
|
| 192 |
else:
|
| 193 |
-
|
| 194 |
for i, gid in enumerate(all_groups):
|
| 195 |
if gid in s_done: continue
|
|
|
|
| 196 |
is_ready = False
|
| 197 |
-
if mode == "label" and gid not in l_done:
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
|
| 200 |
if is_ready:
|
| 201 |
-
|
| 202 |
-
target_idx = i
|
| 203 |
-
found = True
|
| 204 |
-
break
|
| 205 |
|
| 206 |
-
if not
|
| 207 |
return {screen_menu: gr.update(visible=True), screen_work: gr.update(visible=False), log_box: "No more tasks found."}
|
|
|
|
|
|
|
| 208 |
|
| 209 |
urls = get_group_urls(target_gid)
|
| 210 |
if not history or history[-1] != target_gid:
|
|
@@ -290,7 +293,7 @@ def skip_group(idx, history, mode):
|
|
| 290 |
with open(SKIP_FILE, "a", newline="") as f:
|
| 291 |
csv.writer(f).writerow([datetime.now().isoformat(), "user", gid])
|
| 292 |
sync_push_background(SKIP_FILE, "skipped.csv")
|
| 293 |
-
return render_workspace(mode, history
|
| 294 |
|
| 295 |
def refresh_cat():
|
| 296 |
all_gids = get_ordered_groups()
|
|
|
|
| 15 |
import csv
|
| 16 |
import json
|
| 17 |
import threading
|
| 18 |
+
import random
|
| 19 |
from io import BytesIO
|
| 20 |
from PIL import Image
|
| 21 |
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
| 191 |
except: target_idx = 0
|
| 192 |
|
| 193 |
else:
|
| 194 |
+
candidates = []
|
| 195 |
for i, gid in enumerate(all_groups):
|
| 196 |
if gid in s_done: continue
|
| 197 |
+
|
| 198 |
is_ready = False
|
| 199 |
+
if mode == "label" and gid not in l_done:
|
| 200 |
+
is_ready = True
|
| 201 |
+
elif mode == "verify" and gid in l_done and gid not in v_done:
|
| 202 |
+
is_ready = True
|
| 203 |
|
| 204 |
if is_ready:
|
| 205 |
+
candidates.append((i, gid))
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
+
if not candidates:
|
| 208 |
return {screen_menu: gr.update(visible=True), screen_work: gr.update(visible=False), log_box: "No more tasks found."}
|
| 209 |
+
|
| 210 |
+
target_idx, target_gid = random.choice(candidates)
|
| 211 |
|
| 212 |
urls = get_group_urls(target_gid)
|
| 213 |
if not history or history[-1] != target_gid:
|
|
|
|
| 293 |
with open(SKIP_FILE, "a", newline="") as f:
|
| 294 |
csv.writer(f).writerow([datetime.now().isoformat(), "user", gid])
|
| 295 |
sync_push_background(SKIP_FILE, "skipped.csv")
|
| 296 |
+
return render_workspace(mode, history)
|
| 297 |
|
| 298 |
def refresh_cat():
|
| 299 |
all_gids = get_ordered_groups()
|