Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@
"<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>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Fjnm_wg5Axz4"
},
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "mnPMMn3D2pGO"
},
"source": [
"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)."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -35,16 +19,16 @@
"outputs": [],
"source": [
"%%capture\n",
"!mkdir ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ -p\n",
"!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",
"!mkdir ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/ -p\n",
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/ -p\n",
"!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",
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/ -p\n",
"!wget -O images.zip https://zenodo.org/record/5838410/files/images.zip?download=1\n",
"!unzip images.zip -d ../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/\n",
"!mkdir ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/ -p\n",
"!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",
"!unzip images.zip -d ../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/images/\n",
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/ -p\n",
"!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",
"!wget -O photo_images.zip https://zenodo.org/record/4487141/files/images.zip?download=1\n",
"!mkdir ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images -p\n",
"!unzip photo_images -d ../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images"
"!mkdir ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images -p\n",
"!unzip photo_images -d ../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images"
]
},
{
Expand All @@ -55,8 +39,9 @@
},
"outputs": [],
"source": [
"!pip install fastai --upgrade"
]
"!pip install fastai==2.7.9\n",
"!pip install fastprogress==1.0.3"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -153,7 +138,7 @@
"outputs": [],
"source": [
"ad_data = ImageDataLoaders.from_csv(\n",
" path=\"../input/computer-vision-for-the-humanities-ph/ads_data/ads_data/\", # root path to csv file and image directory\n",
" path=\"../content/input/computer-vision-for-the-humanities-ph/ads_data/ads_data/\", # root path to csv file and image directory\n",
" csv_fname=\"ads_upsampled.csv\", # the name of our csv file\n",
" folder=\"images/\", # the folder where our images are stored\n",
" fn_col=\"file\", # the file column in our csv\n",
Expand Down Expand Up @@ -384,7 +369,7 @@
},
"outputs": [],
"source": [
"df = pd.read_csv('../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv', na_filter=False)"
"df = pd.read_csv('../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/multi_label.csv', na_filter=False)"
]
},
{
Expand Down Expand Up @@ -660,7 +645,7 @@
"source": [
"photo_data = ImageDataLoaders.from_df(\n",
" df, # the dataframe where our labels and image file paths are stored\n",
" folder=\"../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # the path to the directory holding the images\n",
" folder=\"../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # the path to the directory holding the images\n",
" bs=32, # the batch size (number of images + labels)\n",
" label_delim=\"|\", # the deliminator between each label in our label column\n",
" item_tfms=Resize(224), # resize each image to 224x224\n",
Expand Down Expand Up @@ -951,7 +936,7 @@
"source": [
"photo_data = ImageDataLoaders.from_df(\n",
" df, # dataframe containing paths to images and labels\n",
" folder=\"../input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # folder where images are stored\n",
" folder=\"../content/input/computer-vision-for-the-humanities-ph/photos_multi/photos_multi/photo_images\", # folder where images are stored\n",
" bs=32, # batch size\n",
" label_delim=\"|\", # the deliminator for multiple labels\n",
" item_tfms=Resize(224), # resize images to a standard size\n",
Expand Down