Nightfury16 commited on
Commit
5838c7c
·
1 Parent(s): 8c333c0

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -16,7 +16,8 @@ from huggingface_hub import HfApi, hf_hub_download
16
  DATASET_REPO_ID = os.environ.get("DATASET_REPO_ID", "fast-stager/property-labels")
17
  HF_TOKEN = os.environ.get("HF_TOKEN")
18
 
19
- CACHE_DIR = "/tmp"
 
20
  URL_FILE = "new_urls.json"
21
  LABEL_FILE = os.path.join(CACHE_DIR, "annotations.csv")
22
  VERIFY_FILE = os.path.join(CACHE_DIR, "verifications.csv")
@@ -34,8 +35,7 @@ def sync_pull():
34
  filename=filename,
35
  repo_type="dataset",
36
  local_dir=CACHE_DIR,
37
- token=token,
38
- local_dir_use_symlinks=False
39
  )
40
  print(f"✅ Loaded {filename}")
41
  except Exception as e:
@@ -102,17 +102,15 @@ def load_all_urls():
102
  data = json.load(f)
103
  if "groups" in data:
104
  for group in data["groups"]:
105
- if "images" in group:
106
- urls.extend(group["images"])
107
  elif isinstance(data, dict):
108
- for query_key, rows in data.items():
109
  if isinstance(rows, list):
110
  for row in rows:
111
  if "unstaged_images" in row:
112
  urls.append(row["unstaged_images"])
113
  except Exception as e:
114
  print(f"Error loading URLs: {e}")
115
-
116
  return urls
117
 
118
  def get_ordered_groups():
 
16
  DATASET_REPO_ID = os.environ.get("DATASET_REPO_ID", "fast-stager/property-labels")
17
  HF_TOKEN = os.environ.get("HF_TOKEN")
18
 
19
+ CACHE_DIR = os.path.join(os.getcwd(), "data")
20
+ os.makedirs(CACHE_DIR, exist_ok=True)
21
  URL_FILE = "new_urls.json"
22
  LABEL_FILE = os.path.join(CACHE_DIR, "annotations.csv")
23
  VERIFY_FILE = os.path.join(CACHE_DIR, "verifications.csv")
 
35
  filename=filename,
36
  repo_type="dataset",
37
  local_dir=CACHE_DIR,
38
+ token=token
 
39
  )
40
  print(f"✅ Loaded {filename}")
41
  except Exception as e:
 
102
  data = json.load(f)
103
  if "groups" in data:
104
  for group in data["groups"]:
105
+ urls.extend(group.get("images", []))
 
106
  elif isinstance(data, dict):
107
+ for rows in data.values():
108
  if isinstance(rows, list):
109
  for row in rows:
110
  if "unstaged_images" in row:
111
  urls.append(row["unstaged_images"])
112
  except Exception as e:
113
  print(f"Error loading URLs: {e}")
 
114
  return urls
115
 
116
  def get_ordered_groups():