{ "cells": [ { "cell_type": "markdown", "metadata": { "hide_input": true }, "source": [ "## Computer vision data" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "%matplotlib inline\n", "from fastai.gen_doc.nbdoc import *\n", "from fastai.vision import * " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module contains the classes that define datasets handling [`Image`](/vision.image.html#Image) objects and their transformations. As usual, we'll start with a quick overview, before we get in to the detailed API docs.\n", "\n", "Before any work can be done a dataset needs to be converted into a [`DataBunch`](/basic_data.html#DataBunch) object, and in the case of the computer vision data - specifically into an [`ImageDataBunch`](/vision.data.html#ImageDataBunch) subclass.\n", "\n", "This is done with the help of [data block API](/data_block.html) and the [`ImageList`](/vision.data.html#ImageList) class and its subclasses.\n", " \n", "However, there is also a group of shortcut methods provided by [`ImageDataBunch`](/vision.data.html#ImageDataBunch) which reduce the multiple stages of the data block API, into a single wrapper method. These shortcuts methods work really well for:\n", "- Imagenet-style of datasets ([`ImageDataBunch.from_folder`](/vision.data.html#ImageDataBunch.from_folder))\n", "- A pandas `DataFrame` with a column of filenames and a column of labels which can be strings for classification, strings separated by a `label_delim` for multi-classification or floats for a regression problem ([`ImageDataBunch.from_df`](/vision.data.html#ImageDataBunch.from_df))\n", "- A csv file with the same format as above ([`ImageDataBunch.from_csv`](/vision.data.html#ImageDataBunch.from_csv))\n", "- A list of filenames and a list of targets ([`ImageDataBunch.from_lists`](/vision.data.html#ImageDataBunch.from_lists))\n", "- A list of filenames and a function to get the target from the filename ([`ImageDataBunch.from_name_func`](/vision.data.html#ImageDataBunch.from_name_func))\n", "- A list of filenames and a regex pattern to get the target from the filename ([`ImageDataBunch.from_name_re`](/vision.data.html#ImageDataBunch.from_name_re))\n", "\n", "In the last five factory methods, a random split is performed between train and validation, in the first one it can be a random split or a separation from a training and a validation folder.\n", "\n", "If you're just starting out you may choose to experiment with these shortcut methods, as they are also used in the first lessons of the fastai deep learning course. However, you can completely skip them and start building your code using the data block API from the very beginning. Internally, these shortcuts use this API anyway.\n", "\n", "The first part of this document is dedicated to the shortcut [`ImageDataBunch`](/vision.data.html#ImageDataBunch) factory methods. Then all the other computer vision data-specific methods that are used with the data block API are presented." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Quickly get your data ready for training" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To get you started as easily as possible, the fastai provides two helper functions to create a [`DataBunch`](/basic_data.html#DataBunch) object that you can directly use for training a classifier. To demonstrate them you'll first need to download and untar the file by executing the following cell. This will create a data folder containing an MNIST subset in `data/mnist_sample`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PosixPath('/home/ubuntu/.fastai/data/mnist_sample')" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path = untar_data(URLs.MNIST_SAMPLE); path" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are a number of ways to create an [`ImageDataBunch`](/vision.data.html#ImageDataBunch). One common approach is to use *Imagenet-style folders* (see a ways down the page below for details) with [`ImageDataBunch.from_folder`](/vision.data.html#ImageDataBunch.from_folder):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tfms = get_transforms(do_flip=False)\n", "data = ImageDataBunch.from_folder(path, ds_tfms=tfms, size=24)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here the datasets will be automatically created in the structure of *Imagenet-style folders*. The parameters specified:\n", "- the transforms to apply to the images in `ds_tfms` (here with `do_flip`=False because we don't want to flip numbers),\n", "- the target `size` of our pictures (here 24).\n", "\n", "As with all [`DataBunch`](/basic_data.html#DataBunch) usage, a `train_dl` and a `valid_dl` are created that are of the type PyTorch [`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader). \n", "\n", "If you want to have a look at a few images inside a batch, you can use [`DataBunch.show_batch`](/basic_data.html#DataBunch.show_batch). The `rows` argument is the number of rows and columns to display." ] }, { "cell_type": "code", "execution_count": null, "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jglXRsGHDPGt5pfsiaBeObm2Ybt20jtRrWaj/djrqqqO8s2bNSrg+LSVnz55d1v8UlEE/F5q11M4FfT9oN+Htt9/u+ZJLLvGs76vdu3d7njlzpmfd5k+/p6J4IgWAQDSkABAop6X9li1bPGuZrxNntTzX0l4n565du9bzqlWrPGsZrbtxf/LJJ5514rB+v1niKKSWCFq26qillvN6oNb06dM9r1y50vM333xjxeTWW2/1rOuxded0La90hF2zdoXov5GWch06dPCsB7PpjA/tFjBLfM9Q2hcencFhlrgoZ8KECZ51qz7tztH7/9Zbb3l++OGHPetpFiF4IgWAQDSkABAop6W9lu16zrRO/tXH8XSTaF9//XXPDz30kGddK18eyRPtu3Xr5llH93WUWEctly9f7lknf8+fP99zMU8EHzVqlGe9b4sXL/aso+q6G7mW8zoRWkeCdXaGlnna7TJy5EjPOhPELHFBh3YTsOdB1XXKKad41tk8ZmZjx471/MMf/tCzfo71s6rdbU899ZRnPcs+U3giBYBANKQAECinpb1ud9W2bVvP3//+9z3raL6WiwsWLPCsj+w6+ltRyQfh6ewB3Z1fR4N1nbeWCFrOF/M6erVhwwbPWsJPnjzZs46K6kwK7TpJt1BBZ2386Ec/8qwlX8uWLT0nvxd0gr6+98paz43c00Ub+rkbM2ZMwvf17t3bs86eUYsWLfJ89913e9auN33P6CIR7fLRfSHWr19f9v8A44kUAILRkAJAoJyW9p07d/Y8ePBgz0OGDPGs5ZxOon3jjTc8a0kdMsld1+uaJU681wnguvP+xx9/7Fkn+uuIdKn461//6vmFF17wXOEzwWXUVe//uHHjPF911VWedR8Enc2hB6eZmb366quei22fg0KR7iSEXr16eR49erRnLe21+88sfTmvi2xeeuklz9old91113nW2Rx6iJ6+b3XbTl2bnw5PpAAQiIYUAALltLTXXeR1BE7XZutE7blz53rWkfqKTrxPJ7m012vSEX0dbdZRQS3nc72lWFUwadKklF/XyfO6f4FuQaijoqeffrrnjh07ek43Uq+LObSc17LOLPEQQkr73NFyXrtq9DDLiy++2HP//v0964i6/p6y6HvpzjvvrNjFpqHvF+3mS4cnUgAIREMKAIHydvidjpDrWus333zTs05y37hxY0auQUcC9ZA2s8RD63TNrh5ap6P2mbqmYqAjqkOHDvWsa6d19oOWS2effbZnPbxMS7avvvrKs96Pp59+2rPudo6qQSe868GWWtqnG40vL+0C0L0t9AQM7XrThT66zaN2K+j3fPrpp561G1LxRAoAgWhIASAQDSkABMppH6lObdEjIrQPYsqUKZ515VCmphdpv+iAAQMS/k77bXUDg/fee8/zsmXLPOs0nFKkq0V0FZL2NesmNDr9SftLNevmImrr1q2etZ9a3zvJm9BovypyRz87uvJQNw7RsQptC8raK1b/7tlnn/Ws09x0UyHt59QxD33tK664wnPz5s096/vtscce86wbLCmeSAEgEA0pAATKaWmvpz/q6iSdwqJ7/2VjtZBOu9FTCc0SS0PdU1S7GCq6IUcxu/nmmz1rOa8rm8qzOkWnv+lKGC35dfXT+PHjPbdu3dqzbpxixnSoqmD//v2etRzXMl/fL1qaa07+s25Wk64LR7uS9HOv71XNOl1KT5195513Uv5+xRMpAASiIQWAQDkt7Z944gnPWnbpY75uEJINZW1eoasitm/f7lnLfI6pOK5Ro0aedYWIlvM6oqqnruqxIHrP0600OeOMMzzr5jfDhw/3nLwJjXbd/OMf/0j5esgu/UytXbs2Zc4W3bdWZ5VcdtllnnVWwWuvveZZTyfWrqd0eCIFgEA0pAAQKKel/dKlSz2vW7fOs47AZUO3bt0860mhWjqaJY4Kvv766551hkEp7juaji6e0H9LnfCsI55a2mvXSbpRex2R1/eOTuDW8k3LfzOzJk2aeNaRXT3CRktMum0Kky7i0Ht+5ZVXev7FL37hWWeD6D7HjzzyiOfFixdX6Bp4IgWAQDSkABAop6W9TnjVnG3pynldf2uWuIZ72rRpnnWEmfLvuHvvvdezLmY499xzPb/99tuedQS3PFasWOF51qxZnnVPBF37PGbMmISf1y6Aa665xrOuwT506JDnTB1hU4q0XNbuFl2Eo+vXV69eXeHX0NNmda9avc86i+Pyyy/3rF1yejxNukUCFT2ahidSAAhEQwoAgXJa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/0+eff95z8mkUun3mwIEDPWuZr3th6O9dtmyZ55kzZ6b8/hA8kQJAIBpSAAgUZWPXaQAoJTyRAkAgGlIACERDCgCBaEgBIBANKQAEoiEFgEA0pAAQiIYUAALRkAJAIBpSAAhEQwoAgWhIASAQDSkABKIhBYBANKQAEIiGFAAC0ZACQCAaUgAIREMKAIFoSAEgEA0pAASiIQWAQDSkABDofwHIWK/BesWovwAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "data.show_batch(rows=3, figsize=(5,5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The second way to define the data for a classifier requires a structure like this:\n", "```\n", "path\\\n", " train\\\n", " test\\\n", " labels.csv\n", "```\n", "where the labels.csv file defines the label(s) of each image in the training set. This is the format you will need to use when each image can have multiple labels. It also works with single labels:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namelabel
0train/3/7463.png0
1train/3/21102.png0
2train/3/31559.png0
3train/3/46882.png0
4train/3/26209.png0
\n", "
" ], "text/plain": [ " name label\n", "0 train/3/7463.png 0\n", "1 train/3/21102.png 0\n", "2 train/3/31559.png 0\n", "3 train/3/46882.png 0\n", "4 train/3/26209.png 0" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.read_csv(path/'labels.csv').head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can then use [`ImageDataBunch.from_csv`](/vision.data.html#ImageDataBunch.from_csv):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_csv(path, ds_tfms=tfms, size=28)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVIAAAFgCAYAAADpZ/FJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3VmQVdX1x/HvEVSQQcURBxAEHEBAnEElDohTnNAkGpOYBJPKHCtDJRWTh39MpVJJTCrDQypxJHFIHAiC8wgqgmhERBFQxAEFBxwAFdD7f8C1zjr0pbvpfbtv33t/nxd2rW66T/e5d/feZ+29dlYqlRARkbbbotoXICJS69SRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpKoITvSLMv6ZFl2c5Zlq7MsW5pl2XnVviZpO93P+pJl2bezLJuTZdmHWZZdWe3raY2u1b6AKvkrsBbYBRgJTMuybG6pVJpf3cuSNtL9rC/LgEuA8UD3Kl9Lq2SNtrMpy7IewEpgWKlUWvhJbBLwSqlU+klVL042m+5n/cqy7BJgj1KpdEG1r6UljTi1HwJ8ZG+6T8wFhlbpeiSN7qdUXSN2pD2BdzaKvQP0qsK1SDrdT6m6RuxIVwG9N4r1Bt6rwrVIOt1PqbpG7EgXAl2zLBscYiMAJSZqk+6nVF3DdaSlUmk1cBPwf1mW9ciybAxwOjCpulcmbaH7WX+yLOuaZVk3oAvQJcuyblmWdeoVRg3XkX7im2xYVrECuBb4hpbK1DTdz/pyMfA+8BPg/E/aF1f1ilrQcMufREQqrVFHpCIiFaOOVEQkkTpSEZFE6khFRBJ16JKCLMuU2WpBqVTKqn0NraX72TLdz/qyqfupEamISCJ1pCIiidSRiogkUkcqIpKoU+9fFQHo0qWLt7feemsAunfPC6dbe926dR5bsWKFt7V7r2NtsUU+PrN79/HHH3ss3g/73K5d867I7uNHH33UrtdZSRqRiogkUkcqIpKo7qf23bp1A4pTwd69N9QB3mGHHTzWq1deUH3PPfcEoE+fPh576aWXvP3BBx8A8PLLL3vsueeeA+D999/3mKaUlbHtttt6e6eddgKK92v48OEADBo0yGNr16719vTp0wF48803Pfbiiy96+513NhTYj9PPRrfNNtsA+e8bYOeddwaKr3F7fwG8/fbbQP74BWD33XcHYOXKlR5777285rZ9rn1tgP79+wNw9913e8zuEcCOO+7YJDZgwIAmnxuvfc6cOU2uvZI0IhURSdTpR6TxwfWWW24JFP8K2l/Ovfbay2MjR470ds+ePQv/Auyyyy4A7Lvvvh6LCY2+ffsCxZHQs88+620b7cS/rEuXLgXgsssu89jChfl5bO31l7ARDB6cF78/5ZRTANh///091qNHDyAfyUDxftr9jqOiadOmeXvBggVAcYSzfv36ilx7rRo1ahQAEyZM8JjN4N59912PxSTRq6++CuTvSYBjjjkGgLfeestjH374obfHjRvX5Hvb++rrX/+6x5YvX+5tmxHG2Pbbb+9tu8/xNfL73/8egBkzZngs3u9UGpGKiCRSRyoikqhTTe3twfN2223nMZuWQf7gep999vHYHnvsAcDAgQM9NmTIEG/btC9O7S1REaclLTn88MObxOK6xVWrVgH5tANgypQp3n7wwQdb/b2kaNddd/W23dsDDzzQY3ZvY3IwTh+PP/54oDiVi4+H7N5YQgLy5GKjJgzt93zuued6LE6fWyvLNtT42Jzfo32f2A+09vts6nvZ47qf/vSnHrv55ptb/fVbohGpiEgidaQiIomqNrW3dZ1xOmaZ95NPPtljlj0E2G233QDYe++9PRanaK3V0nTD1hvGbYZxzamtebNVBJBPRw444ACPPfnkk97W1L7t4j22e3PllVd6zKbhw4YN85itNYT88VDM/n/rW9/y9lFHHQXA5Zdf7rFbbrkFKK4VbiT2+4vvz1p+zGHrTK0PqTSNSEVEEnXoiDSOLA455BAAPve5z3ns0EMPBYprQm0XUhSTBjZiiLG4vvOZZ54BYP78/JhzW+/2xhtveCyuc7MdGrFoQnxI/Z3vfKfJNdlf6/hX2xJQkK+tW7NmTZP/K82bOXOmt21HUkwmWeypp57yWFy3a8lFW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+EDA+lrHHLfF90xK7n/F7x2m+rYyJK3Xam0akIiKJOuWINI704lpMK41miQDI1/PZQ2uAPffc09uWbIrJIhuxxjVy5YqaRHFUY9d37LHHeuykk04C8t1XAI8++qi3bQ3i448/7rFKjZbrXby3dtDd8ccf7zErUNLSqCbe71j0xO7J5MmTPWYj0jgTqXdxh52NzuPvtG/fvgDstttuHosFhJobibZ08GBbxATUYYcd5m0rXqMRqYhIDVFHKiKSqFNN7W3NWqxmf9xxx3n7Rz/6EQDXX3+9x2wKEguM7L777t62qVmsJfniiy8C8PTTT3ssbhG1aX6c1sR6paNHjwbgoosu8pg9Lrjqqqs89uCDD3r7mWeeATSdb624HveYY47xtiWW7OQDyNfzxuReXCts9zMWqbEapgB33303APfcc4/H7DXSSOI26/POOw8oPmb70pe+BMD3v/99j8XtmDbVjrV7bfvupg4jbCkx1Vpxu3e5+rLtTSNSEZFEnWpEan9J4o6EWIzAypidffbZHrPdQXHEGUe0ZuLEid620eftt9/uMVueBPloJC6viMVITj311ML1AnznO98BikVJYmGLcsUdpCkraGGjfoDzzz/f24cccghQHH3a7zYmDOOI0pblzJ4922NXX321t+fPnw/o3K1y4gzqiiuuAIq7veKI0hI+do8gnx3G3225pYQtxeJuqSuvvBIozlrKFTXpSBqRiogkUkcqIpKoU03tbRoRpxOxVqdN+7773e96zHZZxGldTDTYMD8+7LY6h7HqfdwpY7sk4nQkJptsWvnf//7XY7a2VcfzprHHNrEASZwq2r2LxTSsWEasQ/urX/3K2zZFjOskY7ENVbtvHXvdx8dtkT1O+c9//tOu12GPzOLUPu5sjO2OohGpiEgidaQiIok61dS+nFgj0uoM2rZPyNcYxkIIsU7o0KFDgeLxBrb2LT4OiFn5cuL0z7KGMesfM/zSOvbYpV+/fh6zdcOxMIatRYR8DWJ8VGOPU+KW3IceesjblvGt1JpFqS7rE+L9jCtoytWabW8akYqIJOr0I9I4arSH3PFhtu0eip8XR49W0CIWMrERayx0EHdQWbIrjnpisRGrlB7Xniph0TpxV4sVI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LzJx77rlAfggelE8sxbWhth44nmt/zTXXeHvBggWply1VFtd8l3s0F9cVW7LpN7/5jcdsO3h71RjWiFREJFGnH5HGpIItibEEEsAdd9wB5EfugkahnVk8k2ns2LEATJw40WN2j2PBiciWubz66qsesxKINhIBWLx4sbfXrFmTetlSZXGWaUsav/Wtb5X93OHDhwPFpJOKloiIdHLqSEVEEmU6WlhEJI1GpCIiidSRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpJIHamISCJ1pCIiidSRiogkUkcqIpLo/wFBVhwORz8H+AAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "data.show_batch(rows=3, figsize=(5,5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "An example of multiclassification can be downloaded with the following cell. It's a sample of the [planet dataset](https://www.google.com/search?q=kaggle+planet&rlz=1C1CHBF_enFR786FR786&oq=kaggle+planet&aqs=chrome..69i57j0.1563j0j7&sourceid=chrome&ie=UTF-8)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "planet = untar_data(URLs.PLANET_SAMPLE)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we open the labels files, we seach that each image has one or more tags, separated by a space." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
image_nametags
0train_21983partly_cloudy primary
1train_9516clear cultivation primary water
2train_12664haze primary
3train_36960clear primary
4train_5302haze primary road
\n", "
" ], "text/plain": [ " image_name tags\n", "0 train_21983 partly_cloudy primary\n", "1 train_9516 clear cultivation primary water\n", "2 train_12664 haze primary\n", "3 train_36960 clear primary\n", "4 train_5302 haze primary road" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(planet/'labels.csv')\n", "df.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_csv(planet, folder='train', size=128, suffix='.jpg', label_delim=' ',\n", " ds_tfms=get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.05, max_warp=0.))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `show_batch`method will then print all the labels that correspond to each image." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.show_batch(rows=3, figsize=(10,8), ds_type=DatasetType.Valid)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can find more ways to build an [`ImageDataBunch`](/vision.data.html#ImageDataBunch) without the factory methods in [`data_block`](/data_block.html#data_block)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class ImageDataBunch[source][test]

\n", "\n", "> ImageDataBunch(**`train_dl`**:[`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader), **`valid_dl`**:[`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader), **`fix_dl`**:[`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader)=***`None`***, **`test_dl`**:`Optional`\\[[`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader)\\]=***`None`***, **`device`**:[`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch-device)=***`None`***, **`dl_tfms`**:`Optional`\\[`Collection`\\[`Callable`\\]\\]=***`None`***, **`path`**:`PathOrStr`=***`'.'`***, **`collate_fn`**:`Callable`=***`'data_collate'`***, **`no_check`**:`bool`=***`False`***) :: [`DataBunch`](/basic_data.html#DataBunch)\n", "\n", "
×

Tests found for ImageDataBunch:

Some other tests where ImageDataBunch is used:

  • pytest -sv tests/test_vision_data.py::test_clean_tear_down [source]
  • pytest -sv tests/test_vision_data.py::test_denormalize [source]
  • pytest -sv tests/test_vision_data.py::test_from_csv_and_from_df [source]
  • pytest -sv tests/test_vision_data.py::test_from_folder [source]
  • pytest -sv tests/test_vision_data.py::test_from_lists [source]
  • pytest -sv tests/test_vision_data.py::test_from_name_re [source]
  • pytest -sv tests/test_vision_data.py::test_image_resize [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter_broken [source]
  • pytest -sv tests/test_vision_data.py::test_normalize [source]
  • pytest -sv tests/test_vision_data.py::test_path_can_be_str_type [source]

To run tests please refer to this guide.

\n", "\n", "DataBunch suitable for computer vision. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is the same initialization as a regular [`DataBunch`](/basic_data.html#DataBunch) so you probably don't want to use this directly, but one of the factory methods instead." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Factory methods" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you quickly want to get a [`ImageDataBunch`](/vision.data.html#ImageDataBunch) and train a model, you should process your data to have it in one of the formats the following functions handle. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_folder[source][test]

\n", "\n", "> from_folder(**`path`**:`PathOrStr`, **`train`**:`PathOrStr`=***`'train'`***, **`valid`**:`PathOrStr`=***`'valid'`***, **`valid_pct`**=***`None`***, **`classes`**:`Collection`\\[`T_co`\\]=***`None`***, **\\*\\*`kwargs`**:`Any`) → `ImageDataBunch`\n", "\n", "
×

Tests found for from_folder:

  • pytest -sv tests/test_vision_data.py::test_from_folder [source]

Some other tests where from_folder is used:

  • pytest -sv tests/test_vision_data.py::test_camvid [source]
  • pytest -sv tests/test_vision_data.py::test_clean_tear_down [source]
  • pytest -sv tests/test_vision_data.py::test_coco [source]
  • pytest -sv tests/test_vision_data.py::test_coco_pickle [source]
  • pytest -sv tests/test_vision_data.py::test_coco_same_size [source]
  • pytest -sv tests/test_vision_data.py::test_denormalize [source]
  • pytest -sv tests/test_vision_data.py::test_image_resize [source]
  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_tfms [source]
  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_y_size [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter_broken [source]
  • pytest -sv tests/test_vision_data.py::test_normalize [source]
  • pytest -sv tests/test_vision_data.py::test_points [source]
  • pytest -sv tests/test_vision_data.py::test_vision_datasets [source]

To run tests please refer to this guide.

\n", "\n", "Create from imagenet style dataset in `path` with `train`,`valid`,`test` subfolders (or provide `valid_pct`). " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_folder)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "\"*Imagenet-style*\" datasets look something like this (note that the test folder is optional):\n", "\n", "```\n", "path\\\n", " train\\\n", " clas1\\\n", " clas2\\\n", " ...\n", " valid\\\n", " clas1\\\n", " clas2\\\n", " ...\n", " test\\\n", "```\n", "\n", "For example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_folder(path, ds_tfms=tfms, size=24)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that this (and all factory methods in this section) pass any `kwargs` to [`DataBunch.create`](/basic_data.html#DataBunch.create)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_csv[source][test]

\n", "\n", "> from_csv(**`path`**:`PathOrStr`, **`folder`**:`PathOrStr`=***`None`***, **`label_delim`**:`str`=***`None`***, **`csv_labels`**:`PathOrStr`=***`'labels.csv'`***, **`valid_pct`**:`float`=***`0.2`***, **`fn_col`**:`int`=***`0`***, **`label_col`**:`int`=***`1`***, **`suffix`**:`str`=***`''`***, **`delimiter`**:`str`=***`None`***, **`header`**:`Union`\\[`int`, `str`, `NoneType`\\]=***`'infer'`***, **\\*\\*`kwargs`**:`Any`) → `ImageDataBunch`\n", "\n", "
×

Tests found for from_csv:

  • pytest -sv tests/test_vision_data.py::test_from_csv_and_from_df [source]
  • pytest -sv tests/test_vision_data.py::test_path_can_be_str_type [source]

Some other tests where from_csv is used:

  • pytest -sv tests/test_vision_data.py::test_multi [source]

To run tests please refer to this guide.

\n", "\n", "Create from a csv file in `path/csv_labels`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_csv)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "Create an [`ImageDataBunch`](/vision.data.html#ImageDataBunch) from `path` by splitting the data in `folder` and labelled in a file `csv_labels` between a training and validation set. Use `valid_pct` to indicate the percentage of the total images to use as the validation set. An optional `test` folder contains unlabelled data and `suffix` contains an optional suffix to add to the filenames in `csv_labels` (such as '.jpg'). `fn_col` is the index (or the name) of the the column containing the filenames and `label_col` is the index (indices) (or the name(s)) of the column(s) containing the labels. Use [`header`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html#pandas-read-csv) to specify the format of the csv header, and `delimiter` to specify a non-standard csv-field separator. In case your csv has no header, column parameters can only be specified as indices. If `label_delim` is passed, split what's in the label column according to that separator.\n", "\n", "For example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_csv(path, ds_tfms=tfms, size=24);" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_df[source][test]

\n", "\n", "> from_df(**`path`**:`PathOrStr`, **`df`**:`DataFrame`, **`folder`**:`PathOrStr`=***`None`***, **`label_delim`**:`str`=***`None`***, **`valid_pct`**:`float`=***`0.2`***, **`fn_col`**:`IntsOrStrs`=***`0`***, **`label_col`**:`IntsOrStrs`=***`1`***, **`suffix`**:`str`=***`''`***, **\\*\\*`kwargs`**:`Any`) → `ImageDataBunch`\n", "\n", "
×

Tests found for from_df:

  • pytest -sv tests/test_vision_data.py::test_from_csv_and_from_df [source]

To run tests please refer to this guide.

\n", "\n", "Create from a `DataFrame` `df`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_df)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "Same as [`ImageDataBunch.from_csv`](/vision.data.html#ImageDataBunch.from_csv), but passing in a `DataFrame` instead of a csv file. e.g" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namelabel
0train/3/7463.png0
1train/3/21102.png0
2train/3/31559.png0
3train/3/46882.png0
4train/3/26209.png0
\n", "
" ], "text/plain": [ " name label\n", "0 train/3/7463.png 0\n", "1 train/3/21102.png 0\n", "2 train/3/31559.png 0\n", "3 train/3/46882.png 0\n", "4 train/3/26209.png 0" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(path/'labels.csv', header='infer')\n", "df.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_df(path, df, ds_tfms=tfms, size=24)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Different datasets are labeled in many different ways. The following methods can help extract the labels from the dataset in a wide variety of situations. The way they are built in fastai is constructive: there are methods which do a lot for you but apply in specific circumstances and there are methods which do less for you but give you more flexibility.\n", "\n", "In this case the hierarchy is:\n", "\n", "1. [`ImageDataBunch.from_name_re`](/vision.data.html#ImageDataBunch.from_name_re): Gets the labels from the filenames using a regular expression\n", "2. [`ImageDataBunch.from_name_func`](/vision.data.html#ImageDataBunch.from_name_func): Gets the labels from the filenames using any function\n", "3. [`ImageDataBunch.from_lists`](/vision.data.html#ImageDataBunch.from_lists): Labels need to be provided as an input in a list" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_name_re[source][test]

\n", "\n", "> from_name_re(**`path`**:`PathOrStr`, **`fnames`**:`FilePathList`, **`pat`**:`str`, **`valid_pct`**:`float`=***`0.2`***, **\\*\\*`kwargs`**)\n", "\n", "
×

Tests found for from_name_re:

  • pytest -sv tests/test_vision_data.py::test_from_name_re [source]
  • pytest -sv tests/test_vision_data.py::test_image_resize [source]

To run tests please refer to this guide.

\n", "\n", "Create from list of `fnames` in `path` with re expression `pat`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_name_re)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "Creates an [`ImageDataBunch`](/vision.data.html#ImageDataBunch) from `fnames`, calling a regular expression (containing one *re group*) on the file names to get the labels, putting aside `valid_pct` for the validation. In the same way as [`ImageDataBunch.from_csv`](/vision.data.html#ImageDataBunch.from_csv), an optional `test` folder contains unlabelled data.\n", "\n", "Our previously created dataframe contains the labels in the filenames so we can leverage it to test this new method. [`ImageDataBunch.from_name_re`](/vision.data.html#ImageDataBunch.from_name_re) needs the exact path of each file so we will append the data path to each filename before creating our [`ImageDataBunch`](/vision.data.html#ImageDataBunch) object." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[PosixPath('/home/ubuntu/.fastai/data/mnist_sample/train/3/7463.png'),\n", " PosixPath('/home/ubuntu/.fastai/data/mnist_sample/train/3/21102.png')]" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fn_paths = [path/name for name in df['name']]; fn_paths[:2]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pat = r\"/(\\d)/\\d+\\.png$\"\n", "data = ImageDataBunch.from_name_re(path, fn_paths, pat=pat, ds_tfms=tfms, size=24)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['3', '7']" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.classes" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_name_func[source][test]

\n", "\n", "> from_name_func(**`path`**:`PathOrStr`, **`fnames`**:`FilePathList`, **`label_func`**:`Callable`, **`valid_pct`**:`float`=***`0.2`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for from_name_func. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Create from list of `fnames` in `path` with `label_func`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_name_func)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "Works in the same way as [`ImageDataBunch.from_name_re`](/vision.data.html#ImageDataBunch.from_name_re), but instead of a regular expression it expects a function that will determine how to extract the labels from the filenames. (Note that `from_name_re` uses this function in its implementation).\n", "\n", "To test it we could build a function with our previous regex. Let's try another, similar approach to show that the labels can be obtained in a different way." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['3', '7']" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def get_labels(file_path): return '3' if '/3/' in str(file_path) else '7'\n", "data = ImageDataBunch.from_name_func(path, fn_paths, label_func=get_labels, ds_tfms=tfms, size=24)\n", "data.classes" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_lists[source][test]

\n", "\n", "> from_lists(**`path`**:`PathOrStr`, **`fnames`**:`FilePathList`, **`labels`**:`StrList`, **`valid_pct`**:`float`=***`0.2`***, **`item_cls`**:`Callable`=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

Tests found for from_lists:

  • pytest -sv tests/test_vision_data.py::test_from_lists [source]

To run tests please refer to this guide.

\n", "\n", "Create from list of `fnames` in `path`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.from_lists)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Refer to [`create_from_ll`](#ImageDataBunch.create_from_ll) to see all the `**kwargs` arguments.\n", "\n", "The most flexible factory function; pass in a list of `labels` that correspond to each of the filenames in `fnames`.\n", "\n", "To show an example we have to build the labels list outside our [`ImageDataBunch`](/vision.data.html#ImageDataBunch) object and give it as an argument when we call `from_lists`. Let's use our previously created function to create our labels list." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['3', '7']" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "labels_ls = list(map(get_labels, fn_paths))\n", "data = ImageDataBunch.from_lists(path, fn_paths, labels=labels_ls, ds_tfms=tfms, size=24)\n", "data.classes" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

create_from_ll[source][test]

\n", "\n", "> create_from_ll(**`lls`**:[`LabelLists`](/data_block.html#LabelLists), **`bs`**:`int`=***`64`***, **`val_bs`**:`int`=***`None`***, **`ds_tfms`**:`Union`\\[`Callable`, `Collection`\\[`Callable`\\], `NoneType`\\]=***`None`***, **`num_workers`**:`int`=***`4`***, **`dl_tfms`**:`Optional`\\[`Collection`\\[`Callable`\\]\\]=***`None`***, **`device`**:[`device`](https://pytorch.org/docs/stable/tensor_attributes.html#torch-device)=***`None`***, **`test`**:`Union`\\[`Path`, `str`, `NoneType`\\]=***`None`***, **`collate_fn`**:`Callable`=***`'data_collate'`***, **`size`**:`int`=***`None`***, **`no_check`**:`bool`=***`False`***, **`resize_method`**:[`ResizeMethod`](/vision.image.html#ResizeMethod)=***`None`***, **`mult`**:`int`=***`None`***, **`padding_mode`**:`str`=***`'reflection'`***, **`mode`**:`str`=***`'bilinear'`***, **`tfm_y`**:`bool`=***`False`***) → `ImageDataBunch`\n", "\n", "
×

No tests found for create_from_ll. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Create an [`ImageDataBunch`](/vision.data.html#ImageDataBunch) from [`LabelLists`](/data_block.html#LabelLists) `lls` with potential `ds_tfms`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.create_from_ll)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use `bs`, `num_workers`, `collate_fn` and a potential `test` folder. `ds_tfms` is a tuple of two lists of transforms to be applied to the training and the validation (plus test optionally) set. `tfms` are the transforms to apply to the [`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader). The `size` and the `kwargs` are passed to the transforms for data augmentation." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

single_from_classes[source][test]

\n", "\n", "> single_from_classes(**`path`**:`PathOrStr`, **`classes`**:`StrList`, **`ds_tfms`**:`Union`\\[`Callable`, `Collection`\\[`Callable`\\]\\]=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for single_from_classes. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Create an empty [`ImageDataBunch`](/vision.data.html#ImageDataBunch) in `path` with `classes`. Typically used for inference. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.single_from_classes)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
Note: This method is deprecated, you should use DataBunch.load_empty now.
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "jekyll_note('This method is deprecated, you should use DataBunch.load_empty now.')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Other methods" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the next few methods we will use another dataset, CIFAR. This is because the second method will get the statistics for our dataset and we want to be able to show different statistics per channel. If we were to use MNIST, these statistics would be the same for every channel. White pixels are [255,255,255] and black pixels are [0,0,0] (or in normalized form [1,1,1] and [0,0,0]) so there is no variance between channels." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PosixPath('/home/ubuntu/.fastai/data/cifar10')" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path = untar_data(URLs.CIFAR); path" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

channel_view[source][test]

\n", "\n", "> channel_view(**`x`**:`Tensor`) → `Tensor`\n", "\n", "
×

No tests found for channel_view. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Make channel the first axis of `x` and flatten remaining axes " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(channel_view)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = ImageDataBunch.from_folder(path, ds_tfms=tfms, valid='test', size=24)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def channel_view(x:Tensor)->Tensor:\n", " \"Make channel the first axis of `x` and flatten remaining axes\"\n", " return x.transpose(0,1).contiguous().view(x.shape[1],-1) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This function takes a tensor and flattens all dimensions except the channels, which it keeps as the first axis. This function is used to feed [`ImageDataBunch.batch_stats`](/vision.data.html#ImageDataBunch.batch_stats) so that it can get the pixel statistics of a whole batch.\n", "\n", "Let's take as an example the dimensions our MNIST batches: 128, 3, 24, 24." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t = torch.Tensor(128, 3, 24, 24)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "torch.Size([128, 3, 24, 24])" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "t.size()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tensor = channel_view(t)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "torch.Size([3, 73728])" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tensor.size()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

batch_stats[source][test]

\n", "\n", "> batch_stats(**`funcs`**:`Collection`\\[`Callable`\\]=***`None`***, **`ds_type`**:[`DatasetType`](/basic_data.html#DatasetType)=***``***) → `Tensor`\n", "\n", "
×

No tests found for batch_stats. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Grab a batch of data and call reduction function `func` per channel " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.batch_stats)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[tensor([0.4928, 0.4767, 0.4671]), tensor([0.2677, 0.2631, 0.2630])]" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.batch_stats()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

normalize[source][test]

\n", "\n", "> normalize(**`stats`**:`Collection`\\[`Tensor`\\]=***`None`***, **`do_x`**:`bool`=***`True`***, **`do_y`**:`bool`=***`False`***)\n", "\n", "
×

Tests found for normalize:

  • pytest -sv tests/test_vision_data.py::test_normalize [source]

Some other tests where normalize is used:

  • pytest -sv tests/test_vision_data.py::test_clean_tear_down [source]
  • pytest -sv tests/test_vision_data.py::test_denormalize [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter [source]

To run tests please refer to this guide.

\n", "\n", "Add normalize transform using `stats` (defaults to `DataBunch.batch_stats`) " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageDataBunch.normalize)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the fast.ai library we have `imagenet_stats`, `cifar_stats` and `mnist_stats` so we can add normalization easily with any of these datasets. Let's see an example with our dataset of choice: MNIST." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "ImageDataBunch;\n", "\n", "Train: LabelList\n", "y: CategoryList (50000 items)\n", "[Category truck, Category truck, Category truck, Category truck, Category truck]...\n", "Path: /home/ubuntu/.fastai/data/cifar10\n", "x: ImageList (50000 items)\n", "[Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32)]...\n", "Path: /home/ubuntu/.fastai/data/cifar10;\n", "\n", "Valid: LabelList\n", "y: CategoryList (10000 items)\n", "[Category truck, Category truck, Category truck, Category truck, Category truck]...\n", "Path: /home/ubuntu/.fastai/data/cifar10\n", "x: ImageList (10000 items)\n", "[Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32), Image (3, 32, 32)]...\n", "Path: /home/ubuntu/.fastai/data/cifar10;\n", "\n", "Test: None" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.normalize(cifar_stats)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[tensor([ 0.0074, -0.0219, 0.0769]), tensor([1.0836, 1.0829, 1.0078])]" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.batch_stats()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data normalization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You may also want to normalize your data, which can be done by using the following functions." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

normalize[source][test]

\n", "\n", "> normalize(**`x`**:`Tensor`, **`mean`**:`FloatTensor`, **`std`**:`FloatTensor`) → `Tensor`\n", "\n", "
×

Tests found for normalize:

Some other tests where normalize is used:

  • pytest -sv tests/test_vision_data.py::test_clean_tear_down [source]
  • pytest -sv tests/test_vision_data.py::test_denormalize [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter [source]
  • pytest -sv tests/test_vision_data.py::test_normalize [source]

To run tests please refer to this guide.

\n", "\n", "Normalize `x` with `mean` and `std`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(normalize)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

denormalize[source][test]

\n", "\n", "> denormalize(**`x`**:`Tensor`, **`mean`**:`FloatTensor`, **`std`**:`FloatTensor`, **`do_x`**:`bool`=***`True`***) → `Tensor`\n", "\n", "
×

Tests found for denormalize:

  • pytest -sv tests/test_vision_data.py::test_denormalize [source]

To run tests please refer to this guide.

\n", "\n", "Denormalize `x` with `mean` and `std`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(denormalize)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

normalize_funcs[source][test]

\n", "\n", "> normalize_funcs(**`mean`**:`FloatTensor`, **`std`**:`FloatTensor`, **`do_x`**:`bool`=***`True`***, **`do_y`**:`bool`=***`False`***) → `Tuple`\\[`Callable`, `Callable`\\]\n", "\n", "
×

No tests found for normalize_funcs. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Create normalize/denormalize func using `mean` and `std`, can specify `do_y` and `device`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(normalize_funcs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On MNIST the mean and std are 0.1307 and 0.3081 respectively (looked on Google). If you're using a pretrained model, you'll need to use the normalization that was used to train the model. The imagenet norm and denorm functions are stored as constants inside the library named imagenet_norm and imagenet_denorm. If you're training a model on CIFAR-10, you can also use cifar_norm and cifar_denorm.\n", "\n", "You may sometimes see warnings about *clipping input data* when plotting normalized data. That's because even although it's denormalized when plotting automatically, sometimes floating point errors may make some values slightly out or the correct range. You can safely ignore these warnings in this case." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAAGoCAYAAAB/tCPFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3XmQldWZx/HnyL43q+z7JiCLgCgOi4CA6LiTwGQkidGUmcRkkkpSmamZyViZqpnEKVNlJkbjlEmMKUejGCFggcquRhZZBEH2Nc2O0Cyy+c4fE2t8fm97b9/uPn1vd38/Vf7xo7vvPen79n3ynueec0KSJAYAQCxX5HsAAICajUIDAIiKQgMAiIpCAwCIikIDAIiKQgMAiIpCAwCIikJTBiGEZ0MIxSGEUyGErSGE+/M9JhQurhfkojZcL4EFm9mFEAaa2fYkSc6HEPqb2RIzuyVJkjX5HRkKEdcLclEbr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vUqeNyWdak1a2b25+cTu8pnRrp0aOHy/369XNZ/zfo1JpOvVVnOs24d+9el/ft2+dy3759Xe7QoYPLOrWq01A6ddaoUaOM47tw4YLLH330Uep7xo8f7/IVV/h7gxD8TJVO1+k1nm16t7i42OX169e7vGDBgow//1m4owEAREWhAQBERaEBAERFjwa11rlz51zetcsfBbJ48WKX9aOlOmevuSx0Xv7MmTMuaw9G5+R1zr5hw4Yua4/mG9/4hsuDBw92+ac//WmWEVcf2gPRjyevWrXKZX39evbs6bL21/TjzatXr3a5efPmLmtPr169ei7ra21m1q5dO5e1Z6evvz6mXi+atY+1Z8+ejGMuL+5oAABRUWgAAFFRaAAAUdGjQa2lc/i6huAXv/iFyzqH3qlTJ5evueYal0tbV6P/dvr0aZd1LcYDDzzgcrdu3VzOti5C59jbtm3rsq7T0C1NahL93f/pT39yWftbI0aMcLlZs2Yub9682eVvf/vbLmv/Q3/3ev1oP80svZZHx6h9pcmTJ7usPRsd09y5c11+5JFHXNbfUXlxRwMAiIpCAwCIikIDAIiKHg1qLZ2z157NBx984LKuQdD5cl1HUVqPRtdi6N5jY8eOzfgclbWu4RO6tuTkyZOV+viFTLflX7hwocu6l5lu879o0SKXtcen67R0r7U1a9aUfbB/MWTIEJcfeughl/Wa0zG/+eabLj/33HMur1u3LucxlQV3NACAqCg0AICoKDQAgKjy2qNp3769y71793ZZ5xt1Xyg9Fjfbvj7Z6OMfPXo049dL+zf9nDpqDr0edQ5+9+7dLut8ull6bca1117r8nXXXeey7nWV63k22Wzbts1lPaOlJtPX789//rPLzz//fMaf19c7xt++9uj0vKEpU6a4rD083b9Pz5NZtmyZy6W9x1UG7mgAAFFRaAAAUVFoAABR5bVHM3ToUJcfffRRl3XfJ50T/fDDD13Odp62Zv2M+eHDh11euXJlxq+bpc+k0HUIer6IZu0zleXceeSHXj963oj2X+64447UY4wbN87lPn36uKx7U1W2JUuWuKx7Xb3//vtRn7+Q6N+a/i1q/yoftI89bNgwl1u0aJHx57du3eryW2+95XJ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3s0euZRdcEdDQAgKgoNACAqCg0AICp6NDnQfanMzNq0aeOy7lU1evRol/Wz9KtXr3aZHk3+6HkhrVu3dllf26FDh7rcvHlzl1u2bJl6Dl0Xo32gefPmufzLX/7SZe3J6PlHyJ/27du7PG7cOJdvuOEGl3fs2OGyvvZmZtu3b6+k0eUXdzQAgKgoNACAqCg0AICoqnWPpm5dP/z+/fu7rOsadO8p3XesqKjI5RYtWris57ebpefc9TF0/6J169a5vGjRIpePHj2aeg5UDb1edN3M3/3d37ncoUMHl7WHV9prqa//ggULXF6+fLnLu3fvdpmeTOFo3Lixy8OGDXP5K1/5isunTp1y+ec//7nLr776auo5dF1VdcUdDQAgKgoNACAqCg0AIKpQU+YAAQCFiTsaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFQUGgBAVBQaAEBUFBoAQFT/CxFWnMifWD0bAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "data = ImageDataBunch.from_folder(untar_data(URLs.MNIST_SAMPLE),\n", " ds_tfms=tfms, size=24)\n", "data.normalize()\n", "data.show_batch(rows=3, figsize=(6,6))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_annotations[source][test]

\n", "\n", "> get_annotations(**`fname`**, **`prefix`**=***`None`***)\n", "\n", "
×

Tests found for get_annotations:

Some other tests where get_annotations is used:

  • pytest -sv tests/test_vision_data.py::test_coco [source]
  • pytest -sv tests/test_vision_data.py::test_coco_pickle [source]
  • pytest -sv tests/test_vision_data.py::test_points [source]

To run tests please refer to this guide.

\n", "\n", "Open a COCO style json in `fname` and returns the lists of filenames (with maybe `prefix`) and labelled bboxes. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_annotations)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To use this dataset and collate samples into batches, you'll need to following function:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

bb_pad_collate[source][test]

\n", "\n", "> bb_pad_collate(**`samples`**:`BatchSamples`, **`pad_idx`**:`int`=***`0`***) → `Tuple`\\[`FloatTensor`, `Tuple`\\[`LongTensor`, `LongTensor`\\]\\]\n", "\n", "
×

No tests found for bb_pad_collate. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(bb_pad_collate)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, to apply transformations to [`Image`](/vision.image.html#Image) in a [`Dataset`](https://pytorch.org/docs/stable/data.html#torch.utils.data.Dataset), we use this last class." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ItemList specific to vision" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The vision application adds a few subclasses of [`ItemList`](/data_block.html#ItemList) specific to images." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class ImageList[source][test]

\n", "\n", "> ImageList(**\\*`args`**, **`convert_mode`**=***`'RGB'`***, **`after_open`**:`Callable`=***`None`***, **\\*\\*`kwargs`**) :: [`ItemList`](/data_block.html#ItemList)\n", "\n", "
×

Tests found for ImageList:

Some other tests where ImageList is used:

  • pytest -sv tests/test_vision_data.py::test_image_resize [source]
  • pytest -sv tests/test_vision_data.py::test_multi [source]
  • pytest -sv tests/test_vision_data.py::test_vision_datasets [source]

To run tests please refer to this guide.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) suitable for computer vision. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList, title_level=3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a [`ItemList`](/data_block.html#ItemList) in `path` from filenames in `items`. `create_func` will default to [`open_image`](/vision.image.html#open_image). `label_cls` can be specified for the labels, `xtra` contains any extra information (usually in the form of a dataframe) and `processor` is applied to the [`ItemList`](/data_block.html#ItemList) after splitting and labelling." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_folder[source][test]

\n", "\n", "> from_folder(**`path`**:`PathOrStr`=***`'.'`***, **`extensions`**:`StrList`=***`None`***, **\\*\\*`kwargs`**) → [`ItemList`](/data_block.html#ItemList)\n", "\n", "
×

Tests found for from_folder:

  • pytest -sv tests/test_vision_data.py::test_vision_datasets [source]

Some other tests where from_folder is used:

  • pytest -sv tests/test_vision_data.py::test_camvid [source]
  • pytest -sv tests/test_vision_data.py::test_clean_tear_down [source]
  • pytest -sv tests/test_vision_data.py::test_coco [source]
  • pytest -sv tests/test_vision_data.py::test_coco_pickle [source]
  • pytest -sv tests/test_vision_data.py::test_coco_same_size [source]
  • pytest -sv tests/test_vision_data.py::test_denormalize [source]
  • pytest -sv tests/test_vision_data.py::test_from_folder [source]
  • pytest -sv tests/test_vision_data.py::test_image_resize [source]
  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_tfms [source]
  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_y_size [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter [source]
  • pytest -sv tests/test_vision_data.py::test_multi_iter_broken [source]
  • pytest -sv tests/test_vision_data.py::test_normalize [source]
  • pytest -sv tests/test_vision_data.py::test_points [source]

To run tests please refer to this guide.

\n", "\n", "Get the list of files in `path` that have an image suffix. `recurse` determines if we search subfolders. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.from_folder)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

from_df[source][test]

\n", "\n", "> from_df(**`df`**:`DataFrame`, **`path`**:`PathOrStr`, **`cols`**:`IntsOrStrs`=***`0`***, **`folder`**:`PathOrStr`=***`None`***, **`suffix`**:`str`=***`''`***, **\\*\\*`kwargs`**) → `ItemList`\n", "\n", "
×

Tests found for from_df:

Some other tests where from_df is used:

  • pytest -sv tests/test_vision_data.py::test_from_csv_and_from_df [source]

To run tests please refer to this guide.

\n", "\n", "Get the filenames in `cols` of `df` with `folder` in front of them, `suffix` at the end. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.from_df)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_image_files[source][test]

\n", "\n", "> get_image_files(**`c`**:`PathOrStr`, **`check_ext`**:`bool`=***`True`***, **`recurse`**=***`False`***) → `FilePathList`\n", "\n", "
×

Tests found for get_image_files:

Some other tests where get_image_files is used:

  • pytest -sv tests/test_vision_data.py::test_from_name_re [source]
  • pytest -sv tests/test_vision_data.py::test_image_resize [source]

To run tests please refer to this guide.

\n", "\n", "Return list of files in `c` that are images. `check_ext` will filter to `image_extensions`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_image_files)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

open[source][test]

\n", "\n", "> open(**`fn`**)\n", "\n", "
×

Tests found for open:

Some other tests where open is used:

  • pytest -sv tests/test_vision_data.py::test_download_images [source]
  • pytest -sv tests/test_vision_data.py::test_verify_image [source]
  • pytest -sv tests/test_vision_data.py::test_verify_images [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor_16bit [source]

To run tests please refer to this guide.

\n", "\n", "Open image in `fn`, subclass and overwrite for custom behavior. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.open)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

show_xys[source][test]

\n", "\n", "> show_xys(**`xs`**, **`ys`**, **`imgsize`**:`int`=***`4`***, **`figsize`**:`Optional`\\[`Tuple`\\[`int`, `int`\\]\\]=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for show_xys. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Show the `xs` (inputs) and `ys` (targets) on a figure of `figsize`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.show_xys)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

show_xyzs[source][test]

\n", "\n", "> show_xyzs(**`xs`**, **`ys`**, **`zs`**, **`imgsize`**:`int`=***`4`***, **`figsize`**:`Optional`\\[`Tuple`\\[`int`, `int`\\]\\]=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for show_xyzs. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Show `xs` (inputs), `ys` (targets) and `zs` (predictions) on a figure of `figsize`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.show_xyzs)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class ObjectCategoryList[source][test]

\n", "\n", "> ObjectCategoryList(**`items`**:`Iterator`\\[`T_co`\\], **`classes`**:`Collection`\\[`T_co`\\]=***`None`***, **`label_delim`**:`str`=***`None`***, **`one_hot`**:`bool`=***`False`***, **\\*\\*`kwargs`**) :: [`MultiCategoryList`](/data_block.html#MultiCategoryList)\n", "\n", "
×

No tests found for ObjectCategoryList. To contribute a test please refer to this guide and this discussion.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) for labelled bounding boxes. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ObjectCategoryList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class ObjectItemList[source][test]

\n", "\n", "> ObjectItemList(**\\*`args`**, **`convert_mode`**=***`'RGB'`***, **`after_open`**:`Callable`=***`None`***, **\\*\\*`kwargs`**) :: [`ImageList`](/vision.data.html#ImageList)\n", "\n", "
×

Tests found for ObjectItemList:

  • pytest -sv tests/test_vision_data.py::test_coco [source]
  • pytest -sv tests/test_vision_data.py::test_coco_pickle [source]
  • pytest -sv tests/test_vision_data.py::test_coco_same_size [source]

To run tests please refer to this guide.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) suitable for object detection. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ObjectItemList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class SegmentationItemList[source][test]

\n", "\n", "> SegmentationItemList(**\\*`args`**, **`convert_mode`**=***`'RGB'`***, **`after_open`**:`Callable`=***`None`***, **\\*\\*`kwargs`**) :: [`ImageList`](/vision.data.html#ImageList)\n", "\n", "
×

Tests found for SegmentationItemList:

  • pytest -sv tests/test_vision_data.py::test_camvid [source]

To run tests please refer to this guide.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) suitable for segmentation tasks. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationItemList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class SegmentationLabelList[source][test]

\n", "\n", "> SegmentationLabelList(**`items`**:`Iterator`\\[`T_co`\\], **`classes`**:`Collection`\\[`T_co`\\]=***`None`***, **\\*\\*`kwargs`**) :: [`ImageList`](/vision.data.html#ImageList)\n", "\n", "
×

No tests found for SegmentationLabelList. To contribute a test please refer to this guide and this discussion.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) for segmentation masks. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationLabelList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class PointsLabelList[source][test]

\n", "\n", "> PointsLabelList(**`items`**:`Iterator`\\[`T_co`\\], **`path`**:`PathOrStr`=***`'.'`***, **`label_cls`**:`Callable`=***`None`***, **`inner_df`**:`Any`=***`None`***, **`processor`**:`Union`\\[[`PreProcessor`](/data_block.html#PreProcessor), `Collection`\\[[`PreProcessor`](/data_block.html#PreProcessor)\\]\\]=***`None`***, **`x`**:`ItemList`=***`None`***, **`ignore_empty`**:`bool`=***`False`***) :: [`ItemList`](/data_block.html#ItemList)\n", "\n", "
×

No tests found for PointsLabelList. To contribute a test please refer to this guide and this discussion.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) for points. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsLabelList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class PointsItemList[source][test]

\n", "\n", "> PointsItemList(**\\*`args`**, **`convert_mode`**=***`'RGB'`***, **`after_open`**:`Callable`=***`None`***, **\\*\\*`kwargs`**) :: [`ImageList`](/vision.data.html#ImageList)\n", "\n", "
×

Tests found for PointsItemList:

  • pytest -sv tests/test_vision_data.py::test_points [source]

To run tests please refer to this guide.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) for [`Image`](/vision.image.html#Image) to [`ImagePoints`](/vision.image.html#ImagePoints) tasks. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsItemList, title_level=3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

class ImageImageList[source][test]

\n", "\n", "> ImageImageList(**\\*`args`**, **`convert_mode`**=***`'RGB'`***, **`after_open`**:`Callable`=***`None`***, **\\*\\*`kwargs`**) :: [`ImageList`](/vision.data.html#ImageList)\n", "\n", "
×

Tests found for ImageImageList:

Some other tests where ImageImageList is used:

  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_tfms [source]
  • pytest -sv tests/test_vision_data.py::test_image_to_image_different_y_size [source]

To run tests please refer to this guide.

\n", "\n", "[`ItemList`](/data_block.html#ItemList) suitable for [`Image`](/vision.image.html#Image) to [`Image`](/vision.image.html#Image) tasks. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageImageList, title_level=3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Building your own dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module also contains a few helper functions to allow you to build you own dataset for image classification." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

download_images[source][test]

\n", "\n", "> download_images(**`urls`**:`StrList`, **`dest`**:`PathOrStr`, **`max_pics`**:`int`=***`1000`***, **`max_workers`**:`int`=***`8`***, **`timeout`**=***`4`***)\n", "\n", "
×

Tests found for download_images:

  • pytest -sv tests/test_vision_data.py::test_download_images [source]

To run tests please refer to this guide.

\n", "\n", "Download images listed in text file `urls` to path `dest`, at most `max_pics` " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(download_images)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

verify_images[source][test]

\n", "\n", "> verify_images(**`path`**:`PathOrStr`, **`delete`**:`bool`=***`True`***, **`max_workers`**:`int`=***`4`***, **`max_size`**:`int`=***`None`***, **`recurse`**:`bool`=***`False`***, **`dest`**:`PathOrStr`=***`'.'`***, **`n_channels`**:`int`=***`3`***, **`interp`**=***`2`***, **`ext`**:`str`=***`None`***, **`img_format`**:`str`=***`None`***, **`resume`**:`bool`=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

Tests found for verify_images:

  • pytest -sv tests/test_vision_data.py::test_verify_images [source]

To run tests please refer to this guide.

\n", "\n", "Check if the images in `path` aren't broken, maybe resize them and copy it in `dest`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(verify_images)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It will try if every image in this folder can be opened and has `n_channels`. If `n_channels` is 3 – it'll try to convert image to RGB. If `delete=True`, it'll be removed it this fails. If `resume` – it will skip already existent images in `dest`. If `max_size` is specified, image is resized to the same ratio so that both sizes are less than `max_size`, using `interp`. Result is stored in `dest`, `ext` forces an extension type, `img_format` and `kwargs` are passed to PIL.Image.save. Use `max_workers` CPUs." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Undocumented Methods - Methods moved below this line will intentionally be hidden" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

get[source][test]

\n", "\n", "> get(**`i`**)\n", "\n", "
×

No tests found for get. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Subclass if you want to customize how to create item `i` from `self.items`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsItemList.get)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

new[source][test]

\n", "\n", "> new(**`items`**:`Iterator`\\[`T_co`\\], **`processor`**:`Union`\\[[`PreProcessor`](/data_block.html#PreProcessor), `Collection`\\[[`PreProcessor`](/data_block.html#PreProcessor)\\]\\]=***`None`***, **\\*\\*`kwargs`**) → `ItemList`\n", "\n", "
×

No tests found for new. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Create a new [`ItemList`](/data_block.html#ItemList) from `items`, keeping the same attributes. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationLabelList.new)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

from_csv[source][test]

\n", "\n", "> from_csv(**`path`**:`PathOrStr`, **`csv_name`**:`str`, **`header`**:`str`=***`'infer'`***, **\\*\\*`kwargs`**) → `ItemList`\n", "\n", "
×

Tests found for from_csv:

  • pytest -sv tests/test_vision_data.py::test_multi [source]

Some other tests where from_csv is used:

  • pytest -sv tests/test_vision_data.py::test_from_csv_and_from_df [source]
  • pytest -sv tests/test_vision_data.py::test_path_can_be_str_type [source]

To run tests please refer to this guide.

\n", "\n", "Get the filenames in `path/csv_name` opened with `header`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.from_csv)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

get[source][test]

\n", "\n", "> get(**`i`**)\n", "\n", "
×

No tests found for get. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Subclass if you want to customize how to create item `i` from `self.items`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ObjectCategoryList.get)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

get[source][test]

\n", "\n", "> get(**`i`**)\n", "\n", "
×

No tests found for get. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Subclass if you want to customize how to create item `i` from `self.items`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.get)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

reconstruct[source][test]

\n", "\n", "> reconstruct(**`t`**:`Tensor`)\n", "\n", "
×

No tests found for reconstruct. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Reconstruct one of the underlying item for its data `t`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationLabelList.reconstruct)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

show_xys[source][test]

\n", "\n", "> show_xys(**`xs`**, **`ys`**, **`imgsize`**:`int`=***`4`***, **`figsize`**:`Optional`\\[`Tuple`\\[`int`, `int`\\]\\]=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for show_xys. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Show the `xs` (inputs) and `ys`(targets) on a figure of `figsize`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageImageList.show_xys)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

show_xyzs[source][test]

\n", "\n", "> show_xyzs(**`xs`**, **`ys`**, **`zs`**, **`imgsize`**:`int`=***`4`***, **`figsize`**:`Optional`\\[`Tuple`\\[`int`, `int`\\]\\]=***`None`***, **\\*\\*`kwargs`**)\n", "\n", "
×

No tests found for show_xyzs. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Show `xs` (inputs), `ys` (targets) and `zs` (predictions) on a figure of `figsize`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageImageList.show_xyzs)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

open[source][test]

\n", "\n", "> open(**`fn`**)\n", "\n", "
×

Tests found for open:

Some other tests where open is used:

  • pytest -sv tests/test_vision_data.py::test_download_images [source]
  • pytest -sv tests/test_vision_data.py::test_verify_image [source]
  • pytest -sv tests/test_vision_data.py::test_verify_images [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor_16bit [source]

To run tests please refer to this guide.

\n", "\n", "Open image in `fn`, subclass and overwrite for custom behavior. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.open)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

analyze_pred[source][test]

\n", "\n", "> analyze_pred(**`pred`**:`Tensor`)\n", "\n", "
×

No tests found for analyze_pred. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Called on `pred` before `reconstruct` for additional preprocessing. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsItemList.analyze_pred)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

analyze_pred[source][test]

\n", "\n", "> analyze_pred(**`pred`**, **`thresh`**:`float`=***`0.5`***)\n", "\n", "
×

No tests found for analyze_pred. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Called on `pred` before `reconstruct` for additional preprocessing. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationLabelList.analyze_pred)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

reconstruct[source][test]

\n", "\n", "> reconstruct(**`t`**:`Tensor`)\n", "\n", "
×

No tests found for reconstruct. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Reconstruct one of the underlying item for its data `t`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsItemList.reconstruct)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

open[source][test]

\n", "\n", "> open(**`fn`**)\n", "\n", "
×

Tests found for open:

Some other tests where open is used:

  • pytest -sv tests/test_vision_data.py::test_download_images [source]
  • pytest -sv tests/test_vision_data.py::test_verify_image [source]
  • pytest -sv tests/test_vision_data.py::test_verify_images [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor [source]
  • pytest -sv tests/test_vision_data.py::test_vision_pil2tensor_16bit [source]

To run tests please refer to this guide.

\n", "\n", "Open image in `fn`, subclass and overwrite for custom behavior. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(SegmentationLabelList.open)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

reconstruct[source][test]

\n", "\n", "> reconstruct(**`t`**:`Tensor`)\n", "\n", "
×

No tests found for reconstruct. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Reconstruct one of the underlying item for its data `t`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ImageList.reconstruct)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

resize_to[source][test]

\n", "\n", "> resize_to(**`img`**, **`targ_sz`**:`int`, **`use_min`**:`bool`=***`False`***)\n", "\n", "
×

No tests found for resize_to. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Size to resize to, to hit `targ_sz` at same aspect ratio, in PIL coords (i.e w*h) " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(resize_to)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

reconstruct[source][test]

\n", "\n", "> reconstruct(**`t`**, **`x`**)\n", "\n", "
×

No tests found for reconstruct. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Reconstruct one of the underlying item for its data `t`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ObjectCategoryList.reconstruct)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

reconstruct[source][test]

\n", "\n", "> reconstruct(**`t`**, **`x`**)\n", "\n", "
×

No tests found for reconstruct. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Reconstruct one of the underlying item for its data `t`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsLabelList.reconstruct)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

analyze_pred[source][test]

\n", "\n", "> analyze_pred(**`pred`**, **`thresh`**:`float`=***`0.5`***)\n", "\n", "
×

No tests found for analyze_pred. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Called on `pred` before `reconstruct` for additional preprocessing. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsLabelList.analyze_pred)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "

get[source][test]

\n", "\n", "> get(**`i`**)\n", "\n", "
×

No tests found for get. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Subclass if you want to customize how to create item `i` from `self.items`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(PointsLabelList.get)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## New Methods - Please document or move to the undocumented section" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

analyze_pred[source][test]

\n", "\n", "> analyze_pred(**`pred`**)\n", "\n", "
×

No tests found for analyze_pred. To contribute a test please refer to this guide and this discussion.

\n", "\n", "Called on `pred` before `reconstruct` for additional preprocessing. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(ObjectCategoryList.analyze_pred)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "jekyll": { "keywords": "fastai", "summary": "Basic dataset for computer vision and helper function to get a DataBunch", "title": "vision.data" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 2 }