ananyakarn commited on
Commit
2b7f57b
·
verified ·
1 Parent(s): 54c61cb

fix added

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -14,31 +14,38 @@ from sklearn.metrics import accuracy_score, f1_score
14
  from sklearn.model_selection import train_test_split
15
 
16
  # =========================
17
- # 1. DOWNLOAD DATASET
18
  # =========================
19
  url = "https://huggingface.co/datasets/ananyakarn/DAIC_WOZ_Data/resolve/main/DAIC_WOZ_Data.zip"
20
  zip_path = "data.zip"
21
- extract_path = "DAIC_WOZ"
22
 
 
 
 
 
 
23
 
24
- # 🔥 FIX: handle nested folder
25
- while len(os.listdir(extract_path)) == 1:
26
- extract_path = os.path.join(extract_path, os.listdir(extract_path)[0])
27
 
28
- print("Final dataset path:", extract_path)
 
 
 
 
 
 
 
 
29
 
30
- print("Folders detected:", os.listdir(extract_path)[:10])
31
 
32
- if not os.path.exists(extract_path):
33
- print("Downloading dataset...")
34
- r = requests.get(url, stream=True)
35
- with open(zip_path, "wb") as f:
36
- for chunk in r.iter_content(8192):
37
- f.write(chunk)
38
 
39
- print("Extracting dataset...")
40
- with zipfile.ZipFile(zip_path, "r") as zip_ref:
41
- zip_ref.extractall(extract_path)
42
 
43
  # =========================
44
  # 2. LOAD LIGHTWEIGHT BERT
 
14
  from sklearn.model_selection import train_test_split
15
 
16
  # =========================
17
+ # 1. DOWNLOAD & EXTRACT DATASET
18
  # =========================
19
  url = "https://huggingface.co/datasets/ananyakarn/DAIC_WOZ_Data/resolve/main/DAIC_WOZ_Data.zip"
20
  zip_path = "data.zip"
 
21
 
22
+ print("Downloading dataset...")
23
+ r = requests.get(url, stream=True)
24
+ with open(zip_path, "wb") as f:
25
+ for chunk in r.iter_content(8192):
26
+ f.write(chunk)
27
 
28
+ print("Extracting dataset...")
29
+ with zipfile.ZipFile(zip_path, "r") as zip_ref:
30
+ zip_ref.extractall(".")
31
 
32
+ # =========================
33
+ # 2. AUTO-DETECT DATASET FOLDER
34
+ # =========================
35
+ def find_dataset_root():
36
+ for root, dirs, files in os.walk("."):
37
+ for d in dirs:
38
+ if "_P" in d or "_C" in d:
39
+ return root
40
+ return None
41
 
42
+ extract_path = find_dataset_root()
43
 
44
+ if extract_path is None:
45
+ raise Exception("Dataset folders not found!")
 
 
 
 
46
 
47
+ print("Final dataset path:", extract_path)
48
+ print("Sample folders:", os.listdir(extract_path)[:10])
 
49
 
50
  # =========================
51
  # 2. LOAD LIGHTWEIGHT BERT