scfive commited on
Commit
4d5fd96
·
1 Parent(s): d97825c

Initial Gradio app for image/video detection

Browse files
Files changed (1) hide show
  1. download_spod.py +44 -0
download_spod.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import zipfile
3
+ import gdown
4
+
5
+ # Google Drive file ID for SPOD_30b_8c.zip
6
+ FILE_ID = '1wfoLkfZOxxEtuDyDSWCnAq-N8HZVKdQ1'
7
+ DEST_DIR = './data/SPOD_dataset'
8
+ ZIP_PATH = os.path.join(DEST_DIR, 'SPOD_30b_8c.zip')
9
+ EXTRACTED_PATH = os.path.join(DEST_DIR, 'SPOD_30b_8c')
10
+ CONFIG_PATH = './configs/_base_/datasets/hsi_detection.py'
11
+
12
+ os.makedirs(DEST_DIR, exist_ok=True)
13
+
14
+ # Download the dataset
15
+ if not os.path.exists(ZIP_PATH):
16
+ url = f'[https://drive.google.com/uc?id={FILE_ID}'](https://drive.google.com/uc?id={FILE_ID}')
17
+ print(f'Downloading dataset from {url}...')
18
+ gdown.download(url, ZIP_PATH, quiet=False)
19
+ else:
20
+ print('Dataset zip already exists.')
21
+
22
+ # Extract the dataset
23
+ if not os.path.exists(EXTRACTED_PATH):
24
+ print('Extracting dataset...')
25
+ with zipfile.ZipFile(ZIP_PATH, 'r') as zip_ref:
26
+ zip_ref.extractall(DEST_DIR)
27
+ else:
28
+ print('Dataset already extracted.')
29
+
30
+ # Update config file
31
+ if os.path.exists(CONFIG_PATH):
32
+ with open(CONFIG_PATH, 'r') as f:
33
+ lines = f.readlines()
34
+ with open(CONFIG_PATH, 'w') as f:
35
+ for line in lines:
36
+ if line.strip().startswith('data_root'):
37
+ f.write(f"data_root = '{EXTRACTED_PATH}/'\n")
38
+ else:
39
+ f.write(line)
40
+ print(f'Updated {CONFIG_PATH} with dataset path.')
41
+ else:
42
+ print(f'Config file {CONFIG_PATH} not found!')
43
+
44
+ print('Done.')