Skip to content

Commit ea93221

Browse files
authored
Merge pull request #3719 from programminghistorian/notebook-update-computer-vision
Update computer-vision-deep-learning-pt1-2.ipynb
2 parents 3073e89 + 49df21c commit ea93221

1 file changed

Lines changed: 15 additions & 30 deletions

File tree

assets/computer-vision-deep-learning-pt1-2/computer-vision-deep-learning-pt1-2.ipynb

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@
1010
"<a href=\"https://colab.research.google.com/github/programminghistorian/jekyll/blob/gh-pages/assets/computer-vision-deep-learning-pt1-2/computer-vision-deep-learning-pt1-2.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
1111
]
1212
},
13-
{
14-
"cell_type": "markdown",
15-
"metadata": {
16-
"id": "Fjnm_wg5Axz4"
17-
},
18-
"source": []
19-
},
20-
{
21-
"cell_type": "markdown",
22-
"metadata": {
23-
"id": "mnPMMn3D2pGO"
24-
},
25-
"source": [
26-
"Authors' note: The cells below set up the data to mirror the format found on Kaggle, which is where this notebook was originally written. If you are running the notebook on your own machine or server, you will probably want a different directory structure (note that we can't provide support for this approach to running the lesson material)."
27-
]
28-
},
2913
{
3014
"cell_type": "code",
3115
"execution_count": null,
@@ -35,16 +19,16 @@
3519
"outputs": [],
3620
"source": [
3721
"%%capture\n",
38-
"!mkdir ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ -p\n",
39-
"!wget https://zenodo.org/record/5838410/files/ads_upsampled.csv?download=1 -O ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ads_upsampled.csv\n",
40-
"!mkdir ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/ -p\n",
22+
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ -p\n",
23+
"!wget https://zenodo.org/record/5838410/files/ads_upsampled.csv?download=1 -O ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ads_upsampled.csv\n",
24+
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/ -p\n",
4125
"!wget -O images.zip https://zenodo.org/record/5838410/files/images.zip?download=1\n",
42-
"!unzip images.zip -d ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/\n",
43-
"!mkdir ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/ -p\n",
44-
"!wget https://zenodo.org/record/4487141/files/multi_label.csv?download=1 -O ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv\n",
26+
"!unzip images.zip -d ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/\n",
27+
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/ -p\n",
28+
"!wget https://zenodo.org/record/4487141/files/multi_label.csv?download=1 -O ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv\n",
4529
"!wget -O photo_images.zip https://zenodo.org/record/4487141/files/images.zip?download=1\n",
46-
"!mkdir ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images -p\n",
47-
"!unzip photo_images -d ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images"
30+
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images -p\n",
31+
"!unzip photo_images -d ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images"
4832
]
4933
},
5034
{
@@ -55,8 +39,9 @@
5539
},
5640
"outputs": [],
5741
"source": [
58-
"!pip install fastai --upgrade"
59-
]
42+
"!pip install fastai==2.7.9\n",
43+
"!pip install fastprogress==1.0.3"
44+
]
6045
},
6146
{
6247
"cell_type": "markdown",
@@ -153,7 +138,7 @@
153138
"outputs": [],
154139
"source": [
155140
"ad_data = ImageDataLoaders.from_csv(\n",
156-
" path=\"../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/\", # root path to csv file and image directory\n",
141+
" path=\"../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/\", # root path to csv file and image directory\n",
157142
" csv_fname=\"ads_upsampled.csv\", # the name of our csv file\n",
158143
" folder=\"images/\", # the folder where our images are stored\n",
159144
" fn_col=\"file\", # the file column in our csv\n",
@@ -384,7 +369,7 @@
384369
},
385370
"outputs": [],
386371
"source": [
387-
"df = pd.read_csv('../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv', na_filter=False)"
372+
"df = pd.read_csv('../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv', na_filter=False)"
388373
]
389374
},
390375
{
@@ -660,7 +645,7 @@
660645
"source": [
661646
"photo_data = ImageDataLoaders.from_df(\n",
662647
" df, # the dataframe where our labels and image file paths are stored\n",
663-
" folder=\"../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # the path to the directory holding the images\n",
648+
" folder=\"../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # the path to the directory holding the images\n",
664649
" bs=32, # the batch size (number of images + labels)\n",
665650
" label_delim=\"|\", # the deliminator between each label in our label column\n",
666651
" item_tfms=Resize(224), # resize each image to 224x224\n",
@@ -951,7 +936,7 @@
951936
"source": [
952937
"photo_data = ImageDataLoaders.from_df(\n",
953938
" df, # dataframe containing paths to images and labels\n",
954-
" folder=\"../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # folder where images are stored\n",
939+
" folder=\"../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # folder where images are stored\n",
955940
" bs=32, # batch size\n",
956941
" label_delim=\"|\", # the deliminator for multiple labels\n",
957942
" item_tfms=Resize(224), # resize images to a standard size\n",

0 commit comments

Comments
 (0)