File size: 1,373 Bytes
4d5fd96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import zipfile
import gdown

# Google Drive file ID for SPOD_30b_8c.zip
FILE_ID = '1wfoLkfZOxxEtuDyDSWCnAq-N8HZVKdQ1'
DEST_DIR = './data/SPOD_dataset'
ZIP_PATH = os.path.join(DEST_DIR, 'SPOD_30b_8c.zip')
EXTRACTED_PATH = os.path.join(DEST_DIR, 'SPOD_30b_8c')
CONFIG_PATH = './configs/_base_/datasets/hsi_detection.py'

os.makedirs(DEST_DIR, exist_ok=True)

# Download the dataset
if not os.path.exists(ZIP_PATH):
    url = f'[https://drive.google.com/uc?id={FILE_ID}'](https://drive.google.com/uc?id={FILE_ID}')
    print(f'Downloading dataset from {url}...')
    gdown.download(url, ZIP_PATH, quiet=False)
else:
    print('Dataset zip already exists.')

# Extract the dataset
if not os.path.exists(EXTRACTED_PATH):
    print('Extracting dataset...')
    with zipfile.ZipFile(ZIP_PATH, 'r') as zip_ref:
        zip_ref.extractall(DEST_DIR)
else:
    print('Dataset already extracted.')

# Update config file
if os.path.exists(CONFIG_PATH):
    with open(CONFIG_PATH, 'r') as f:
        lines = f.readlines()
    with open(CONFIG_PATH, 'w') as f:
        for line in lines:
            if line.strip().startswith('data_root'):
                f.write(f"data_root = '{EXTRACTED_PATH}/'\n")
            else:
                f.write(line)
    print(f'Updated {CONFIG_PATH} with dataset path.')
else:
    print(f'Config file {CONFIG_PATH} not found!')

print('Done.')