MarkusStoll commited on
Commit
1750280
1 Parent(s): 88fb9ce

dataset in dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -0
  2. prepare.py +22 -0
Dockerfile CHANGED
@@ -15,4 +15,5 @@ RUN pip install datasets
15
  COPY . .
16
  RUN mkdir -p /code/.cache
17
  RUN chmod -R 777 /code
 
18
  CMD ["python", "run.py"]
 
15
  COPY . .
16
  RUN mkdir -p /code/.cache
17
  RUN chmod -R 777 /code
18
+ RUN python prepare.py
19
  CMD ["python", "run.py"]
prepare.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import datasets
3
+ import os
4
+
5
+ if __name__ == "__main__":
6
+ cache_file = "dataset_cache.pkl"
7
+ if os.path.exists(cache_file):
8
+ # Load dataset from cache
9
+ with open(cache_file, "rb") as file:
10
+ dataset = pickle.load(file)
11
+ print("Dataset loaded from cache.")
12
+ else:
13
+ # Load dataset using datasets.load_dataset()
14
+ dataset = datasets.load_dataset("renumics/cifar100-enriched", split="train")
15
+ print("Dataset loaded using datasets.load_dataset().")
16
+
17
+ # Save dataset to cache
18
+ with open(cache_file, "wb") as file:
19
+ pickle.dump(dataset, file)
20
+
21
+ print("Dataset saved to cache.")
22
+