-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
30 lines (23 loc) · 749 Bytes
/
Copy pathsetup.py
File metadata and controls
30 lines (23 loc) · 749 Bytes
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
import kagglehub
import shutil
import os, random
TEST_SAMPLES = 10
def main():
if not os.path.exists("./train"):
# Download kaggle dataset
path = kagglehub.dataset_download("alexanderyyy/mnist-patched-2022")
shutil.move(path, '.')
# Move the train folder to the current directory and delete unwanted folder
source = "./1/mnist_png_patched/train"
destination = "./train"
shutil.move(source, destination)
shutil.rmtree("./1")
# Create a test folder
os.mkdir("./test")
for i in range(10):
os.mkdir(f"./test/{i}")
path = f"./train/{i}/"
for j in range(TEST_SAMPLES):
shutil.move(path + str(random.choice(os.listdir(path))), f"./test/{i}")
if __name__ == '__main__':
main()