-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdata.py
32 lines (24 loc) · 803 Bytes
/
data.py
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
import os
import shutil
import requests
import zipfile
DATA_PATH = './data'
RESULT_PATH = './result'
if os.path.exists(DATA_PATH):
shutil.rmtree(DATA_PATH)
os.mkdir(DATA_PATH)
print('Downloading and extracting data...')
url = 'https://github.com/YipengHu/datasets/raw/refs/heads/fetusphan/fetusphan.zip'
r = requests.get(url,allow_redirects=True)
temp_file = 'temp.zip'
_ = open(temp_file,'wb').write(r.content)
with zipfile.ZipFile(temp_file, 'r') as zip_ref:
zip_ref.extractall(DATA_PATH)
os.remove(temp_file)
print('Done.')
filename = os.path.join(DATA_PATH,'fetusphan.h5')
print('Done.')
print('Image and label data downloaded: %s' % filename)
if not os.path.exists(RESULT_PATH):
os.makedirs(RESULT_PATH)
print('Result directory created: %s' % os.path.abspath(RESULT_PATH))