Created
January 24, 2019 19:48
-
-
Save AlisonDavey/5742c87aa45da57511b7b10bb4f8bd51 to your computer and use it in GitHub Desktop.
Oxford_Flowers_Classifier_fastai.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "metadata": {}, | |
| "cell_type": "markdown", | |
| "source": "# Udacity PyTorch Challenge Classification Project - fast.ai\n\nIn this project an image classifier is trained to recognize different species of flowers using [the Oxford dataset](http://www.robots.ox.ac.uk/~vgg/data/flowers/102/index.html) of 102 flower categories. \n\nMy [notebook](https://gist.github.com/AlisonDavey/17c5a5c09c7bbf31a3b95515c7cb70e6) for phase 1 of the PyTorch Scholarship Challenge uses PyTorch to achieve 99% accuracy in 30 or so epochs (7 misclassified flowers out of 819).\n\nAs a follow-up, the same data is used here using the [fast.ai V1](https://docs.fast.ai/) library which sits on top of Pytorch 1.0. The previous notebook gives the data sources and builds the test set.\n\nThis project is very similar to the dog breeds notebook in lesson 1 of the Practical Deep Learning for Coders (2019) course.\n\nThis complete notebook runs in 16 minutes on a P100 GPU on GCP to achieve at least 98% accuracy on the test set." | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "%matplotlib inline", | |
| "execution_count": 1, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "import fastai\nfastai.__version__", | |
| "execution_count": 2, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": "'1.0.40'" | |
| }, | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "from fastai import *\nfrom fastai.vision import *\n\nfrom torchvision import models as tvmodels", | |
| "execution_count": 3, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "path = Path('./assets/flower_data')", | |
| "execution_count": 4, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "tfms = get_transforms()\ndata = ImageDataBunch.from_folder(path, ds_tfms=tfms, bs=64, size=256)\ndata.normalize(imagenet_stats);", | |
| "execution_count": 5, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": false | |
| }, | |
| "cell_type": "code", | |
| "source": "data.show_batch(rows=3, figsize=(10,10))", | |
| "execution_count": 6, | |
| "outputs": [ | |
| { | |
| "data": { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment