Spaces:
Sleeping
Sleeping
quantumiracle-git
commited on
Commit
·
2a181f4
1
Parent(s):
6bab0a7
Update app.py
Browse files
app.py
CHANGED
@@ -26,28 +26,59 @@ 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
|
28 |
# url = 'https://drive.google.com/drive/folders/1ZWgpPiZwnWfwlwta8Tu-Jtu2HsS7HAEa?usp=share_link' # './filter_processed_zip/' folder in google drive
|
29 |
-
url = 'https://drive.google.com/drive/folders/1ROkuX6rQpyK7vLqF5fL2mggKiMCdKSuY?usp=share_link' # './split_processed_zip/' folder in google drive
|
30 |
-
|
31 |
-
output = './'
|
32 |
-
id = url.split('/')[-1]
|
33 |
-
os.system(f"gdown --id {id} -O {output} --folder --no-cookies --remaining-ok")
|
34 |
-
# VIDEO_PATH = 'processed_zip'
|
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 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
else: # local data
|
53 |
VIDEO_PATH = 'robotinder-data'
|
|
|
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
|
28 |
# url = 'https://drive.google.com/drive/folders/1ZWgpPiZwnWfwlwta8Tu-Jtu2HsS7HAEa?usp=share_link' # './filter_processed_zip/' folder in google drive
|
29 |
+
# url = 'https://drive.google.com/drive/folders/1ROkuX6rQpyK7vLqF5fL2mggKiMCdKSuY?usp=share_link' # './split_processed_zip/' folder in google drive
|
30 |
+
|
31 |
+
# output = './'
|
32 |
+
# id = url.split('/')[-1]
|
33 |
+
# os.system(f"gdown --id {id} -O {output} --folder --no-cookies --remaining-ok")
|
34 |
+
# # VIDEO_PATH = 'processed_zip'
|
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)]
|
44 |
+
# for f in zip_files:
|
45 |
+
# if f.endswith(".zip"):
|
46 |
+
# directory_to_extract_to = path_to_zip_file # extracted file itself contains a folder
|
47 |
+
# print(f'extract data {f} to {directory_to_extract_to}')
|
48 |
+
# with zipfile.ZipFile(f, 'r') as zip_ref:
|
49 |
+
# zip_ref.extractall(directory_to_extract_to)
|
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
|
59 |
+
'https://drive.google.com/drive/folders/1Kh9_E28-RH8g8EP1V3DhGI7KRs9LB7YJ?usp=share_link', # './filter_processed_zip/3' folder in google drive
|
60 |
+
'https://drive.google.com/drive/folders/1oE75Dz6hxtaSpNhjD22PmQfgQ-PjnEc0?usp=share_link', # './filter_processed_zip/4' folder in google drive
|
61 |
+
'https://drive.google.com/drive/folders/1XSPEKFqNHpXdLho-bnkT6FZZXssW8JkC?usp=share_link', # './filter_processed_zip/5' folder in google drive
|
62 |
+
]
|
63 |
+
|
64 |
+
output = './'
|
65 |
+
# VIDEO_PATH = 'processed_zip'
|
66 |
+
VIDEO_PATH = 'filter_processed_zip'
|
67 |
+
# VIDEO_PATH = 'split_processed_zip'
|
68 |
+
for i, url in enumerate(urls):
|
69 |
+
id = url.split('/')[-1]
|
70 |
+
os.system(f"gdown --id {id} -O {output} --folder --no-cookies --remaining-ok")
|
71 |
+
|
72 |
+
# unzip the zip files to the same location and delete zip files
|
73 |
+
path_to_zip_file = str(i)
|
74 |
+
zip_files = [join(path_to_zip_file, f) for f in listdir(path_to_zip_file)]
|
75 |
+
for f in zip_files:
|
76 |
+
if f.endswith(".zip"):
|
77 |
+
directory_to_extract_to = VIDEO_PATH # extracted file itself contains a folder
|
78 |
+
print(f'extract data {f} to {directory_to_extract_to}')
|
79 |
+
with zipfile.ZipFile(f, 'r') as zip_ref:
|
80 |
+
zip_ref.extractall(directory_to_extract_to)
|
81 |
+
os.remove(f)
|
82 |
|
83 |
else: # local data
|
84 |
VIDEO_PATH = 'robotinder-data'
|