Skip to content

Commit 51f52d2

Browse files
committed
fetch hymenoptera_data
1 parent 35a4477 commit 51f52d2

File tree

1 file changed

+10
-2
lines changed
  • demonstrations_v2/tutorial_quantum_transfer_learning

1 file changed

+10
-2
lines changed

demonstrations_v2/tutorial_quantum_transfer_learning/demo.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
import time
124124
import os
125125
import copy
126+
import urllib.request
127+
import shutil
126128

127129
# PyTorch
128130
import torch
@@ -211,7 +213,13 @@
211213
),
212214
}
213215

214-
data_dir = "../_data/hymenoptera_data"
216+
data_dir = "hymenoptera_data"
217+
if not os.path.exists(data_dir):
218+
urllib.request.urlretrieve(
219+
"https://download.pytorch.org/tutorial/hymenoptera_data.zip", f"{data_dir}.zip"
220+
)
221+
shutil.unpack_archive(f"{data_dir}.zip")
222+
215223
image_datasets = {
216224
x if x == "train" else "validation": datasets.ImageFolder(
217225
os.path.join(data_dir, x), data_transforms[x]
@@ -609,4 +617,4 @@ def visualize_model(model, num_images=6, fig_name="Predictions"):
609617
#
610618
# About the author
611619
# ----------------
612-
#
620+
#

0 commit comments

Comments
 (0)