{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Image Cleaner Widget" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "fastai offers several widgets to support the workflow of a deep learning practitioner. The purpose of the widgets are to help you organize, clean, and prepare your data for your model. Widgets are separated by data type." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.vision import *\n", "from fastai.widgets import DatasetFormatter, ImageCleaner, ImageDownloader, download_google_images\n", "from fastai.gen_doc.nbdoc import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "%reload_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "path = untar_data(URLs.MNIST_SAMPLE)\n", "data = ImageDataBunch.from_folder(path)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "learn = cnn_learner(data, models.resnet18, metrics=error_rate)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
epoch | \n", "train_loss | \n", "valid_loss | \n", "error_rate | \n", "time | \n", "
---|---|---|---|---|
0 | \n", "0.184135 | \n", "0.103444 | \n", "0.037291 | \n", "00:06 | \n", "
1 | \n", "0.110252 | \n", "0.082977 | \n", "0.028459 | \n", "00:05 | \n", "
class
DatasetFormatter
[source][test]DatasetFormatter
()\n",
"\n",
"No tests found for DatasetFormatter
. To contribute a test please refer to this guide and this discussion.
from_similars
[source][test]from_similars
(**`learn`**, **`layer_ls`**:`list`=***`[0, 7, 2]`***, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for from_similars
. To contribute a test please refer to this guide and this discussion.
from_toplosses
[source][test]from_toplosses
(**`learn`**, **`n_imgs`**=***`None`***, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for from_toplosses
. To contribute a test please refer to this guide and this discussion.
class
ImageCleaner
[source][test]ImageCleaner
(**`dataset`**, **`fns_idxs`**, **`path`**, **`batch_size`**:`int`=***`5`***, **`duplicates`**=***`False`***)\n",
"\n",
"Tests found for ImageCleaner
:
pytest -sv tests/test_widgets_image_cleaner.py::test_image_cleaner_index_length_mismatch
[source]pytest -sv tests/test_widgets_image_cleaner.py::test_image_cleaner_length_correct
[source]pytest -sv tests/test_widgets_image_cleaner.py::test_image_cleaner_wrong_input_type
[source]To run tests please refer to this guide.
(n_batches, n_features, 1, 1)
then you don't need any pooling (this is the case with the last layer). The suggested use of `.from_similars()` with resnets is using the last layer and no pooling, like in the following cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Getting activations...\n"
]
},
{
"data": {
"text/html": [
"\n",
" class
ImageDownloader
[source][test]ImageDownloader
(**`path`**:`PathOrStr`=***`'data'`***)\n",
"\n",
"download_google_images
[source][test]download_google_images
(**`path`**:`PathOrStr`, **`search_term`**:`str`, **`size`**:`str`=***`'>400*300'`***, **`n_images`**:`int`=***`10`***, **`format`**:`str`=***`'jpg'`***, **`max_workers`**:`int`=***`4`***, **`timeout`**:`int`=***`4`***) → `FilePathList`\n",
"\n",
"No tests found for download_google_images
. To contribute a test please refer to this guide and this discussion.
make_dropdown_widget
[source][test]make_dropdown_widget
(**`description`**=***`'Description'`***, **`options`**=***`['Label 1', 'Label 2']`***, **`value`**=***`'Label 1'`***, **`file_path`**=***`None`***, **`layout`**=***`Layout()`***, **`handler`**=***`None`***)\n",
"\n",
"No tests found for make_dropdown_widget
. To contribute a test please refer to this guide and this discussion.
next_batch
[source][test]next_batch
(**`_`**)\n",
"\n",
"No tests found for next_batch
. To contribute a test please refer to this guide and this discussion.
sort_idxs
[source][test]sort_idxs
(**`similarities`**)\n",
"\n",
"No tests found for sort_idxs
. To contribute a test please refer to this guide and this discussion.
make_vertical_box
[source][test]make_vertical_box
(**`children`**, **`layout`**=***`Layout()`***, **`duplicates`**=***`False`***)\n",
"\n",
"No tests found for make_vertical_box
. To contribute a test please refer to this guide and this discussion.
relabel
[source][test]relabel
(**`change`**)\n",
"\n",
"No tests found for relabel
. To contribute a test please refer to this guide and this discussion.
largest_indices
[source][test]largest_indices
(**`arr`**, **`n`**)\n",
"\n",
"No tests found for largest_indices
. To contribute a test please refer to this guide and this discussion.
delete_image
[source][test]delete_image
(**`file_path`**)\n",
"\n",
"No tests found for delete_image
. To contribute a test please refer to this guide and this discussion.
empty
[source][test]empty
()\n",
"\n",
"No tests found for empty
. To contribute a test please refer to this guide and this discussion.
empty_batch
[source][test]empty_batch
()\n",
"\n",
"No tests found for empty_batch
. To contribute a test please refer to this guide and this discussion.
comb_similarity
[source][test]comb_similarity
(**`t1`**:`Tensor`, **`t2`**:`Tensor`, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for comb_similarity
. To contribute a test please refer to this guide and this discussion.
get_widgets
[source][test]get_widgets
(**`duplicates`**)\n",
"\n",
"No tests found for get_widgets
. To contribute a test please refer to this guide and this discussion.
write_csv
[source][test]write_csv
()\n",
"\n",
"No tests found for write_csv
. To contribute a test please refer to this guide and this discussion.
create_image_list
[source][test]create_image_list
(**`dataset`**, **`fns_idxs`**)\n",
"\n",
"No tests found for create_image_list
. To contribute a test please refer to this guide and this discussion.
render
[source][test]render
()\n",
"\n",
"No tests found for render
. To contribute a test please refer to this guide and this discussion.
get_similars_idxs
[source][test]get_similars_idxs
(**`learn`**, **`layer_ls`**, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for get_similars_idxs
. To contribute a test please refer to this guide and this discussion.
on_delete
[source][test]on_delete
(**`btn`**)\n",
"\n",
"No tests found for on_delete
. To contribute a test please refer to this guide and this discussion.
make_button_widget
[source][test]make_button_widget
(**`label`**, **`file_path`**=***`None`***, **`handler`**=***`None`***, **`style`**=***`None`***, **`layout`**=***`Layout(width='auto')`***)\n",
"\n",
"No tests found for make_button_widget
. To contribute a test please refer to this guide and this discussion.
make_img_widget
[source][test]make_img_widget
(**`img`**, **`layout`**=***`Layout()`***, **`format`**=***`'jpg'`***)\n",
"\n",
"No tests found for make_img_widget
. To contribute a test please refer to this guide and this discussion.
get_actns
[source][test]get_actns
(**`learn`**, **`hook`**:[`Hook`](/callbacks.hooks.html#Hook), **`dl`**:[`DataLoader`](https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader), **`pool`**=***`'AdaptiveConcatPool2d'`***, **`pool_dim`**:`int`=***`4`***, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for get_actns
. To contribute a test please refer to this guide and this discussion.
batch_contains_deleted
[source][test]batch_contains_deleted
()\n",
"\n",
"No tests found for batch_contains_deleted
. To contribute a test please refer to this guide and this discussion.
make_horizontal_box
[source][test]make_horizontal_box
(**`children`**, **`layout`**=***`Layout()`***)\n",
"\n",
"No tests found for make_horizontal_box
. To contribute a test please refer to this guide and this discussion.
get_toplosses_idxs
[source][test]get_toplosses_idxs
(**`learn`**, **`n_imgs`**, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for get_toplosses_idxs
. To contribute a test please refer to this guide and this discussion.
padded_ds
[source][test]padded_ds
(**`ll_input`**, **`size`**=***`(250, 300)`***, **`resize_method`**=***`No tests found for padded_ds
. To contribute a test please refer to this guide and this discussion.