Spaces:
Sleeping
Sleeping
quantumiracle-git
commited on
Commit
·
bdc0224
1
Parent(s):
75ae4f9
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,9 @@ import base64
|
|
8 |
from time import gmtime, strftime
|
9 |
from csv import writer
|
10 |
import json
|
11 |
-
|
|
|
|
|
12 |
from datasets import load_dataset
|
13 |
from hfserver import HuggingFaceDatasetSaver, HuggingFaceDatasetJSONSaver
|
14 |
|
@@ -21,7 +23,8 @@ ENVS = ['ShadowHand', 'ShadowHandCatchAbreast', 'ShadowHandOver', 'ShadowHandBlo
|
|
21 |
# download data from huggingface dataset
|
22 |
# dataset = load_dataset("quantumiracle-git/robotinder-data")
|
23 |
os.remove('.git/hooks/pre-push') # https://github.com/git-lfs/git-lfs/issues/853
|
24 |
-
LOAD_DATA_GOOGLE_DRIVE =
|
|
|
25 |
if LOAD_DATA_GOOGLE_DRIVE: # download data from google drive
|
26 |
# url = 'https://drive.google.com/drive/folders/1JuNQS4R7axTezWj1x4KRAuRt_L26ApxA?usp=sharing' # './processed/' folder in google drive
|
27 |
# url = 'https://drive.google.com/drive/folders/1o8Q9eX-J7F326zv4g2MZWlzR46uVkUF2?usp=sharing' # './processed_zip/' folder in google drive
|
@@ -35,9 +38,6 @@ if LOAD_DATA_GOOGLE_DRIVE: # download data from google drive
|
|
35 |
# # VIDEO_PATH = 'filter_processed_zip'
|
36 |
# VIDEO_PATH = 'split_processed_zip'
|
37 |
|
38 |
-
# import zipfile
|
39 |
-
# from os import listdir
|
40 |
-
# from os.path import isfile, join, isdir
|
41 |
# # unzip the zip files to the same location and delete zip files
|
42 |
# path_to_zip_file = VIDEO_PATH
|
43 |
# zip_files = [join(path_to_zip_file, f) for f in listdir(path_to_zip_file)]
|
@@ -50,9 +50,6 @@ if LOAD_DATA_GOOGLE_DRIVE: # download data from google drive
|
|
50 |
# os.remove(f)
|
51 |
|
52 |
### multiple urls to handle the retrieve error
|
53 |
-
import zipfile
|
54 |
-
from os import listdir
|
55 |
-
from os.path import isfile, join, isdir
|
56 |
# urls = [
|
57 |
# 'https://drive.google.com/drive/folders/1BbQe4XtcsalsvwGVLW9jWCkr-ln5pvyf?usp=share_link', # './filter_processed_zip/1' folder in google drive
|
58 |
# 'https://drive.google.com/drive/folders/1saUTUuObPhMJFguc2J_O0K5woCJjYHci?usp=share_link', # './filter_processed_zip/2' folder in google drive
|
@@ -101,8 +98,21 @@ if LOAD_DATA_GOOGLE_DRIVE: # download data from google drive
|
|
101 |
zip_ref.extractall(directory_to_extract_to)
|
102 |
os.remove(f)
|
103 |
|
104 |
-
else:
|
105 |
-
VIDEO_PATH = '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
VIDEO_INFO = os.path.join(VIDEO_PATH, 'video_info.json')
|
108 |
|
|
|
8 |
from time import gmtime, strftime
|
9 |
from csv import writer
|
10 |
import json
|
11 |
+
import zipfile
|
12 |
+
from os import listdir
|
13 |
+
from os.path import isfile, join, isdir
|
14 |
from datasets import load_dataset
|
15 |
from hfserver import HuggingFaceDatasetSaver, HuggingFaceDatasetJSONSaver
|
16 |
|
|
|
23 |
# download data from huggingface dataset
|
24 |
# dataset = load_dataset("quantumiracle-git/robotinder-data")
|
25 |
os.remove('.git/hooks/pre-push') # https://github.com/git-lfs/git-lfs/issues/853
|
26 |
+
LOAD_DATA_GOOGLE_DRIVE = False
|
27 |
+
|
28 |
if LOAD_DATA_GOOGLE_DRIVE: # download data from google drive
|
29 |
# url = 'https://drive.google.com/drive/folders/1JuNQS4R7axTezWj1x4KRAuRt_L26ApxA?usp=sharing' # './processed/' folder in google drive
|
30 |
# url = 'https://drive.google.com/drive/folders/1o8Q9eX-J7F326zv4g2MZWlzR46uVkUF2?usp=sharing' # './processed_zip/' folder in google drive
|
|
|
38 |
# # VIDEO_PATH = 'filter_processed_zip'
|
39 |
# VIDEO_PATH = 'split_processed_zip'
|
40 |
|
|
|
|
|
|
|
41 |
# # unzip the zip files to the same location and delete zip files
|
42 |
# path_to_zip_file = VIDEO_PATH
|
43 |
# zip_files = [join(path_to_zip_file, f) for f in listdir(path_to_zip_file)]
|
|
|
50 |
# os.remove(f)
|
51 |
|
52 |
### multiple urls to handle the retrieve error
|
|
|
|
|
|
|
53 |
# urls = [
|
54 |
# 'https://drive.google.com/drive/folders/1BbQe4XtcsalsvwGVLW9jWCkr-ln5pvyf?usp=share_link', # './filter_processed_zip/1' folder in google drive
|
55 |
# 'https://drive.google.com/drive/folders/1saUTUuObPhMJFguc2J_O0K5woCJjYHci?usp=share_link', # './filter_processed_zip/2' folder in google drive
|
|
|
98 |
zip_ref.extractall(directory_to_extract_to)
|
99 |
os.remove(f)
|
100 |
|
101 |
+
else:
|
102 |
+
VIDEO_PATH = 'processed-data'
|
103 |
+
path_to_zip_file = VIDEO_PATH
|
104 |
+
zip_files = [join(path_to_zip_file, f) for f in listdir(path_to_zip_file)]
|
105 |
+
for f in zip_files:
|
106 |
+
if f.endswith(".zip"):
|
107 |
+
directory_to_extract_to = path_to_zip_file # extracted file itself contains a folder
|
108 |
+
print(f'extract data {f} to {directory_to_extract_to}')
|
109 |
+
with zipfile.ZipFile(f, 'r') as zip_ref:
|
110 |
+
zip_ref.extractall(directory_to_extract_to)
|
111 |
+
os.remove(f)
|
112 |
+
|
113 |
+
# for test only
|
114 |
+
# else: # local data
|
115 |
+
# VIDEO_PATH = 'robotinder-data'
|
116 |
|
117 |
VIDEO_INFO = os.path.join(VIDEO_PATH, 'video_info.json')
|
118 |
|