{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Computer Vision models zoo" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.vision.models.darknet import Darknet\n", "from fastai.vision.models.wrn import wrn_22, WideResNet" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On top of the models offered by [torchivision](https://pytorch.org/docs/stable/torchvision/models.html), the fastai library has implementations for the following models:\n", "\n", "- Darknet architecture, which is the base of [Yolo v3](https://pjreddie.com/media/files/papers/YOLOv3.pdf)\n", "- Unet architecture based on a pretrained model. The original unet is described [here](https://arxiv.org/abs/1505.04597), the model implementation is detailed in [`models.unet`](/vision.models.unet.html#vision.models.unet)\n", "- Wide resnets architectures, as introduced in [this article](https://arxiv.org/abs/1605.07146)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class Darknet[source]

\n", "\n", "> Darknet(`num_blocks`:`Collection`\\[`int`\\], `num_classes`:`int`, `nf`=`32`) :: [`Module`](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(Darknet, doc_string=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a Darknet with blocks of sizes given in `num_blocks`, ending with `num_classes` and using `nf` initial features. Darknet53 uses `num_blocks = [1,2,8,8,4]`. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class WideResNet[source]

\n", "\n", "> WideResNet(`num_groups`:`int`, `N`:`int`, `num_classes`:`int`, `k`:`int`=`1`, `drop_p`:`float`=`0.0`, `start_nf`:`int`=`16`) :: [`Module`](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(WideResNet, doc_string=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a wide resnet with blocks `num_groups` groups, each containing blocks of size `N`. `k` is the width of the resnet, `start_nf` the initial number of features. Dropout of `drop_p` is applied at the end of each block." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

wrn_22[source]

\n", "\n", "> wrn_22()" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(wrn_22)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creates a wide resnet for CIFAR-10 with `num_groups=3`, `N=3`, `k=6` and `drop_p=0.`." ] } ], "metadata": { "jekyll": { "keywords": "fastai", "summary": "Overview of the models used for CV in fastai", "title": "vision.models" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 2 }