Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

update nobooks #9

Merged
merged 24 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).


## [0.1.0] - 01/02/2021

### Added

- Added flash_notebook examples ([#9](https://github.com/PyTorchLightning/pytorch-lightning/pull/9))

### Changed

### Fixed


### Removed
241 changes: 241 additions & 0 deletions flash_notebooks/finetuning/image_classification.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
{
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
tchaton marked this conversation as resolved.
Show resolved Hide resolved
"cells": [
{
"cell_type": "markdown",
"id": "inner-confusion",
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/PyTorchLightning/lightning-flash/blob/master/flash_notebooks/finetuning/image_classification.ipynb)"
]
},
{
"cell_type": "markdown",
"id": "stretch-hearts",
"metadata": {},
"source": [
"In this notebook, we'll go over the basics of lightning Flash by training a ImageClassifier on [Hymenoptera Dataset](https://www.kaggle.com/ajayrana/hymenoptera-data).\n",
"\n",
"---\n",
" - Give us a ⭐ [on Github](https://www.github.com/PytorchLightning/pytorch-lightning/)\n",
" - Check out [Flash documentation](https://lightning-flash.readthedocs.io/en/latest/)\n",
" - Check out [Lightning documentation](https://pytorch-lightning.readthedocs.io/en/latest/)\n",
" - Join us [on Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-f6bl2l0l-JYMK3tbAgAmGRrlNr00f1A)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "worldwide-request",
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"! pip install lightning-flash"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "perfect-timber",
"metadata": {},
"outputs": [],
"source": [
"import flash\n",
"from flash.core.data import download_data\n",
"from flash.vision import ImageClassificationData, ImageClassifier"
]
},
{
"cell_type": "markdown",
"id": "impaired-fraud",
"metadata": {},
"source": [
"### 1. Download the data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "separated-intelligence",
"metadata": {},
"outputs": [],
"source": [
"download_data(\"https://pl-flash-data.s3.amazonaws.com/hymenoptera_data.zip\", 'data/')"
]
},
{
"cell_type": "markdown",
"id": "following-synthesis",
"metadata": {},
"source": [
"### 2. Load the data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "moving-saturday",
"metadata": {},
"outputs": [],
"source": [
"datamodule = ImageClassificationData.from_folders(\n",
" train_folder=\"data/hymenoptera_data/train/\",\n",
" valid_folder=\"data/hymenoptera_data/val/\",\n",
" test_folder=\"data/hymenoptera_data/test/\",\n",
")"
]
},
{
"cell_type": "markdown",
"id": "independent-relationship",
"metadata": {},
"source": [
"### 3. Build the model"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "increased-vaccine",
"metadata": {},
"outputs": [],
"source": [
"model = ImageClassifier(num_classes=datamodule.num_classes)"
]
},
{
"cell_type": "markdown",
"id": "narrative-samba",
"metadata": {},
"source": [
"### 4. Create the trainer. Run once on data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fifteen-manchester",
"metadata": {},
"outputs": [],
"source": [
"trainer = flash.Trainer(max_epochs=1)"
]
},
{
"cell_type": "markdown",
"id": "convertible-currency",
"metadata": {},
"source": [
"### 5. Train the model"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "portable-geneva",
"metadata": {},
"outputs": [],
"source": [
"trainer.finetune(model, datamodule=datamodule, unfreeze_milestones=(0, 1))"
]
},
{
"cell_type": "markdown",
"id": "funky-methodology",
"metadata": {},
"source": [
"### 6. Test the model"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ambient-donna",
"metadata": {},
"outputs": [],
"source": [
"trainer.test()"
]
},
{
"cell_type": "markdown",
"id": "missing-campaign",
"metadata": {},
"source": [
"### 7. Save it!"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "advance-kruger",
"metadata": {},
"outputs": [],
"source": [
"trainer.save_checkpoint(\"image_classification_model.pt\")"
]
},
{
"cell_type": "markdown",
"id": "applicable-remedy",
"metadata": {},
"source": [
"<code style=\"color:#792ee5;\">\n",
" <h1> <strong> Congratulations - Time to Join the Community! </strong> </h1>\n",
"</code>\n",
"\n",
"Congratulations on completing this notebook tutorial! If you enjoyed it and would like to join the Lightning movement, you can do so in the following ways!\n",
"\n",
"### Help us build Flash by adding support for new data-types and new tasks.\n",
"Flash aims at becoming the first task hub, so anyone can get started to great amazing application using deep learning. \n",
"If you are interested, please open a PR with your contributions !!! \n",
"\n",
"\n",
"### Star [Lightning](https://github.com/PyTorchLightning/pytorch-lightning) on GitHub\n",
"The easiest way to help our community is just by starring the GitHub repos! This helps raise awareness of the cool tools we're building.\n",
"\n",
"* Please, star [Lightning](https://github.com/PyTorchLightning/pytorch-lightning)\n",
"\n",
"### Join our [Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-f6bl2l0l-JYMK3tbAgAmGRrlNr00f1A)!\n",
"The best way to keep up to date on the latest advancements is to join our community! Make sure to introduce yourself and share your interests in `#general` channel\n",
"\n",
"### Interested by SOTA AI models ! Check out [Bolt](https://github.com/PyTorchLightning/pytorch-lightning-bolts)\n",
"Bolts has a collection of state-of-the-art models, all implemented in [Lightning](https://github.com/PyTorchLightning/pytorch-lightning) and can be easily integrated within your own projects.\n",
"\n",
"* Please, star [Bolt](https://github.com/PyTorchLightning/pytorch-lightning-bolts)\n",
"\n",
"### Contributions !\n",
"The best way to contribute to our community is to become a code contributor! At any time you can go to [Lightning](https://github.com/PyTorchLightning/pytorch-lightning) or [Bolt](https://github.com/PyTorchLightning/pytorch-lightning-bolts) GitHub Issues page and filter for \"good first issue\". \n",
"\n",
"* [Lightning good first issue](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)\n",
"* [Bolt good first issue](https://github.com/PyTorchLightning/pytorch-lightning-bolts/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)\n",
"* You can also contribute your own notebooks with useful examples !\n",
"\n",
"### Great thanks from the entire Pytorch Lightning Team for your interest !\n",
"\n",
"<img src=\"https://github.com/PyTorchLightning/pytorch-lightning/blob/master/docs/source/_images/logos/lightning_logo-name.png?raw=true\" width=\"800\" height=\"200\" />"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading