taesiri commited on
Commit
c9d6732
1 Parent(s): a32b587
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -18,7 +18,7 @@ from huggingface_hub import (
18
  InferenceClient,
19
  login,
20
  snapshot_download,
21
- hf_hub_download
22
  )
23
  from PIL import Image
24
  from utils import string_to_image
@@ -37,20 +37,18 @@ np.random.seed(int(time.time()))
37
  session_token = os.environ.get("SessionToken")
38
  login(token=session_token, add_to_git_credential=True)
39
 
40
- # Using snapshot_download to handle the download and extraction
41
- # snapshot_download(
42
- # repo_id='XAI/PEEB-Data',
43
- # repo_type='dataset',
44
- # local_dir='./',
45
- # cache_dir='./hf_cache'
46
- # )
47
- zip_file_path = hf_hub_download(repo_id='XAI/PEEB-Data', repo_type='dataset', cache_dir='./hf_cache', filename="data.zip")
48
 
 
49
 
50
- with zipfile.ZipFile('./data.zip', 'r') as zip_ref:
51
  zip_ref.extractall("./")
52
 
53
-
54
  NUMBER_OF_IMAGES = 30
55
  intro_screen = Image.open("./images/intro.jpg")
56
 
@@ -70,7 +68,6 @@ for k in all_data["topK"].keys():
70
  all_data["topK"][k]["type"] = "topK"
71
 
72
 
73
-
74
  REPO_URL = "taesiri/AdvisingNetworksReviewDataExtension"
75
  JSON_DATASET_DIR = Path("responses")
76
 
@@ -239,7 +236,7 @@ def update_app(decision, data, current_index, history, username):
239
  # TODO, Call the accuracy and show it to the user
240
  # calcualte the mean of is_user_correct
241
  all_is_user_correct = [d["is_user_correct"] for d in history]
242
- accuracy = np.mean(all_is_user_correct) * 100
243
  accuracy = round(accuracy, 2)
244
 
245
  return (
 
18
  InferenceClient,
19
  login,
20
  snapshot_download,
21
+ hf_hub_download,
22
  )
23
  from PIL import Image
24
  from utils import string_to_image
 
37
  session_token = os.environ.get("SessionToken")
38
  login(token=session_token, add_to_git_credential=True)
39
 
40
+ zip_file_path = hf_hub_download(
41
+ repo_id="XAI/PEEB-Data",
42
+ repo_type="dataset",
43
+ cache_dir="./hf_cache",
44
+ filename="data.zip",
45
+ )
 
 
46
 
47
+ print(f"zip_file_path: {zip_file_path}")
48
 
49
+ with zipfile.ZipFile("./data.zip", "r") as zip_ref:
50
  zip_ref.extractall("./")
51
 
 
52
  NUMBER_OF_IMAGES = 30
53
  intro_screen = Image.open("./images/intro.jpg")
54
 
 
68
  all_data["topK"][k]["type"] = "topK"
69
 
70
 
 
71
  REPO_URL = "taesiri/AdvisingNetworksReviewDataExtension"
72
  JSON_DATASET_DIR = Path("responses")
73
 
 
236
  # TODO, Call the accuracy and show it to the user
237
  # calcualte the mean of is_user_correct
238
  all_is_user_correct = [d["is_user_correct"] for d in history]
239
+ accuracy = np.mean(all_is_user_correct) * 100
240
  accuracy = round(accuracy, 2)
241
 
242
  return (