Created
June 18, 2022 22:45
-
-
Save EmbraceLife/ffc170d3bf3e7ca6ced3f5585f3f97ef to your computer and use it in GitHub Desktop.
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": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "773ae077", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from fastai.vision.all import *" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1b5d9042", | |
"metadata": {}, | |
"source": [ | |
"What did we just import from the above line?" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "359a01d7", | |
"metadata": {}, | |
"source": [ | |
"#### `fastai.vision.all`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "f4bb2332", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"total 120\n", | |
"drwxr-xr-x 3 root root 10 Jun 17 23:18 .\n", | |
"drwxr-xr-x 8 root root 25 Jun 18 12:05 ..\n", | |
"-rw-r--r-- 1 root root 1 Jun 17 23:18 __init__.py\n", | |
"-rw-r--r-- 1 root root 206 Jun 17 23:18 all.py\n", | |
"-rw-r--r-- 1 root root 54295 Jun 17 23:18 augment.py\n", | |
"-rw-r--r-- 1 root root 9943 Jun 17 23:18 core.py\n", | |
"-rw-r--r-- 1 root root 11247 Jun 17 23:18 data.py\n", | |
"-rw-r--r-- 1 root root 18879 Jun 17 23:18 gan.py\n", | |
"-rw-r--r-- 1 root root 17250 Jun 17 23:18 learner.py\n", | |
"drwxr-xr-x 2 root root 5 Jun 17 23:18 models\n", | |
"-rw-r--r-- 1 root root 3928 Jun 17 23:18 utils.py\n", | |
"-rw-r--r-- 1 root root 4869 Jun 17 23:18 widgets.py\n" | |
] | |
} | |
], | |
"source": [ | |
"! ls -la fastai/fastai/vision" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2c54b1d6", | |
"metadata": {}, | |
"source": [ | |
"#### `from fastai.vision.all import *`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "07aee715", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"from . import models\n", | |
"from ..basics import *\n", | |
"from ..callback.all import *\n", | |
"from .augment import *\n", | |
"from .core import *\n", | |
"from .data import *\n", | |
"from .models.all import *\n", | |
"from .learner import *\n", | |
"from .utils import *\n", | |
"\u001b[K\u001b[7m(END)\u001b[m\u001b[Kvision/all.py (END)\u001b[m\u001b[K\u0007" | |
] | |
} | |
], | |
"source": [ | |
"! less fastai/fastai/vision/all.py" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "07ad0b45", | |
"metadata": {}, | |
"source": [ | |
"#### `from . import models`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "d8ba445a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"total 14\n", | |
"drwxr-xr-x 2 root root 5 Jun 17 23:18 .\n", | |
"drwxr-xr-x 3 root root 10 Jun 17 23:18 ..\n", | |
"-rw-r--r-- 1 root root 60 Jun 17 23:18 __init__.py\n", | |
"-rw-r--r-- 1 root root 62 Jun 17 23:18 all.py\n", | |
"-rw-r--r-- 1 root root 309 Jun 17 23:18 tvm.py\n", | |
"-rw-r--r-- 1 root root 4574 Jun 17 23:18 unet.py\n", | |
"-rw-r--r-- 1 root root 7561 Jun 17 23:18 xresnet.py\n" | |
] | |
} | |
], | |
"source": [ | |
"! ls -la fastai/fastai/vision/models" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "66dc8dab", | |
"metadata": {}, | |
"source": [ | |
"#### `from ..basics import *`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "9f77c002", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"from .data.all import *\n", | |
"from .optimizer import *\n", | |
"from .callback.core import *\n", | |
"from .learner import *\n", | |
"from .metrics import *\n", | |
"from .interpret import *\n", | |
"\u001b[K\u001b[7m(END)\u001b[m\u001b[Kbasics.py (END)\u001b[m\u001b[K\u0007" | |
] | |
} | |
], | |
"source": [ | |
"! less fastai/fastai/basics.py" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "3c895443", | |
"metadata": {}, | |
"source": [ | |
"#### `from ..callback.all import *`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "b80d6f1a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"from .core import *\n", | |
"from .data import *\n", | |
"from .fp16 import *\n", | |
"from .hook import *\n", | |
"from .mixup import *\n", | |
"from .progress import *\n", | |
"from .schedule import *\n", | |
"from .tracker import *\n", | |
"from .rnn import *\n", | |
"from .training import *\n", | |
"from .preds import *\n", | |
"\u001b[K\u001b[7m(END)\u001b[m\u001b[Kcallback/all.py (END)\u001b[m\u001b[K\u0007" | |
] | |
} | |
], | |
"source": [ | |
"! less fastai/fastai/callback/all.py" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0a75e9b5", | |
"metadata": {}, | |
"source": [ | |
"#### `from .augment import *`" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "77939dae", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/09_vision.augment.ipynb (unless otherwise specified).\n", | |
"\n", | |
"\n", | |
"from __future__ import annotations\n", | |
"\n", | |
"\n", | |
"__all__ = ['RandTransform', 'TensorTypes', 'FlipItem', 'DihedralItem', 'PadMode', 'CropPad', 'RandomCrop',\n", | |
" 'OldRandomCrop', 'ResizeMethod', 'Resize', 'RandomResizedCrop', 'RatioResize', 'affine_grid',\n", | |
" 'AffineCoordTfm', 'RandomResizedCropGPU', 'mask_tensor', 'affine_mat', 'flip_mat', 'Flip',\n", | |
" 'DeterministicDraw', 'DeterministicFlip', 'dihedral_mat', 'Dihedral', 'DeterministicDihedral', 'rotate_mat',\n", | |
" 'Rotate', 'zoom_mat', 'Zoom', 'find_coeffs', 'apply_perspective', 'Warp', 'SpaceTfm', 'LightingTfm',\n", | |
" 'Brightness', 'Contrast', 'grayscale', 'Saturation', 'rgb2hsv', 'hsv2rgb', 'HSVTfm', 'Hue',\n", | |
" 'cutout_gaussian', 'norm_apply_denorm', 'RandomErasing', 'setup_aug_tfms', 'aug_transforms']\n", | |
"\n", | |
"# Cell\n", | |
"\u001b[K:\u001b[Ktai/fastai/vision/augment.py\u001b[m\u001b[K\u0007" | |
] | |
} | |
], | |
"source": [ | |
"! less fastai/fastai/vision/augment.py" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "bd8240a9", | |
"metadata": {}, | |
"source": [ | |
"#### `Rand` + tab to have a list of options to choose" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "19cb93e5", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"fastai.vision.augment.RandTransform" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"RandTransform" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "56dadeed", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mInit signature:\u001b[0m \u001b[0mRandTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1.0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbefore_call\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mDocstring:\u001b[0m A transform that before_call its state at each `__call__`\n", | |
"\u001b[0;31mFile:\u001b[0m /opt/conda/lib/python3.7/site-packages/fastai/vision/augment.py\n", | |
"\u001b[0;31mType:\u001b[0m _TfmMeta\n", | |
"\u001b[0;31mSubclasses:\u001b[0m FlipItem, DihedralItem, RandomCrop, Resize, RandomResizedCrop, AffineCoordTfm, RandomResizedCropGPU, SpaceTfm, RandomErasing\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"RandTransform?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "73c2fff6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mInit signature:\u001b[0m \u001b[0mRandTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1.0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbefore_call\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mSource:\u001b[0m \n", | |
"\u001b[0;32mclass\u001b[0m \u001b[0mRandTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDisplayedTransform\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;34m\"A transform that before_call its state at each `__call__`\"\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mdo\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mnm\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0msupports\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0msplit_idx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbefore_call\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mstore_attr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'p'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbefore_call\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mifnone\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbefore_call\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbefore_call\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mbefore_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;34m\"Set `self.do` based on `self.p`\"\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m==\u001b[0m\u001b[0;36m1.\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbefore_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msplit_idx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msplit_idx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdo\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mFile:\u001b[0m /opt/conda/lib/python3.7/site-packages/fastai/vision/augment.py\n", | |
"\u001b[0;31mType:\u001b[0m _TfmMeta\n", | |
"\u001b[0;31mSubclasses:\u001b[0m FlipItem, DihedralItem, RandomCrop, Resize, RandomResizedCrop, AffineCoordTfm, RandomResizedCropGPU, SpaceTfm, RandomErasing\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"RandTransform??" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "c03d9748", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"fastcore.transform.DisplayedTransform" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"DisplayedTransform" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "5ee4a412", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mInit signature:\u001b[0m \u001b[0mDisplayedTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0menc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdec\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mDocstring:\u001b[0m A transform with a `__repr__` that shows its attrs\n", | |
"\u001b[0;31mFile:\u001b[0m ~/.local/lib/python3.7/site-packages/fastcore/transform.py\n", | |
"\u001b[0;31mType:\u001b[0m _TfmMeta\n", | |
"\u001b[0;31mSubclasses:\u001b[0m ColReader, Categorize, OneHotEncode, RegressionSetup, IntToFloatTensor, Normalize, RandTransform, CropPad, RatioResize\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"DisplayedTransform?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "e2ea62e5", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mInit signature:\u001b[0m \u001b[0mDisplayedTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0menc\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdec\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msplit_idx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mSource:\u001b[0m \n", | |
"\u001b[0;32mclass\u001b[0m \u001b[0mDisplayedTransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mTransform\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;34m\"A transform with a `__repr__` that shows its attrs\"\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;34mf\"{super().name} -- {getattr(self,'__stored_args__',{})}\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mFile:\u001b[0m ~/.local/lib/python3.7/site-packages/fastcore/transform.py\n", | |
"\u001b[0;31mType:\u001b[0m _TfmMeta\n", | |
"\u001b[0;31mSubclasses:\u001b[0m ColReader, Categorize, OneHotEncode, RegressionSetup, IntToFloatTensor, Normalize, RandTransform, CropPad, RatioResize\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"DisplayedTransform??" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"id": "43fee8c9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<h2 id=\"RandTransform\" class=\"doc_header\"><code>class</code> <code>RandTransform</code><a href=\"https://github.com/fastai/fastai/tree/master/fastai/vision/augment.py#L21\" class=\"source_link\" style=\"float:right\">[source]</a></h2><blockquote><p><code>RandTransform</code>(<strong><code>p</code></strong>=<em><code>1.0</code></em>, <strong><code>nm</code></strong>=<em><code>None</code></em>, <strong><code>before_call</code></strong>=<em><code>None</code></em>, <strong>**<code>kwargs</code></strong>) :: <code>DisplayedTransform</code></p>\n", | |
"</blockquote>\n", | |
"<p>A transform that before_call its state at each <code>__call__</code></p>\n", | |
"<p><a href=\"https://docs.fast.ai/vision.augment#RandTransform\" target=\"_blank\" rel=\"noreferrer noopener\">Show in docs</a></p>\n", | |
"<style>\n", | |
" table { border-collapse: collapse; border:thin solid #dddddd; margin: 25px 0px; ; }\n", | |
" table tr:first-child { background-color: #FFF}\n", | |
" table thead th { background-color: #eee; color: #000; text-align: center;}\n", | |
" tr, th, td { border: 1px solid #ccc; border-width: 1px 0 0 1px; border-collapse: collapse;\n", | |
" padding: 5px; }\n", | |
" tr:nth-child(even) {background: #eee;}</style>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"doc(RandTransform)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "800df300", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<function fastai.data.external.untar_data(url, archive=None, data=None, c_key='data', force_download=False)>" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"untar_data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "af32f67d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mSignature:\u001b[0m\n", | |
"\u001b[0muntar_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0marchive\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mc_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mforce_download\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mDocstring:\u001b[0m Download `url` to `fname` if `dest` doesn't exist, and extract to folder `dest`\n", | |
"\u001b[0;31mFile:\u001b[0m /opt/conda/lib/python3.7/site-packages/fastai/data/external.py\n", | |
"\u001b[0;31mType:\u001b[0m function\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"untar_data?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "c465bfa9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"\u001b[0;31mSignature:\u001b[0m\n", | |
"\u001b[0muntar_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0marchive\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mc_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0mforce_download\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mSource:\u001b[0m \n", | |
"\u001b[0;32mdef\u001b[0m \u001b[0muntar_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marchive\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mforce_download\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;31m#, extract_func=file_extract, timeout=4):\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;34m\"Download `url` to `fname` if `dest` doesn't exist, and extract to folder `dest`\"\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0md\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFastDownload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfastai_cfg\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmodule\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfastai\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marchive\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0marchive\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbase\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'~/.fastai'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n", | |
"\u001b[0;34m\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0murl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mforce\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mforce_download\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextract_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mc_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mFile:\u001b[0m /opt/conda/lib/python3.7/site-packages/fastai/data/external.py\n", | |
"\u001b[0;31mType:\u001b[0m function\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"untar_data??" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"id": "c51a8547", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<h4 id=\"untar_data\" class=\"doc_header\"><code>untar_data</code><a href=\"https://github.com/fastai/fastai/tree/master/fastai/data/external.py#L121\" class=\"source_link\" style=\"float:right\">[source]</a></h4><blockquote><p><code>untar_data</code>(<strong><code>url</code></strong>, <strong><code>archive</code></strong>=<em><code>None</code></em>, <strong><code>data</code></strong>=<em><code>None</code></em>, <strong><code>c_key</code></strong>=<em><code>'data'</code></em>, <strong><code>force_download</code></strong>=<em><code>False</code></em>)</p>\n", | |
"</blockquote>\n", | |
"<p>Download <code>url</code> to <code>fname</code> if <code>dest</code> doesn't exist, and extract to folder <code>dest</code></p>\n", | |
"<table>\n", | |
"<thead><tr>\n", | |
"<th></th>\n", | |
"<th>Type</th>\n", | |
"<th>Default</th>\n", | |
"<th>Details</th>\n", | |
"</tr>\n", | |
"</thead>\n", | |
"<tbody>\n", | |
"<tr>\n", | |
"<td><strong><code>url</code></strong></td>\n", | |
"<td></td>\n", | |
"<td></td>\n", | |
"<td><em>No Content</em></td>\n", | |
"</tr>\n", | |
"<tr>\n", | |
"<td><strong><code>archive</code></strong></td>\n", | |
"<td></td>\n", | |
"<td><code>None</code></td>\n", | |
"<td><em>No Content</em></td>\n", | |
"</tr>\n", | |
"<tr>\n", | |
"<td><strong><code>data</code></strong></td>\n", | |
"<td></td>\n", | |
"<td><code>None</code></td>\n", | |
"<td><em>No Content</em></td>\n", | |
"</tr>\n", | |
"<tr>\n", | |
"<td><strong><code>c_key</code></strong></td>\n", | |
"<td><code>str</code></td>\n", | |
"<td><code>data</code></td>\n", | |
"<td><em>No Content</em></td>\n", | |
"</tr>\n", | |
"<tr>\n", | |
"<td><strong><code>force_download</code></strong></td>\n", | |
"<td><code>bool</code></td>\n", | |
"<td><code>False</code></td>\n", | |
"<td>, extract_func=file_extract, timeout=4):</td>\n", | |
"</tr>\n", | |
"</tbody>\n", | |
"</table>\n", | |
"<p><a href=\"https://docs.fast.ai/data.external#untar_data\" target=\"_blank\" rel=\"noreferrer noopener\">Show in docs</a></p>\n", | |
"<style>\n", | |
" table { border-collapse: collapse; border:thin solid #dddddd; margin: 25px 0px; ; }\n", | |
" table tr:first-child { background-color: #FFF}\n", | |
" table thead th { background-color: #eee; color: #000; text-align: center;}\n", | |
" tr, th, td { border: 1px solid #ccc; border-width: 1px 0 0 1px; border-collapse: collapse;\n", | |
" padding: 5px; }\n", | |
" tr:nth-child(even) {background: #eee;}</style>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"doc(untar_data)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "74357c16", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <iframe\n", | |
" width=\"900\"\n", | |
" height=\"500\"\n", | |
" src=\"https://docs.fast.ai/data.external#untar_data\"\n", | |
" frameborder=\"0\"\n", | |
" allowfullscreen\n", | |
" ></iframe>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.lib.display.IFrame at 0x7f88247bcb90>" | |
] | |
}, | |
"execution_count": 24, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from IPython.display import IFrame\n", | |
"IFrame(\"https://docs.fast.ai/data.external#untar_data\", 900,500)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "8bdcf6de", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"path = untar_data(URLs.PETS)/'images'" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "f15780e5", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"Path('/storage/data/oxford-iiit-pet/images')" | |
] | |
}, | |
"execution_count": 29, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"path" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"id": "5ea0084b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"762M\t/storage/data/oxford-iiit-pet/images/\n" | |
] | |
} | |
], | |
"source": [ | |
"! du -sh /storage/data/oxford-iiit-pet/images/" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "77f9708e", | |
"metadata": {}, | |
"source": [ | |
"#### How to move the dataset to home directory in the first place?" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "dd5567db", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <iframe\n", | |
" width=\"900\"\n", | |
" height=\"500\"\n", | |
" src=\"https://fastdownload.fast.ai/#What's-this-about?\"\n", | |
" frameborder=\"0\"\n", | |
" allowfullscreen\n", | |
" ></iframe>\n", | |
" " | |
], | |
"text/plain": [ | |
"<IPython.lib.display.IFrame at 0x7f882207f7d0>" | |
] | |
}, | |
"execution_count": 33, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"IFrame(\"https://fastdownload.fast.ai/#What's-this-about?\", 900,500)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"id": "2fd1e5c0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"total 12\n", | |
"drwxr-xr-x 1 root root 4096 Jun 18 14:09 .\n", | |
"drwx------ 1 root root 4096 Jun 18 14:10 ..\n", | |
"lrwxrwxrwx 1 root root 23 Jun 18 14:09 config.ini -> /storage/cfg/config.ini\n" | |
] | |
} | |
], | |
"source": [ | |
"! ls -la ~/.fastai/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "a2cf9599", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[DEFAULT][?1h\u001b=\n", | |
"\n", | |
"model = /storage/models/\n", | |
"data = /storage/data\n", | |
"storage = /storage/data/\n", | |
"\u001b[K\u001b[7m(END)\u001b[m\u001b[Kconfig.ini (END)\u001b[m\u001b[K\u0007" | |
] | |
} | |
], | |
"source": [ | |
"! less /root/.fastai/config.ini" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"id": "c7a6e13d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"5.0K\t/storage/data\n" | |
] | |
} | |
], | |
"source": [ | |
"! du -sh /storage/data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"id": "38e56b5b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"ls: cannot access '/storage/archive': No such file or directory\n" | |
] | |
} | |
], | |
"source": [ | |
"ls -la /storage/archive" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "35fb6720", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def is_cat(x): return x[0].isupper()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "c36bdbc3", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "25d0b037", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "a7fafa33", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"dls = ImageDataLoaders.from_name_func(\n", | |
" path, get_image_files(path), valid_pct=0.2, seed=42,\n", | |
" label_func=is_cat, item_tfms=Resize(224))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "71c24cf9", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn = vision_learner(dls, resnet34, metrics=error_rate)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "09335dfa", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"learn.fine_tune(1)" | |
] | |
} | |
], | |
"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.7.11" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment