Full Code of jantic/DeOldify for AI

master 5f86c2892379 cached
143 files
1.1 MB
308.3k tokens
2028 symbols
1 requests
Download .txt
Showing preview only (1,164K chars total). Download the full file or copy to clipboard to get everything.
Repository: jantic/DeOldify
Branch: master
Commit: 5f86c2892379
Files: 143
Total size: 1.1 MB

Directory structure:
gitextract_t921b9n1/

├── .github/
│   └── CODEOWNERS
├── .gitignore
├── .pre-commit-config.yaml
├── .pylintrc
├── .travis.yml
├── ColorFIDBenchmarkArtistic.ipynb
├── ColorizeTrainingArtistic.ipynb
├── ColorizeTrainingStable.ipynb
├── ColorizeTrainingStableLargeBatch.ipynb
├── ColorizeTrainingVideo.ipynb
├── ColorizeTrainingWandb.ipynb
├── ImageColorizer.ipynb
├── ImageColorizerArtisticTests.ipynb
├── ImageColorizerColab.ipynb
├── ImageColorizerColabStable.ipynb
├── ImageColorizerStableTests.ipynb
├── LICENSE
├── MANIFEST.in
├── README.md
├── VideoColorizer.ipynb
├── VideoColorizerColab.ipynb
├── deoldify/
│   ├── __init__.py
│   ├── _device.py
│   ├── augs.py
│   ├── critics.py
│   ├── dataset.py
│   ├── device_id.py
│   ├── filters.py
│   ├── generators.py
│   ├── layers.py
│   ├── loss.py
│   ├── save.py
│   ├── unet.py
│   └── visualize.py
├── environment.yml
├── fastai/
│   ├── LICENSE
│   ├── __init__.py
│   ├── basic_data.py
│   ├── basic_train.py
│   ├── basics.py
│   ├── callback.py
│   ├── callbacks/
│   │   ├── __init__.py
│   │   ├── csv_logger.py
│   │   ├── fp16.py
│   │   ├── general_sched.py
│   │   ├── hooks.py
│   │   ├── loss_metrics.py
│   │   ├── lr_finder.py
│   │   ├── mem.py
│   │   ├── misc.py
│   │   ├── mixup.py
│   │   ├── mlflow.py
│   │   ├── one_cycle.py
│   │   ├── oversampling.py
│   │   ├── rnn.py
│   │   ├── tensorboard.py
│   │   └── tracker.py
│   ├── collab.py
│   ├── core.py
│   ├── data_block.py
│   ├── datasets.py
│   ├── distributed.py
│   ├── gen_doc/
│   │   ├── __init__.py
│   │   ├── autogen.tpl
│   │   ├── convert2html.py
│   │   ├── core.py
│   │   ├── docstrings.py
│   │   ├── doctest.py
│   │   ├── gen_notebooks.py
│   │   ├── hide.tpl
│   │   ├── jekyll.tpl
│   │   ├── nbdoc.py
│   │   └── nbtest.py
│   ├── general_optimizer.py
│   ├── imports/
│   │   ├── __init__.py
│   │   ├── core.py
│   │   └── torch.py
│   ├── launch.py
│   ├── layers.py
│   ├── metrics.py
│   ├── script.py
│   ├── sixel.py
│   ├── tabular/
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── models.py
│   │   └── transform.py
│   ├── test_registry.json
│   ├── text/
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── interpret.py
│   │   ├── learner.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── awd_lstm.py
│   │   │   ├── bwd_forget_mult_cuda.cpp
│   │   │   ├── bwd_forget_mult_cuda_kernel.cu
│   │   │   ├── forget_mult_cuda.cpp
│   │   │   ├── forget_mult_cuda_kernel.cu
│   │   │   ├── qrnn.py
│   │   │   └── transformer.py
│   │   └── transform.py
│   ├── torch_core.py
│   ├── train.py
│   ├── utils/
│   │   ├── __init__.py
│   │   ├── check_perf.py
│   │   ├── collect_env.py
│   │   ├── ipython.py
│   │   ├── mem.py
│   │   ├── mod_display.py
│   │   ├── pynvml_gate.py
│   │   └── show_install.py
│   ├── version.py
│   ├── vision/
│   │   ├── __init__.py
│   │   ├── cyclegan.py
│   │   ├── data.py
│   │   ├── gan.py
│   │   ├── image.py
│   │   ├── interpret.py
│   │   ├── learner.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── cadene_models.py
│   │   │   ├── darknet.py
│   │   │   ├── presnet.py
│   │   │   ├── unet.py
│   │   │   ├── wrn.py
│   │   │   ├── xception.py
│   │   │   ├── xresnet.py
│   │   │   └── xresnet2.py
│   │   ├── transform.py
│   │   └── tta.py
│   └── widgets/
│       ├── __init__.py
│       ├── class_confusion.py
│       ├── image_cleaner.py
│       └── image_downloader.py
├── fid/
│   ├── LICENSE
│   ├── fid_score.py
│   └── inception.py
├── models/
│   └── .gitkeep
├── requirements-colab.txt
├── requirements-dev.txt
├── requirements.txt
├── setup.py
├── test_images/
│   └── .gitkeep
└── tox.ini

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/CODEOWNERS
================================================
# See: https://help.github.com/en/articles/about-code-owners
#
# Owners will be requested for review when someone opens a pull request.
*       @jantic @alexandrevicenzi


================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# DeOldify
data
*SymbolicLinks.sh
*.ipynb_checkpoints*
ColorizeTraining*[0-9]*.ipynb
*Colorizer[0-9]*.ipynb
lesson7-superres*.ipynb
test.py
result_images
*.prof
*.pth
video
test_images/*.jpg
test_images/*.JPG
test_images/*.PNG
test_images/*.png
test_images/*.jpeg
test_images/*.JPEG 
deoldify/.ipynb_checkpoints/*-checkpoint.py
tmp*


================================================
FILE: .pre-commit-config.yaml
================================================
repos:
-   repo: https://github.com/ambv/black
    rev: stable
    hooks:
    - id: black
      args: [-S]
      language_version: python3.6


================================================
FILE: .pylintrc
================================================
[MASTER]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook='import sys; sys.path.append("./venv/lib/python3.7/site-packages")'

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
# complex, nested conditions.
limit-inference-results=100

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=

# Pickle collected data for later comparisons.
persistent=yes

# Specify a configuration file.
#rcfile=

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no


[MESSAGES CONTROL]

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
confidence=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once). You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
        parameter-unpacking,
        unpacking-in-except,
        old-raise-syntax,
        backtick,
        long-suffix,
        old-ne-operator,
        old-octal-literal,
        import-star-module-level,
        non-ascii-bytes-literal,
        raw-checker-failed,
        bad-inline-option,
        locally-disabled,
        locally-enabled,
        file-ignored,
        suppressed-message,
        useless-suppression,
        deprecated-pragma,
        use-symbolic-message-instead,
        apply-builtin,
        basestring-builtin,
        buffer-builtin,
        cmp-builtin,
        coerce-builtin,
        execfile-builtin,
        file-builtin,
        long-builtin,
        raw_input-builtin,
        reduce-builtin,
        standarderror-builtin,
        unicode-builtin,
        xrange-builtin,
        coerce-method,
        delslice-method,
        getslice-method,
        setslice-method,
        no-absolute-import,
        old-division,
        dict-iter-method,
        dict-view-method,
        next-method-called,
        metaclass-assignment,
        indexing-exception,
        raising-string,
        reload-builtin,
        oct-method,
        hex-method,
        nonzero-method,
        cmp-method,
        input-builtin,
        round-builtin,
        intern-builtin,
        unichr-builtin,
        map-builtin-not-iterating,
        zip-builtin-not-iterating,
        range-builtin-not-iterating,
        filter-builtin-not-iterating,
        using-cmp-argument,
        eq-without-hash,
        div-method,
        idiv-method,
        rdiv-method,
        exception-message-attribute,
        invalid-str-codec,
        sys-max-int,
        bad-python3-import,
        deprecated-string-function,
        deprecated-str-translate-call,
        deprecated-itertools-function,
        deprecated-types-field,
        next-method-defined,
        dict-items-not-iterating,
        dict-keys-not-iterating,
        dict-values-not-iterating,
        deprecated-operator-function,
        deprecated-urllib-function,
        xreadlines-attribute,
        deprecated-sys-function,
        exception-escape,
        comprehension-escape,
        # Disabled due Black
        bad-continuation,
        bad-whitespace,
        # We don't care about these
        redundant-keyword-arg,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member


[REPORTS]

# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)

# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
#msg-template=

# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=text

# Tells whether to display a full report or only the messages.
reports=no

# Activate the evaluation score.
score=yes


[REFACTORING]

# Maximum number of nested blocks for function / method body
max-nested-blocks=5

# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=sys.exit


[LOGGING]

# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging


[SIMILARITIES]

# Ignore comments when computing similarities.
ignore-comments=yes

# Ignore docstrings when computing similarities.
ignore-docstrings=yes

# Ignore imports when computing similarities.
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=4


[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
      XXX,
      TODO


[FORMAT]

# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$

# Number of spaces of indent required inside a hanging  or continued line.
indent-after-paren=4

# String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1
# tab).
indent-string='    '

# Maximum number of characters on a single line.
max-line-length=100

# Maximum number of lines in a module.
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1  : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
               dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no

# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no


[BASIC]

# Naming style matching correct argument names.
argument-naming-style=snake_case

# Regular expression matching correct argument names. Overrides argument-
# naming-style.
#argument-rgx=

# Naming style matching correct attribute names.
attr-naming-style=snake_case

# Regular expression matching correct attribute names. Overrides attr-naming-
# style.
#attr-rgx=

# Bad variable names which should always be refused, separated by a comma.
bad-names=foo,
          bar,
          baz,
          toto,
          tutu,
          tata

# Naming style matching correct class attribute names.
class-attribute-naming-style=any

# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style.
#class-attribute-rgx=

# Naming style matching correct class names.
class-naming-style=PascalCase

# Regular expression matching correct class names. Overrides class-naming-
# style.
#class-rgx=

# Naming style matching correct constant names.
const-naming-style=UPPER_CASE

# Regular expression matching correct constant names. Overrides const-naming-
# style.
#const-rgx=

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1

# Naming style matching correct function names.
function-naming-style=snake_case

# Regular expression matching correct function names. Overrides function-
# naming-style.
#function-rgx=

# Good variable names which should always be accepted, separated by a comma.
good-names=f,
           i,
           j,
           k,
           s,
           t,
           ex,
           Run,
           _

# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no

# Naming style matching correct inline iteration names.
inlinevar-naming-style=any

# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style.
#inlinevar-rgx=

# Naming style matching correct method names.
method-naming-style=snake_case

# Regular expression matching correct method names. Overrides method-naming-
# style.
#method-rgx=

# Naming style matching correct module names.
module-naming-style=snake_case

# Regular expression matching correct module names. Overrides module-naming-
# style.
#module-rgx=

# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_

# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty

# Naming style matching correct variable names.
variable-naming-style=snake_case

# Regular expression matching correct variable names. Overrides variable-
# naming-style.
variable-rgx=_?[a-z][A-Za-z0-9_]{0,30}$
argument-rgx=_?[a-z][A-Za-z0-9_]{0,30}$


[TYPECHECK]

# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=torch.mm,
                  torch.diag,
                  torch.symeig,
                  torch.sqrt,
                  torch.cat,
                  cv2.cvtColor,
                  cv2.COLOR_BGR2YUV,
                  cv2.COLOR_YUV2BGR,

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes

# Tells whether to warn about missing members when the owner of the attribute
# is inferred to be None.
ignore-none=yes

# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes

# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=

# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes

# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1

# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1


[VARIABLES]

# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=

# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes

# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
          _cb

# A regular expression matching the name of dummy variables (i.e. expected to
# not be used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_

# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_

# Tells whether we should check for unused import in __init__ files.
init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io


[SPELLING]

# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4

# Spelling dictionary name. Available dictionaries: en_IE (myspell), en_ZM
# (myspell), en_GB (myspell), en_HK (myspell), en_BZ (myspell), en_PH
# (myspell), en_ZA (myspell), en_MW (myspell), en_AU (myspell), en_CA
# (myspell), en_JM (myspell), en_GH (myspell), en_TT (myspell), en_SG
# (myspell), en_BW (myspell), en_US (myspell), en_NZ (myspell), en_AG
# (myspell), en_ZW (myspell), en_NA (myspell), en_IN (myspell), en_BS
# (myspell), en_DK (myspell), en_NG (myspell)..
spelling-dict=

# List of comma separated words that should not be checked.
spelling-ignore-words=

# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=

# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no


[IMPORTS]

# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no

# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no

# Deprecated modules which should not be used, separated by a comma.
deprecated-modules=optparse,tkinter.tix

# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled).
ext-import-graph=

# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled).
import-graph=

# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled).
int-import-graph=

# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=

# Force import order to recognize a module as part of a third party library.
known-third-party=enchant


[CLASSES]

# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
                      __new__,
                      setUp

# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
                  _fields,
                  _replace,
                  _source,
                  _make

# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls

# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls


[DESIGN]

# Maximum number of arguments for function / method.
max-args=5

# Maximum number of attributes for a class (see R0902).
max-attributes=7

# Maximum number of boolean expressions in an if statement.
max-bool-expr=5

# Maximum number of branch for function / method body.
max-branches=12

# Maximum number of locals for function / method body.
max-locals=15

# Maximum number of parents for a class (see R0901).
max-parents=7

# Maximum number of public methods for a class (see R0904).
max-public-methods=20

# Maximum number of return / yield for function / method body.
max-returns=6

# Maximum number of statements in function / method body.
max-statements=50

# Minimum number of public methods for a class (see R0903).
min-public-methods=2


[EXCEPTIONS]

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception".
overgeneral-exceptions=Exception


================================================
FILE: .travis.yml
================================================
sudo: false
language: python
install: pip install tox
matrix:
  include:
  - python: "3.6"
    env: TOX_ENV=static
  - python: "3.6"
    env: TOX_ENV=format
script: tox -e $TOX_ENV


================================================
FILE: ColorFIDBenchmarkArtistic.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Color FID Benchmark (HQ)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ['CUDA_VISIBLE_DEVICES']='1'\n",
    "os.environ['OMP_NUM_THREADS']='1'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import statistics\n",
    "from fastai import *\n",
    "from deoldify.visualize import *\n",
    "import cv2\n",
    "from fid.fid_score import *\n",
    "from fid.inception import *\n",
    "import imageio\n",
    "plt.style.use('dark_background')\n",
    "torch.backends.cudnn.benchmark=True\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\", category=UserWarning, module=\"torch.nn.functional\")\n",
    "warnings.filterwarnings(\"ignore\", category=UserWarning, message='.*?retrieve source code for container of type.*?')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  Data should come from here:  'https://datasets.figure-eight.com/figure_eight_datasets/open-images/test_challenge.zip'\n",
    "#NOTE:  Minimum recommmended number of samples is 10K.  Source:  https://github.com/bioinf-jku/TTUR\n",
    "\n",
    "path = Path('data/ColorBenchmark')\n",
    "path_hr = path/'source'\n",
    "path_lr = path/'bandw'\n",
    "path_results = Path('./result_images/ColorBenchmarkFID/artistic')\n",
    "path_rendered = path_results/'rendered'\n",
    "\n",
    "#path = Path('data/DeOldifyColor')\n",
    "#path_hr = path\n",
    "#path_lr = path/'bandw'\n",
    "#path_results = Path('./result_images/ColorBenchmark/edge')\n",
    "#path_rendered = path_results/'rendered'\n",
    "\n",
    "#num_images = 2048\n",
    "#num_images = 15000\n",
    "num_images = 50000\n",
    "render_factor=35\n",
    "fid_batch_size = 4\n",
    "eval_size=299"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def inception_model(dims:int):\n",
    "    block_idx = InceptionV3.BLOCK_INDEX_BY_DIM[dims]\n",
    "    model = InceptionV3([block_idx])\n",
    "    model.cuda()\n",
    "    return model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def create_before_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def render_images(colorizer, source_dir:Path, filtered_dir:Path, target_dir:Path, render_factor:int, num_images:int)->[(Path, Path, Path)]:\n",
    "    results = []\n",
    "    bandw_list = ImageList.from_folder(path_lr)\n",
    "    bandw_list = bandw_list[:num_images]\n",
    "\n",
    "    if len(bandw_list.items) == 0: return results\n",
    "\n",
    "    results = []\n",
    "    img_iterator = progress_bar(bandw_list.items)\n",
    "\n",
    "    for bandw_path in img_iterator:\n",
    "        target_path = target_dir/bandw_path.relative_to(source_dir)\n",
    "\n",
    "        try:\n",
    "            result_image = colorizer.get_transformed_image(path=bandw_path, render_factor=render_factor)\n",
    "            result_path = Path(str(path_results) + '/' + bandw_path.parent.name + '/' + bandw_path.name)\n",
    "            if not result_path.parent.exists():\n",
    "                result_path.parent.mkdir(parents=True, exist_ok=True)\n",
    "            result_image.save(result_path)\n",
    "            results.append((result_path, bandw_path, target_path))\n",
    "        except Exception as err:\n",
    "            print('Failed to render image.  Skipping.  Details: {0}'.format(err))\n",
    "    \n",
    "    return results "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calculate_fid_score(render_results, bs:int, eval_size:int):\n",
    "    dims = 2048\n",
    "    cuda = True\n",
    "    model = inception_model(dims=dims)\n",
    "    rendered_paths = []\n",
    "    target_paths = []\n",
    "    \n",
    "    for render_result in render_results:\n",
    "        rendered_path, _, target_path = render_result\n",
    "        rendered_paths.append(str(rendered_path))\n",
    "        target_paths.append(str(target_path))\n",
    "        \n",
    "    rendered_m, rendered_s = calculate_activation_statistics(files=rendered_paths, model=model, batch_size=bs, dims=dims, cuda=cuda)\n",
    "    target_m, target_s = calculate_activation_statistics(files=target_paths, model=model, batch_size=bs, dims=dims, cuda=cuda)\n",
    "    fid_score = calculate_frechet_distance(rendered_m, rendered_s, target_m, target_s)\n",
    "    del model\n",
    "    return fid_score"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and whites source images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_before_images, il.items)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "path_results.parent.mkdir(parents=True, exist_ok=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Rendering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "colorizer = get_image_colorizer(artistic=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "render_results = render_images(colorizer=colorizer, source_dir=path_lr, target_dir=path_hr, filtered_dir=path_results, render_factor=render_factor, num_images=num_images)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Colorizaton Scoring"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fid_score = calculate_fid_score(render_results, bs=fid_batch_size, eval_size=eval_size)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('FID Score: ' + str(fid_score))"
   ]
  }
 ],
 "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


================================================
FILE: ColorizeTrainingArtistic.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Artistic Model Training"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTES:  \n",
    "* This is \"NoGAN\" based training, described in the DeOldify readme.\n",
    "* This model prioritizes colorful renderings.  It has higher variation in renderings at different resolutions compared to the \"stable\" model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import fastai\n",
    "from fastai import *\n",
    "from fastai.vision import *\n",
    "from fastai.callbacks.tensorboard import *\n",
    "from fastai.vision.gan import *\n",
    "from deoldify.generators import *\n",
    "from deoldify.critics import *\n",
    "from deoldify.dataset import *\n",
    "from deoldify.loss import *\n",
    "from deoldify.save import *\n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "from PIL import ImageFile"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = Path('data/imagenet/ILSVRC/Data/CLS-LOC')\n",
    "path_hr = path\n",
    "path_lr = path/'bandw'\n",
    "\n",
    "proj_id = 'ArtisticModel'\n",
    "\n",
    "gen_name = proj_id + '_gen'\n",
    "pre_gen_name = gen_name + '_0'\n",
    "crit_name = proj_id + '_crit'\n",
    "\n",
    "name_gen = proj_id + '_image_gen'\n",
    "path_gen = path/name_gen\n",
    "\n",
    "TENSORBOARD_PATH = Path('data/tensorboard/' + proj_id)\n",
    "\n",
    "nf_factor = 1.5\n",
    "pct_start = 1e-8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(bs:int, sz:int, keep_pct:float):\n",
    "    return get_colorize_data(sz=sz, bs=bs, crappy_path=path_lr, good_path=path_hr, \n",
    "                             random_seed=None, keep_pct=keep_pct)\n",
    "\n",
    "def get_crit_data(classes, bs, sz):\n",
    "    src = ImageList.from_folder(path, include=classes, recurse=True).split_by_rand_pct(0.1, seed=42)\n",
    "    ll = src.label_from_folder(classes=classes)\n",
    "    data = (ll.transform(get_transforms(max_zoom=2.), size=sz)\n",
    "           .databunch(bs=bs).normalize(imagenet_stats))\n",
    "    return data\n",
    "\n",
    "def create_training_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  \n",
    "    \n",
    "def save_preds(dl):\n",
    "    i=0\n",
    "    names = dl.dataset.items\n",
    "    \n",
    "    for b in dl:\n",
    "        preds = learn_gen.pred_batch(batch=b, reconstruct=True)\n",
    "        for o in preds:\n",
    "            o.save(path_gen/names[i].name)\n",
    "            i += 1\n",
    "    \n",
    "def save_gen_images():\n",
    "    if path_gen.exists(): shutil.rmtree(path_gen)\n",
    "    path_gen.mkdir(exist_ok=True)\n",
    "    data_gen = get_data(bs=bs, sz=sz, keep_pct=0.085)\n",
    "    save_preds(data_gen.fix_dl)\n",
    "    PIL.Image.open(path_gen.ls()[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and white training images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_training_images, il.items)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pre-train generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Most of the training takes place here in pretraining for NoGAN.  The goal here is to take the generator as far as possible with conventional training, as that is much easier to control and obtain glitch-free results compared to GAN training."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 64px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=88\n",
    "sz=64\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_deep(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.callback_fns.append(partial(ImageGenTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GenPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=0.8, max_lr=slice(1e-3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start,  max_lr=slice(3e-7, 3e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 128px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=22\n",
    "sz=128\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(1e-7,1e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 192px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=11\n",
    "sz=192\n",
    "keep_pct=0.50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeatable GAN Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Best results so far have been based on repeating the cycle below a few times (about 5-8?), until diminishing returns are hit (no improvement in image quality).  Each time you repeat the cycle, you want to increment that old_checkpoint_num by 1 so that new check points don't overwrite the old.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "old_checkpoint_num = 0\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Save Generated Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_deep(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_gen_images()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pretrain Critic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Only need full pretraining of critic when starting from scratch.  Otherwise, just finetune!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if old_checkpoint_num == 0:\n",
    "    bs=64\n",
    "    sz=128\n",
    "    learn_gen=None\n",
    "    gc.collect()\n",
    "    data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)\n",
    "    data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)\n",
    "    learn_critic = colorize_crit_learner(data=data_crit, nf=256)\n",
    "    learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))\n",
    "    learn_critic.fit_one_cycle(6, 1e-3)\n",
    "    learn_critic.save(crit_old_checkpoint_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=16\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.fit_one_cycle(4, 1e-4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.save(crit_new_checkpoint_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit=None\n",
    "learn_gen=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr=1e-5\n",
    "sz=192\n",
    "bs=9"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_new_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_deep(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "switcher = partial(AdaptiveGANSwitcher, critic_thresh=0.65)\n",
    "learn = GANLearner.from_learners(learn_gen, learn_crit, weights_gen=(1.0,2.0), show_img=False, switcher=switcher,\n",
    "                                 opt_func=partial(optim.Adam, betas=(0.,0.9)), wd=1e-3)\n",
    "learn.callback_fns.append(partial(GANDiscriminativeLR, mult_lr=5.))\n",
    "learn.callback_fns.append(partial(GANTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GanLearner', visual_iters=100))\n",
    "learn.callback_fns.append(partial(GANSaveCallback, learn_gen=learn_gen, filename=gen_new_checkpoint_name, save_iters=100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Instructions:  \n",
    "Find the checkpoint just before where glitches start to be introduced.  This is all very new so you may need to play around with just how far you go here with keep_pct."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn.data = get_data(sz=sz, bs=bs, keep_pct=0.03)\n",
    "learn_gen.freeze_to(-1)\n",
    "learn.fit(1,lr)"
   ]
  }
 ],
 "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


================================================
FILE: ColorizeTrainingStable.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Stable Model Training"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTES:  \n",
    "* This is \"NoGAN\" based training, described in the DeOldify readme.\n",
    "* This model prioritizes stable and reliable renderings.  It does particularly well on portraits and landscapes.  It's not as colorful as the artistic model."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import fastai\n",
    "from fastai import *\n",
    "from fastai.vision import *\n",
    "from fastai.callbacks.tensorboard import *\n",
    "from fastai.vision.gan import *\n",
    "from deoldify.generators import *\n",
    "from deoldify.critics import *\n",
    "from deoldify.dataset import *\n",
    "from deoldify.loss import *\n",
    "from deoldify.save import *\n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "from PIL import ImageFile"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = Path('data/imagenet/ILSVRC/Data/CLS-LOC')\n",
    "path_hr = path\n",
    "path_lr = path/'bandw'\n",
    "\n",
    "proj_id = 'StableModel'\n",
    "\n",
    "gen_name = proj_id + '_gen'\n",
    "pre_gen_name = gen_name + '_0'\n",
    "crit_name = proj_id + '_crit'\n",
    "\n",
    "name_gen = proj_id + '_image_gen'\n",
    "path_gen = path/name_gen\n",
    "\n",
    "TENSORBOARD_PATH = Path('data/tensorboard/' + proj_id)\n",
    "\n",
    "nf_factor = 2\n",
    "pct_start = 1e-8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(bs:int, sz:int, keep_pct:float):\n",
    "    return get_colorize_data(sz=sz, bs=bs, crappy_path=path_lr, good_path=path_hr, \n",
    "                             random_seed=None, keep_pct=keep_pct)\n",
    "\n",
    "def get_crit_data(classes, bs, sz):\n",
    "    src = ImageList.from_folder(path, include=classes, recurse=True).split_by_rand_pct(0.1, seed=42)\n",
    "    ll = src.label_from_folder(classes=classes)\n",
    "    data = (ll.transform(get_transforms(max_zoom=2.), size=sz)\n",
    "           .databunch(bs=bs).normalize(imagenet_stats))\n",
    "    return data\n",
    "\n",
    "def create_training_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  \n",
    "    \n",
    "def save_preds(dl):\n",
    "    i=0\n",
    "    names = dl.dataset.items\n",
    "    \n",
    "    for b in dl:\n",
    "        preds = learn_gen.pred_batch(batch=b, reconstruct=True)\n",
    "        for o in preds:\n",
    "            o.save(path_gen/names[i].name)\n",
    "            i += 1\n",
    "    \n",
    "def save_gen_images():\n",
    "    if path_gen.exists(): shutil.rmtree(path_gen)\n",
    "    path_gen.mkdir(exist_ok=True)\n",
    "    data_gen = get_data(bs=bs, sz=sz, keep_pct=0.085)\n",
    "    save_preds(data_gen.fix_dl)\n",
    "    PIL.Image.open(path_gen.ls()[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and white training images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_training_images, il.items)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pre-train generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Most of the training takes place here in pretraining for NoGAN.  The goal here is to take the generator as far as possible with conventional training, as that is much easier to control and obtain glitch-free results compared to GAN training."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 64px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=88\n",
    "sz=64\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.callback_fns.append(partial(ImageGenTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GenPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=0.8, max_lr=slice(1e-3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start,  max_lr=slice(3e-7, 3e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 128px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=20\n",
    "sz=128\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(1e-7,1e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 192px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192\n",
    "keep_pct=0.50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeatable GAN Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Best results so far have been based on repeating the cycle below a few times (about 5-8?), until diminishing returns are hit (no improvement in image quality).  Each time you repeat the cycle, you want to increment that old_checkpoint_num by 1 so that new check points don't overwrite the old.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "old_checkpoint_num = 0\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Save Generated Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_gen_images()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pretrain Critic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Only need full pretraining of critic when starting from scratch.  Otherwise, just finetune!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if old_checkpoint_num == 0:\n",
    "    bs=64\n",
    "    sz=128\n",
    "    learn_gen=None\n",
    "    gc.collect()\n",
    "    data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)\n",
    "    data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)\n",
    "    learn_critic = colorize_crit_learner(data=data_crit, nf=256)\n",
    "    learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))\n",
    "    learn_critic.fit_one_cycle(6, 1e-3)\n",
    "    learn_critic.save(crit_old_checkpoint_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=16\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.fit_one_cycle(4, 1e-4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.save(crit_new_checkpoint_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit=None\n",
    "learn_gen=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr=2e-5\n",
    "sz=192\n",
    "bs=5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_new_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "switcher = partial(AdaptiveGANSwitcher, critic_thresh=0.65)\n",
    "learn = GANLearner.from_learners(learn_gen, learn_crit, weights_gen=(1.0,1.5), show_img=False, switcher=switcher,\n",
    "                                 opt_func=partial(optim.Adam, betas=(0.,0.9)), wd=1e-3)\n",
    "learn.callback_fns.append(partial(GANDiscriminativeLR, mult_lr=5.))\n",
    "learn.callback_fns.append(partial(GANTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GanLearner', visual_iters=100))\n",
    "learn.callback_fns.append(partial(GANSaveCallback, learn_gen=learn_gen, filename=gen_new_checkpoint_name, save_iters=100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Instructions:  \n",
    "Find the checkpoint just before where glitches start to be introduced.  This is all very new so you may need to play around with just how far you go here with keep_pct."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn.data = get_data(sz=sz, bs=bs, keep_pct=0.03)\n",
    "learn_gen.freeze_to(-1)\n",
    "learn.fit(1,lr)"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


================================================
FILE: ColorizeTrainingStableLargeBatch.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Stable Model Training (Large Batch/Limited GPU Memory Support)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## IMPORTANT: Training has -not- been verified by myself for this notebook ~jantic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTES:  \n",
    "* This is \"NoGAN\" based training, described in the DeOldify readme.\n",
    "* This model prioritizes stable and reliable renderings.  It does particularly well on portraits and landscapes.  It's not as colorful as the artistic model."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ['CUDA_VISIBLE_DEVICES']='0' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import fastai\n",
    "from fastai import *\n",
    "from fastai.vision import *\n",
    "from fastai.callbacks.tensorboard import *\n",
    "from fastai.vision.gan import *\n",
    "from deoldify.generators import *\n",
    "from deoldify.critics import *\n",
    "from deoldify.dataset import *\n",
    "from deoldify.loss import *\n",
    "from deoldify.save import *\n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "from PIL import ImageFile"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Activate Large Model Support for PyTorch\n",
    "This will allow us to fit the model within a GPU with smaller memory capacity (e.g. GTX 1070 8Gb)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Large Model Support (LMS) is a feature provided in IBM Watson Machine Learning Community Edition (WML-CE) PyTorch V1.1.0 that allows the successful training of deep learning models that would otherwise exhaust GPU memory and abort with “out-of-memory” errors. LMS manages this oversubscription of GPU memory by temporarily swapping tensors to host memory when they are not needed. One or more elements of a deep learning model can lead to GPU memory exhaustion.\n",
    "\n",
    "Requires the use of IBM WML-CE (Available here: https://www.ibm.com/support/knowledgecenter/en/SS5SF7_1.6.1/welcome/welcome.html)\n",
    "\n",
    "Further Reading on PyTorch with Large Model Support: https://www.ibm.com/support/knowledgecenter/en/SS5SF7_1.6.1/navigation/wmlce_getstarted_pytorch.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import shutil"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set limit of GPU used before swapping to tensors to host memory\n",
    "max_gpu_mem = 7\n",
    "\n",
    "def gb_to_bytes(gb):\n",
    "    return gb*1024*1024*1024\n",
    "\n",
    "# Enable PyTorch LMS\n",
    "torch.cuda.set.enabled_lms(True)\n",
    "# Set LMS limit\n",
    "torch.cuda.set_limit_lms(gb_to_bytes(max_gpu_mem))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Check LMS is enabled\n",
    "torch.cuda.get_enabled_lms()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Check LMS Limit has been set\n",
    "torch.cuda.get_limit_lms()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Path to Training Data\n",
    "path = Path('data/imagenet/ILSVRC/Data/CLS-LOC')\n",
    "path_hr = path\n",
    "\n",
    "# Path to Black and White images\n",
    "path_bandw = Path('/training/DeOldify')\n",
    "path_lr = path_bandw/'bandw'\n",
    "\n",
    "# Name of Model\n",
    "proj_id = 'StableModel'\n",
    "\n",
    "# Name of Generator\n",
    "gen_name = proj_id + '_gen'\n",
    "pre_gen_name = gen_name + '_0'\n",
    "\n",
    "# Name of Critic\n",
    "crit_name = proj_id + '_crit'\n",
    "\n",
    "# Name of Generated Images folder, located within the Black and White folder\n",
    "name_gen = proj_id + '_image_gen'\n",
    "path_gen = path/name_gen\n",
    "\n",
    "# Path to tensorboard data\n",
    "TENSORBOARD_PATH = Path('data/tensorboard/' + proj_id)\n",
    "\n",
    "nf_factor = 2\n",
    "pct_start = 1e-8\n",
    "\n",
    "# Number of workers for DataLoader\n",
    "num_works = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(bs:int, sz:int, keep_pct:float):\n",
    "    return get_colorize_data(sz=sz, bs=bs, crappy_path=path_lr, good_path=path_hr, \n",
    "                             random_seed=None, keep_pct=keep_pct, num_workers=num_works)\n",
    "\n",
    "def get_crit_data(classes, bs, sz):\n",
    "    src = ImageList.from_folder(path, include=classes, recurse=True).split_by_rand_pct(0.1, seed=42)\n",
    "    ll = src.label_from_folder(classes=classes)\n",
    "    data = (ll.transform(get_transforms(max_zoom=2.), size=sz)\n",
    "           .databunch(bs=bs).normalize(imagenet_stats))\n",
    "    return data\n",
    "\n",
    "def create_training_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  \n",
    "    \n",
    "def save_preds(dl):\n",
    "    i=0\n",
    "    names = dl.dataset.items\n",
    "    \n",
    "    for b in dl:\n",
    "        preds = learn_gen.pred_batch(batch=b, reconstruct=True)\n",
    "        for o in preds:\n",
    "            o.save(path_gen/names[i].name)\n",
    "            i += 1\n",
    "    \n",
    "def save_gen_images():\n",
    "    if path_gen.exists(): shutil.rmtree(path_gen)\n",
    "    path_gen.mkdir(exist_ok=True)\n",
    "    data_gen = get_data(bs=bs, sz=sz, keep_pct=0.085)\n",
    "    save_preds(data_gen.fix_dl)\n",
    "    PIL.Image.open(path_gen.ls()[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and white training images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_training_images, il.items)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pre-train generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Most of the training takes place here in pretraining for NoGAN.  The goal here is to take the generator as far as possible with conventional training, as that is much easier to control and obtain glitch-free results compared to GAN training."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 64px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=88 # This can be increased if using PyTorch LMS, training could be slower.\n",
    "sz=64\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.callback_fns.append(partial(ImageGenTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GenPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=0.8, max_lr=slice(1e-3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start,  max_lr=slice(3e-7, 3e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 128px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=40 # This can be increased if using PyTorch LMS, training could be slower.\n",
    "sz=128\n",
    "keep_pct=1.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(1e-7,1e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 192px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=16 # This can be increased if using PyTorch LMS, training could be slower.\n",
    "sz=192\n",
    "keep_pct=0.50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 256px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8 # This can be increased if using PyTorch LMS, training could be slower.\n",
    "sz=256\n",
    "keep_pct=0.50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(sz=sz, bs=bs, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeatable GAN Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Best results so far have been based on repeating the cycle below a few times (about 5-8?), until diminishing returns are hit (no improvement in image quality).  Each time you repeat the cycle, you want to increment that old_checkpoint_num by 1 so that new check points don't overwrite the old.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "old_checkpoint_num = 0\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Save Generated Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_gen_images()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pretrain Critic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Only need full pretraining of critic when starting from scratch.  Otherwise, just finetune!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if old_checkpoint_num == 0:\n",
    "    bs=64\n",
    "    sz=128\n",
    "    learn_gen=None\n",
    "    gc.collect()\n",
    "    data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)\n",
    "    data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)\n",
    "    learn_critic = colorize_crit_learner(data=data_crit, nf=256)\n",
    "    learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))\n",
    "    learn_critic.fit_one_cycle(6, 1e-3)\n",
    "    learn_critic.save(crit_old_checkpoint_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.fit_one_cycle(4, 1e-4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.save(crit_new_checkpoint_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit=None\n",
    "learn_gen=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr=2e-5\n",
    "sz=256\n",
    "bs=5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_new_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "switcher = partial(AdaptiveGANSwitcher, critic_thresh=0.65)\n",
    "learn = GANLearner.from_learners(learn_gen, learn_crit, weights_gen=(1.0,1.5), show_img=False, switcher=switcher,\n",
    "                                 opt_func=partial(optim.Adam, betas=(0.,0.9)), wd=1e-3)\n",
    "learn.callback_fns.append(partial(GANDiscriminativeLR, mult_lr=5.))\n",
    "learn.callback_fns.append(partial(GANTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GanLearner', visual_iters=100))\n",
    "learn.callback_fns.append(partial(GANSaveCallback, learn_gen=learn_gen, filename=gen_new_checkpoint_name, save_iters=100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Instructions:  \n",
    "Find the checkpoint just before where glitches start to be introduced.  This is all very new so you may need to play around with just how far you go here with keep_pct."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn.data = get_data(sz=sz, bs=bs, keep_pct=0.03)\n",
    "learn_gen.freeze_to(-1)\n",
    "learn.fit(1,lr)"
   ]
  }
 ],
 "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


================================================
FILE: ColorizeTrainingVideo.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Video Model Training"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTES:  \n",
    "* It's assumed that there's a pretrained generator from the ColorizeTrainingStable notebook available at the specified path.\n",
    "* This is \"NoGAN\" based training, described in the DeOldify readme."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import fastai\n",
    "from fastai import *\n",
    "from fastai.vision import *\n",
    "from fastai.callbacks.tensorboard import *\n",
    "from fastai.vision.gan import *\n",
    "from deoldify.generators import *\n",
    "from deoldify.critics import *\n",
    "from deoldify.dataset import *\n",
    "from deoldify.loss import *\n",
    "from deoldify.save import *\n",
    "from deoldify.augs import noisify \n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "from PIL import ImageFile"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = Path('data/imagenet/ILSVRC/Data/CLS-LOC')\n",
    "path_hr = path\n",
    "path_lr = path/'bandw'\n",
    "\n",
    "proj_id = 'VideoModel'\n",
    "gen_name = proj_id + '_gen'\n",
    "pre_gen_name = gen_name + '_0'\n",
    "crit_name = proj_id + '_crit'\n",
    "\n",
    "name_gen = proj_id + '_image_gen'\n",
    "path_gen = path/name_gen\n",
    "\n",
    "TENSORBOARD_PATH = Path('data/tensorboard/' + proj_id)\n",
    "\n",
    "nf_factor = 2\n",
    "xtra_tfms=[noisify(p=0.8)]\n",
    "pct_start = 1e-8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(bs:int, sz:int, keep_pct:float):\n",
    "    return get_colorize_data(sz=sz, bs=bs, crappy_path=path_lr, good_path=path_hr, \n",
    "                             random_seed=None, keep_pct=keep_pct, xtra_tfms=xtra_tfms)\n",
    "\n",
    "def get_crit_data(classes, bs, sz):\n",
    "    src = ImageList.from_folder(path, include=classes, recurse=True).split_by_rand_pct(0.1, seed=42)\n",
    "    ll = src.label_from_folder(classes=classes)\n",
    "    data = (ll.transform(get_transforms(max_zoom=2.), size=sz)\n",
    "           .databunch(bs=bs).normalize(imagenet_stats))\n",
    "    return data\n",
    "\n",
    "def create_training_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  \n",
    "    \n",
    "def save_preds(dl):\n",
    "    i=0\n",
    "    names = dl.dataset.items\n",
    "    \n",
    "    for b in dl:\n",
    "        preds = learn_gen.pred_batch(batch=b, reconstruct=True)\n",
    "        for o in preds:\n",
    "            o.save(path_gen/names[i].name)\n",
    "            i += 1\n",
    "            \n",
    "def save_gen_images():\n",
    "    if path_gen.exists(): shutil.rmtree(path_gen)\n",
    "    path_gen.mkdir(exist_ok=True)\n",
    "    data_gen = get_data(bs=bs, sz=sz, keep_pct=0.085)\n",
    "    save_preds(data_gen.fix_dl)\n",
    "    PIL.Image.open(path_gen.ls()[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and white training images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_training_images, il.items)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Finetune Generator With Noise Augmented Images."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### This helps the generator better deal with noisy/grainy video (which is pretty normal)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192\n",
    "keep_pct=0.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, keep_pct=keep_pct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.callback_fns.append(partial(ImageGenTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GenPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = learn_gen.load(pre_gen_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(1, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeatable GAN Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Best results so far have been based only doing a single run of the cells below (otherwise glitches are introduced that are visible in video).  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "old_checkpoint_num = 0\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Save Generated Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_gen_images()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pretrain Critic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=16\n",
    "sz=192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.callback_fns.append(partial(LearnerTensorboardWriter, base_dir=TENSORBOARD_PATH, name='CriticPre'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.fit_one_cycle(4, 1e-4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_critic.save(crit_new_checkpoint_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit=None\n",
    "learn_gen=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr=5e-6\n",
    "sz=192\n",
    "bs=5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_new_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "switcher = partial(AdaptiveGANSwitcher, critic_thresh=0.65)\n",
    "learn = GANLearner.from_learners(learn_gen, learn_crit, weights_gen=(1.0,1.5), show_img=False, switcher=switcher,\n",
    "                                 opt_func=partial(optim.Adam, betas=(0.,0.9)), wd=1e-3)\n",
    "learn.callback_fns.append(partial(GANDiscriminativeLR, mult_lr=5.))\n",
    "learn.callback_fns.append(partial(GANTensorboardWriter, base_dir=TENSORBOARD_PATH, name='GanLearner', visual_iters=100, stats_iters=10, loss_iters=1))\n",
    "learn.callback_fns.append(partial(GANSaveCallback, learn_gen=learn_gen, filename=gen_new_checkpoint_name, save_iters=100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Instructions:  \n",
    "Find the checkpoint just before where glitches start to be introduced.  So far this has been found at the point of iterating through 1.4% of the data when using learning rate of 1e-5, and at 2.2% of the data for 5e-6."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn.data = get_data(sz=sz, bs=bs, keep_pct=0.03)\n",
    "learn_gen.freeze_to(-1)\n",
    "learn.fit(1,lr)"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


================================================
FILE: ColorizeTrainingWandb.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Stable Model Training with monitoring through Weights & Biases"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTES:  \n",
    "* This is \"NoGAN\" based training, described in the DeOldify readme.\n",
    "* This model prioritizes stable and reliable renderings.  It does particularly well on portraits and landscapes.  It's not as colorful as the artistic model.\n",
    "* Training with this notebook has been logged and monitored through [Weights & Biases](https://www.wandb.com/). Refer to [W&B Report](https://app.wandb.ai/borisd13/DeOldify/reports?view=borisd13%2FDeOldify).\n",
    "* It is **highly** recommended to use a 11 Go GPU to run this notebook. Anything lower will require to reduce the batch size (leading to moro instability) or use of \"Large Model Support\" from IBM WML-CE (not so easy to setup). An alternative is to rent ressources online."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Install W&B Callback\n",
    "#!pip install wandb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import fastai\n",
    "from fastai import *\n",
    "from fastai.vision import *\n",
    "from fastai.vision.gan import *\n",
    "from deoldify.generators import *\n",
    "from deoldify.critics import *\n",
    "from deoldify.dataset import *\n",
    "from deoldify.loss import *\n",
    "from deoldify.save import *\n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "from PIL import ImageFile\n",
    "from torch.utils.data.sampler import RandomSampler, SequentialSampler\n",
    "from tqdm import tqdm\n",
    "import wandb\n",
    "from wandb.fastai import WandbCallback"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set up W&B: checks user can connect to W&B servers\n",
    "# Note: set up API key the first time\n",
    "wandb.login()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Dataset can be downloaded from https://www.kaggle.com/c/imagenet-object-localization-challenge/data\n",
    "path = Path('data/imagenet/ILSVRC/Data/CLS-LOC')\n",
    "path_hr = path\n",
    "path_lr = path/'bandw'\n",
    "\n",
    "proj_id = 'StableModel'\n",
    "\n",
    "gen_name = proj_id + '_gen'\n",
    "pre_gen_name = gen_name + '_0'\n",
    "crit_name = proj_id + '_crit'\n",
    "\n",
    "name_gen = proj_id + '_image_gen'\n",
    "path_gen = path/name_gen\n",
    "\n",
    "nf_factor = 2\n",
    "pct_start = 1e-8"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Iterating through the dataset\n",
    "\n",
    "The dataset is very large and it would take a long time to iterate through all the samples at each epoch.\n",
    "\n",
    "We use custom samplers in order to limit epochs to subsets of data while still iterating slowly through the entire dataset (epoch after epoch). This let us run the validation loop more often where we log metrics as well as prediction samples on validation data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Reduce quantity of samples per training epoch\n",
    "# Adapted from https://forums.fast.ai/t/epochs-of-arbitrary-length/27777/10\n",
    "\n",
    "@classmethod\n",
    "def create(cls, train_ds:Dataset, valid_ds:Dataset, test_ds:Optional[Dataset]=None, path:PathOrStr='.', bs:int=64,\n",
    "            val_bs:int=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None,\n",
    "            device:torch.device=None, collate_fn:Callable=data_collate, no_check:bool=False, sampler=None, **dl_kwargs)->'DataBunch':\n",
    "    \"Create a `DataBunch` from `train_ds`, `valid_ds` and maybe `test_ds` with a batch size of `bs`. Passes `**dl_kwargs` to `DataLoader()`\"\n",
    "    datasets = cls._init_ds(train_ds, valid_ds, test_ds)\n",
    "    val_bs = ifnone(val_bs, bs)\n",
    "    if sampler is None: sampler = [RandomSampler] + 3*[SequentialSampler]\n",
    "    dls = [DataLoader(d, b, sampler=sa(d), drop_last=sh, num_workers=num_workers, **dl_kwargs) for d,b,sh,sa in\n",
    "            zip(datasets, (bs,val_bs,val_bs,val_bs), (True,False,False,False), sampler) if d is not None]\n",
    "    return cls(*dls, path=path, device=device, dl_tfms=dl_tfms, collate_fn=collate_fn, no_check=no_check)\n",
    "\n",
    "ImageDataBunch.create = create\n",
    "ImageImageList._bunch = ImageDataBunch\n",
    "\n",
    "class FixedLenRandomSampler(RandomSampler):\n",
    "    def __init__(self, data_source, epoch_size):\n",
    "        super().__init__(data_source)\n",
    "        self.epoch_size = epoch_size\n",
    "        self.not_sampled = np.array([True]*len(data_source))\n",
    "    \n",
    "    @property\n",
    "    def reset_state(self): self.not_sampled[:] = True\n",
    "        \n",
    "    def __iter__(self):\n",
    "        ns = sum(self.not_sampled)\n",
    "        idx_last = []\n",
    "        if ns >= len(self):\n",
    "            idx = np.random.choice(np.where(self.not_sampled)[0], size=len(self), replace=False).tolist()\n",
    "            if ns == len(self): self.reset_state\n",
    "        else:\n",
    "            idx_last = np.where(self.not_sampled)[0].tolist()\n",
    "            self.reset_state\n",
    "            idx = np.random.choice(np.where(self.not_sampled)[0], size=len(self)-len(idx_last), replace=False).tolist()\n",
    "        self.not_sampled[idx] = False\n",
    "        idx = [*idx_last, *idx]\n",
    "        return iter(idx)\n",
    "    \n",
    "    def __len__(self):\n",
    "        return self.epoch_size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(bs:int, sz:int, keep_pct=1.0, random_seed=None, valid_pct=0.2, epoch_size=1000):\n",
    "    \n",
    "    # Create samplers\n",
    "    train_sampler = partial(FixedLenRandomSampler, epoch_size=epoch_size)\n",
    "    samplers = [train_sampler, SequentialSampler, SequentialSampler, SequentialSampler]\n",
    "\n",
    "    return get_colorize_data(sz=sz, bs=bs, crappy_path=path_lr, good_path=path_hr, random_seed=random_seed,\n",
    "                             keep_pct=keep_pct, samplers=samplers, valid_pct=valid_pct)\n",
    "\n",
    "# Function modified to allow use of custom samplers\n",
    "def get_colorize_data(sz:int, bs:int, crappy_path:Path, good_path:Path, random_seed:int=None,\n",
    "        keep_pct:float=1.0, num_workers:int=8, samplers=None, valid_pct=0.2, xtra_tfms=[])->ImageDataBunch:\n",
    "    src = (ImageImageList.from_folder(crappy_path, convert_mode='RGB')\n",
    "        .use_partial_data(sample_pct=keep_pct, seed=random_seed)\n",
    "        .split_by_rand_pct(valid_pct, seed=random_seed))\n",
    "    data = (src.label_from_func(lambda x: good_path/x.relative_to(crappy_path))\n",
    "        .transform(get_transforms(max_zoom=1.2, max_lighting=0.5, max_warp=0.25, xtra_tfms=xtra_tfms), size=sz, tfm_y=True)\n",
    "        .databunch(bs=bs, num_workers=num_workers, sampler=samplers, no_check=True)\n",
    "        .normalize(imagenet_stats, do_y=True))\n",
    "    data.c = 3\n",
    "    return data\n",
    "\n",
    "# Function to limit amount of data in critic\n",
    "def filter_data(pct=1.0):\n",
    "    def _f(fname):\n",
    "        if 'test' in str(fname):\n",
    "            if np.random.random_sample() > pct:\n",
    "                return False\n",
    "        return True\n",
    "    return _f\n",
    "\n",
    "def get_crit_data(classes, bs, sz, pct=1.0):\n",
    "    src = ImageList.from_folder(path, include=classes, recurse=True).filter_by_func(filter_data(pct)).split_by_rand_pct(0.1)\n",
    "    ll = src.label_from_folder(classes=classes)\n",
    "    data = (ll.transform(get_transforms(max_zoom=2.), size=sz)\n",
    "           .databunch(bs=bs).normalize(imagenet_stats))\n",
    "    return data\n",
    "\n",
    "def create_training_images(fn,i):\n",
    "    dest = path_lr/fn.relative_to(path_hr)\n",
    "    dest.parent.mkdir(parents=True, exist_ok=True)\n",
    "    img = PIL.Image.open(fn).convert('LA').convert('RGB')\n",
    "    img.save(dest)  \n",
    "    \n",
    "def save_preds(dl):\n",
    "    i=0\n",
    "    names = dl.dataset.items    \n",
    "    for b in tqdm(dl):\n",
    "        preds = learn_gen.pred_batch(batch=b, reconstruct=True)\n",
    "        for o in preds:\n",
    "            o.save(path_gen/names[i].name)\n",
    "            i += 1\n",
    "    \n",
    "def save_gen_images(keep_pct):\n",
    "    if path_gen.exists(): shutil.rmtree(path_gen)\n",
    "    path_gen.mkdir(exist_ok=True)\n",
    "    data_gen = get_data(bs=bs, sz=sz, keep_pct=keep_pct)\n",
    "    save_preds(data_gen.fix_dl)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create black and white training images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only runs if the directory isn't already created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if not path_lr.exists():\n",
    "    il = ImageList.from_folder(path_hr)\n",
    "    parallel(create_training_images, il.items)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Number of black & white images\n",
    "data_size = len(list(path_lr.rglob('*.*')))\n",
    "print('Number of black & white images:', data_size)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pre-train generator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Most of the training takes place here in pretraining for NoGAN.  The goal here is to take the generator as far as possible with conventional training, as that is much easier to control and obtain glitch-free results compared to GAN training."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 64px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Init logging of a new run\n",
    "wandb.init(tags=['Pre-train Gen'])  # tags are optional"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=88\n",
    "sz=64\n",
    "\n",
    "# Define target number of training/validation samples as well as number of epochs\n",
    "epoch_train_size = 100 * bs\n",
    "epoch_valid_size = 10 * bs\n",
    "valid_pct = epoch_valid_size / data_size\n",
    "number_epochs = (data_size - epoch_valid_size) // epoch_train_size\n",
    "\n",
    "# Log hyper parameters\n",
    "wandb.config.update({\"Step 1 - batch size\": bs, \"Step 1 - image size\": sz,\n",
    "                     \"Step 1 - epoch size\": epoch_train_size, \"Step 1 - number epochs\": number_epochs})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, random_seed=123, valid_pct=valid_pct, epoch_size=100*bs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.callback_fns.append(partial(WandbCallback,\n",
    "                                      input_type='images'))  # log prediction samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(number_epochs, pct_start=0.8, max_lr=slice(1e-3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(number_epochs, pct_start=pct_start,  max_lr=slice(3e-7, 3e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 128px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=20\n",
    "sz=128\n",
    "\n",
    "# Define target number of training/validation samples as well as number of epochs\n",
    "epoch_train_size = 100 * bs\n",
    "epoch_valid_size = 10 * bs\n",
    "valid_pct = epoch_valid_size / data_size\n",
    "number_epochs = (data_size - epoch_valid_size) // epoch_train_size\n",
    "\n",
    "# Log hyper parameters\n",
    "wandb.config.update({\"Step 2 - batch size\": bs, \"Step 2 - image size\": sz,\n",
    "                     \"Step 2 - epoch size\": epoch_train_size, \"Step 2 - number epochs\": number_epochs})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(bs=bs, sz=sz, random_seed=123, valid_pct=valid_pct, epoch_size=100*bs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(number_epochs, pct_start=pct_start, max_lr=slice(1e-7,1e-4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 192px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192\n",
    "\n",
    "# Define target number of training/validation samples as well as number of epochs\n",
    "epoch_train_size = 100 * bs\n",
    "epoch_valid_size = 10 * bs\n",
    "valid_pct = epoch_valid_size / data_size\n",
    "number_epochs = (data_size - epoch_valid_size) // epoch_train_size // 2  # Training is long - we use half of data\n",
    "\n",
    "# Log hyper parameters\n",
    "wandb.config.update({\"Step 3 - batch size\": bs, \"Step 3 - image size\": sz,\n",
    "                     \"Step 3 - epoch size\": epoch_train_size, \"Step 3 - number epochs\": number_epochs})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.data = get_data(bs=bs, sz=sz, random_seed=123, valid_pct=valid_pct, epoch_size=100*bs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.unfreeze()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.fit_one_cycle(number_epochs, pct_start=pct_start, max_lr=slice(5e-8,5e-5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen.save(pre_gen_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# End logging of current session run\n",
    "# Note: this is optional and would be automatically triggered when stopping the kernel\n",
    "wandb.join()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeatable GAN Cycle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE\n",
    "Best results so far have been based on repeating the cycle below a few times (about 5-8?), until diminishing returns are hit (no improvement in image quality).  Each time you repeat the cycle, you want to increment that old_checkpoint_num by 1 so that new check points don't overwrite the old.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "old_checkpoint_num = 0\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Save Generated Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=8\n",
    "sz=192\n",
    "\n",
    "# Define target number of training/validation samples as well as number of epochs\n",
    "epoch_train_size = 100 * bs\n",
    "epoch_valid_size = 10 * bs\n",
    "valid_pct = epoch_valid_size / data_size\n",
    "number_epochs = (data_size - epoch_valid_size) // epoch_train_size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_gen = get_data(bs=bs, sz=sz, random_seed=123, valid_pct=valid_pct, epoch_size=100*bs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_gen_images(0.1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pretrain Critic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Only need full pretraining of critic when starting from scratch.  Otherwise, just finetune!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if old_checkpoint_num == 0:\n",
    "    \n",
    "    # Init logging of a new run\n",
    "    wandb.init(tags=['Pre-train Crit'])  # tags are optional\n",
    "    \n",
    "    bs=64\n",
    "    sz=128\n",
    "    learn_gen=None\n",
    "    \n",
    "    # Log hyper parameters\n",
    "    wandb.config.update({\"Step 1 - batch size\": bs, \"Step 1 - image size\": sz})\n",
    "\n",
    "    gc.collect()    \n",
    "    data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)\n",
    "    data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)\n",
    "    learn_crit = colorize_crit_learner(data=data_crit, nf=256)\n",
    "    learn_crit.callback_fns.append(partial(WandbCallback))  # log prediction samples\n",
    "    learn_crit.fit_one_cycle(6, 1e-3)\n",
    "    learn_crit.save(crit_old_checkpoint_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs=16\n",
    "sz=192\n",
    "\n",
    "# Log hyper parameters\n",
    "wandb.config.update({\"Step 2 - batch size\": bs, \"Step 2 - image size\": sz})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_crit.show_batch(rows=3, ds_type=DatasetType.Train, imgsize=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit.fit_one_cycle(4, 1e-4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_crit.save(crit_new_checkpoint_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### GAN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# free up memory\n",
    "learn_crit=None\n",
    "learn_gen=None\n",
    "learn=None\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set old_checkpoint_num to last iteration\n",
    "old_checkpoint_num = 0\n",
    "save_checkpoints = False\n",
    "batch_per_epoch = 200\n",
    "\n",
    "checkpoint_num = old_checkpoint_num + 1\n",
    "gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)   \n",
    "\n",
    "if False:   # need only to do it once\n",
    "        \n",
    "    # Generate data\n",
    "    print('Generating data…')\n",
    "    bs=8\n",
    "    sz=192\n",
    "    epoch_train_size = batch_per_epoch * bs\n",
    "    epoch_valid_size = batch_per_epoch * bs // 10\n",
    "    valid_pct = epoch_valid_size / data_size\n",
    "    data_gen = get_data(bs=bs, sz=sz, epoch_size=epoch_train_size, valid_pct=valid_pct)\n",
    "    learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)\n",
    "    save_gen_images(0.02)\n",
    "\n",
    "    # Pre-train critic\n",
    "    print('Pre-training critic…')\n",
    "    bs=16\n",
    "    sz=192\n",
    "\n",
    "    len_test = len(list((path / 'test').rglob('*.*')))\n",
    "    len_gen = len(list((path / name_gen).rglob('*.*')))\n",
    "    keep_test_pct = len_gen / len_test * 2\n",
    "\n",
    "    data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz, pct=keep_test_pct)\n",
    "    learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_old_checkpoint_name, with_opt=False)\n",
    "    learn_crit.fit_one_cycle(1, 1e-4)\n",
    "    learn_crit.save(crit_new_checkpoint_name)\n",
    "\n",
    "# Creating GAN\n",
    "print('Creating GAN…')\n",
    "sz=192\n",
    "bs=8\n",
    "lr_GAN=2e-5\n",
    "epoch_train_size = batch_per_epoch * bs\n",
    "epoch_valid_size = batch_per_epoch * bs // 10\n",
    "valid_pct = epoch_valid_size / data_size\n",
    "len_test = len(list((path / 'test').rglob('*.*')))\n",
    "len_gen = len(list((path / name_gen).rglob('*.*')))\n",
    "keep_test_pct = len_gen / len_test * 2\n",
    "\n",
    "data_crit = get_crit_data([name_gen, 'test'], bs=bs, sz=sz, pct=keep_test_pct)\n",
    "learn_crit = colorize_crit_learner(data=data_crit, nf=256).load(crit_new_checkpoint_name, with_opt=False)\n",
    "data_gen = get_data(bs=bs, sz=sz, epoch_size=epoch_train_size, valid_pct=valid_pct)\n",
    "learn_gen = gen_learner_wide(data=data_gen, gen_loss=FeatureLoss(), nf_factor=nf_factor).load(gen_old_checkpoint_name, with_opt=False)\n",
    "switcher = partial(AdaptiveGANSwitcher, critic_thresh=0.65)\n",
    "learn = GANLearner.from_learners(learn_gen, learn_crit, weights_gen=(1.0,1.5), show_img=False, switcher=switcher,\n",
    "                                 opt_func=partial(optim.Adam, betas=(0.,0.9)), wd=1e-3)\n",
    "learn.callback_fns.append(partial(GANDiscriminativeLR, mult_lr=5.))\n",
    "learn.callback_fns.append(partial(WandbCallback, input_type='images', seed=None, save_model=False))\n",
    "learn.data = get_data(bs=bs, sz=sz, epoch_size=epoch_train_size, valid_pct=valid_pct)\n",
    "\n",
    "# Start logging to W&B\n",
    "wandb.init(tags=['GAN'])\n",
    "wandb.config.update({\"learning rate\": lr_GAN})  \n",
    "\n",
    "# Run the loop until satisfied with the results\n",
    "while True:\n",
    "\n",
    "    # Current loop\n",
    "    checkpoint_num = old_checkpoint_num + 1\n",
    "    gen_old_checkpoint_name = gen_name + '_' + str(old_checkpoint_num)\n",
    "    gen_new_checkpoint_name = gen_name + '_' + str(checkpoint_num)\n",
    "    crit_old_checkpoint_name = crit_name + '_' + str(old_checkpoint_num)\n",
    "    crit_new_checkpoint_name= crit_name + '_' + str(checkpoint_num)      \n",
    "    \n",
    "    \n",
    "    # GAN for 10 epochs between each checkpoint\n",
    "    try:\n",
    "        learn.fit(1, lr_GAN)\n",
    "    except:\n",
    "        # Sometimes we get an error for some unknown reason during callbacks\n",
    "        learn.callback_fns[-1](learn).on_epoch_end(old_checkpoint_num, None, [])\n",
    "        \n",
    "    if save_checkpoints:\n",
    "        learn_crit.save(crit_new_checkpoint_name)\n",
    "        learn_gen.save(gen_new_checkpoint_name)\n",
    "    \n",
    "    old_checkpoint_num += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# End logging of current session run\n",
    "# Note: this is optional and would be automatically triggered when stopping the kernel\n",
    "wandb.join()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


================================================
FILE: ImageColorizer.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from deoldify.visualize import *\n",
    "plt.style.use('dark_background')\n",
    "torch.backends.cudnn.benchmark=True\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\", category=UserWarning, message=\".*?Your .*? set is empty.*?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "NOTE:  Set artistic to False if you're having trouble getting a good render.  Chances are it will work with the Stable model. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "colorizer = get_image_colorizer(artistic=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Instructions\n",
    "\n",
    "### source_url\n",
    "Type in a url to a direct link of an image.  Usually that means they'll end in .png, .jpg, etc.  NOTE: If you want to use your own image, you can set source_url to None and just upload the image to /test_images/ in Jupyter.  Just make sure that the source_path parameter matches the file you uploaded.\n",
    "\n",
    "### source_path\n",
    "Name this whatever sensible image path (plus extension of jpg/png/ext) you want!  Sensible means the path exists and the file exists if source_url=None.\n",
    "\n",
    "### render_factor\n",
    "The default value of 35 has been carefully chosen and should work -ok- for most scenarios (but probably won't be the -best-). This determines resolution at which the color portion of the image is rendered. Lower resolution will render faster, and colors also tend to look more vibrant. Older and lower quality images in particular will generally benefit by lowering the render factor. Higher render factors are often better for higher quality images, but the colors may get slightly washed out. \n",
    "\n",
    "### result_path\n",
    "Ditto- don't change.\n",
    "\n",
    "### How to Download a Copy\n",
    "Simply shift+right click on the displayed image and click \"Save Image As...\"!\n",
    "\n",
    "\n",
    "## Pro Tips\n",
    "1. You can evaluate how well the image is rendered at each render_factor by using the code at the bottom (that cell under \"See how well render_factor values perform on a frame here\"). \n",
    "2. Keep in mind again that you can go up top and set artistic to False for the colorizer to use the 'Stable' model instead.  This will often tend to do better on portraits, and natural landscapes.  \n",
    "\n",
    "\n",
    "## Troubleshooting\n",
    "If you get a 'CUDA out of memory' error, you probably have the render_factor too high.  The max is 45 on 11GB video cards."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Colorize!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  Max is 45 with 11GB video cards. 35 is a good default\n",
    "render_factor=35\n",
    "#NOTE:  Make source_url None to just read from file at ./video/source/[file_name] directly without modification\n",
    "source_url='https://upload.wikimedia.org/wikipedia/commons/e/e4/Raceland_Louisiana_Beer_Drinkers_Russell_Lee.jpg'\n",
    "source_path = 'test_images/image.png'\n",
    "result_path = None\n",
    "\n",
    "if source_url is not None:\n",
    "    result_path = colorizer.plot_transformed_image_from_url(url=source_url, path=source_path, render_factor=render_factor, compare=True)\n",
    "else:\n",
    "    result_path = colorizer.plot_transformed_image(path=source_path, render_factor=render_factor, compare=True)\n",
    "\n",
    "show_image_in_notebook(result_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## See how well render_factor values perform on the image here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#for i in range(10,46):\n",
    "    #colorizer.plot_transformed_image(source_path, render_factor=i, display_render_factor=True, figsize=(10,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.6"
  },
  "toc": {
   "colors": {
    "hover_highlight": "#DAA520",
    "navigate_num": "#000000",
    "navigate_text": "#333333",
    "running_highlight": "#FF0000",
    "selected_highlight": "#FFD700",
    "sidebar_border": "#EEEEEE",
    "wrapper_background": "#FFFFFF"
   },
   "moveMenuLeft": true,
   "nav_menu": {
    "height": "67px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": false,
   "widenNotebook": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}


================================================
FILE: ImageColorizerArtisticTests.ipynb
================================================
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#NOTE:  This must be the first call in order to work properly!\n",
    "from deoldify import device\n",
    "from deoldify.device_id import DeviceId\n",
    "#choices:  CPU, GPU0...GPU7\n",
    "device.set(device=DeviceId.GPU0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from deoldify.visualize import *\n",
    "plt.style.use('dark_background')\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\", category=UserWarning, message=\".*?Your .*? set is empty.*?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Adjust render_factor (int) if image doesn't look quite right (max 64 on 11GB GPU).  The default here works for most photos.  \n",
    "#It literally just is a number multiplied by 16 to get the square render resolution.  \n",
    "#Note that this doesn't affect the resolution of the final output- the output is the same resolution as the input.\n",
    "#Example:  render_factor=21 => color is rendered at 16x21 = 336x336 px.  \n",
    "render_factor=35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis = get_image_colorizer(render_factor=render_factor, artistic=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/poolparty.jpg\", render_factor=38, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1852GatekeepersWindsor.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Chief.jpg\", render_factor=14, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1850SchoolForGirls.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AtlanticCityBeach1905.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CottonMillWorkers1913.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BrooklynNavyYardHospital.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FinnishPeasant1867.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AtlanticCity1905.png\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PushingCart.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Drive1905.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/IronLung.png\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FamilyWithDog.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/DayAtSeaBelgium.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/marilyn_woods.jpg\", render_factor=29, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/OldWomanSweden1904.jpg\", render_factor=36, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WomenTapingPlanes.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/overmiller.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BritishDispatchRider.jpg\", render_factor=19, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MuseauNacionalDosCoches.jpg\", render_factor=17, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/abe.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/RossCorbettHouseCork.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HPLabelleOfficeMontreal.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/einstein_beach.jpg\", render_factor=29, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/airmen1943.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/20sWoman.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/egypt-1.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Rutherford_Hayes.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/einstein_portrait.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/pinkerton.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WaltWhitman.jpg\", render_factor=12, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dorothea-lange.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Hemmingway2.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/hemmingway.jpg\", render_factor=9, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/smoking_kid.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/teddy_rubble.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dustbowl_2.jpg\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/camera_man.jpg\", render_factor=23, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/migrant_mother.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/marktwain.jpg\", render_factor=10, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HelenKeller.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Evelyn_Nesbit.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Eddie-Adams.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/soldier_kids.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AnselAdamsYosemite.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/unnamed.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/workers_canyon.jpg\", render_factor=48, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CottonMill.jpg\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/JudyGarland.jpeg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/kids_pit.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/last_samurai.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AnselAdamsWhiteChurch.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/opium.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dorothea_lange_2.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/rgs.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/wh-auden.jpg\", render_factor=24, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/w-b-yeats.jpg\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/marilyn_portrait.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/wilson-slaverevivalmeeting.jpg\", render_factor=38, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ww1_trench.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/women-bikers.png\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Unidentified1855.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/skycrapper_lunch.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/sioux.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/school_kids.jpg\", render_factor=26, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/royal_family.jpg\", render_factor=33, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/redwood_lumberjacks.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/poverty.jpg\", render_factor=26, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/paperboy.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NativeAmericans.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/helmut_newton-.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Greece1911.jpg\", render_factor=26, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FatMenClub.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/EgyptColosus.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/egypt-2.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dustbowl_sd.jpg\", render_factor=12, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dustbowl_people.jpg\", render_factor=24, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dustbowl_5.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/dustbowl_1.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/DriveThroughGiantTree.jpg\", render_factor=39, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/covered-wagons-traveling.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/civil-war_2.jpg\", render_factor=12, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/civil_war_4.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/civil_war_3.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/civil_war.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BritishSlum.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/bicycles.jpg\", render_factor=33, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/brooklyn_girls_1940s.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/40sCouple.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1946Wedding.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Dolores1920s.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TitanicGym.jpg\", render_factor=31, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FrenchVillage1950s.jpg\", render_factor=38, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ClassDivide1930sBrittain.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1870sSphinx.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890Surfer.png\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TV1930s.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1864UnionSoldier.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890sMedStudents.jpg\", render_factor=23, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BellyLaughWWI.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PiggyBackRide.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HealingTree.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ManPile.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1910Bike.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FreeportIL.jpg\", render_factor=36, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/DutchBabyCoupleEllis.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/InuitWoman1903.png\", render_factor=33, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1920sDancing.jpg\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AirmanDad.jpg\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1910Racket.png\", render_factor=34, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1880Paris.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Deadwood1860s.jpg\", render_factor=38, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1860sSamauris.jpg\", render_factor=34, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonUnderground1860.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Mid1800sSisters.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1860Girls.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SanFran1851.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Kabuki1870s.png\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Mormons1870s.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/EgyptianWomenLate1800s.jpg\", render_factor=7, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PicadillyLate1800s.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SutroBaths1880s.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1880sBrooklynBridge.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ChinaOpiumc1880.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Locomotive1880s.jpg\", render_factor=10, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ViennaBoys1880s.png\", render_factor=19, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/VictorianDragQueen1880s.png\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Sami1880s.jpg\", render_factor=39, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Ballet1890Russia.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Rottindean1890s.png\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890sPingPong.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/London1937.png\", render_factor=36, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Harlem1932.jpg\", render_factor=27, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/OregonTrail1870s.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/EasterNyc1911.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1899NycBlizzard.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Edinburgh1920s.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890sShoeShopOhio.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890sTouristsEgypt.png\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1938Reading.jpg\", render_factor=27, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1850Geography.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1901Electrophone.jpg\", render_factor=7, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Texas1938Woman.png\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MaioreWoman1895NZ.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WestVirginiaHouse.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1920sGuadalope.jpg\", render_factor=33, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1909Chicago.jpg\", render_factor=14, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1920sFarmKid.jpg\", render_factor=12, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ParisLate1800s.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1900sDaytonaBeach.png\", render_factor=24, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1930sGeorgia.jpg\", render_factor=17, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NorwegianBride1920s.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Depression.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1888Slum.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LivingRoom1920Sweden.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1896NewsBoyGirl.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PetDucks1927.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1899SodaFountain.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TimesSquare1955.jpg\", render_factor=42, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PuppyGify.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890CliffHouseSF.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1908FamilyPhoto.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1900sSaloon.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890BostonHospital.jpg\", render_factor=19, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1870Girl.jpg\", render_factor=9, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AustriaHungaryWomen1890s.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Shack.jpg\",render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Apsaroke1908.png\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1948CarsGrandma.jpg\", render_factor=14, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PlanesManhattan1931.jpg\", render_factor=11, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WorriedKid1940sNyc.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1920sFamilyPhoto.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CatWash1931.jpg\", render_factor=34, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1940sBeerRiver.jpg\", render_factor=46, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/VictorianLivingRoom.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1897BlindmansBluff.jpg\", render_factor=23, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1874Mexico.png\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MadisonSquare1900.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1867MusicianConstantinople.jpg\", render_factor=11, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1925Girl.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1907Cowboys.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WWIIPeeps.jpg\", render_factor=26, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BabyBigBoots.jpg\", render_factor=17, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1895BikeMaidens.jpg\", render_factor=8, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/IrishLate1800s.jpg\", render_factor=13, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LibraryOfCongress1910.jpg\", render_factor=33, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1875Olds.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SenecaNative1908.jpg\", render_factor=22, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WWIHospital.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1892WaterLillies.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GreekImmigrants1905.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FatMensShop.jpg\", render_factor=24, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/KidCage1930s.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FarmWomen1895.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NewZealand1860s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/JerseyShore1905.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonKidsEarly1900s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NYStreetClean1906.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Boston1937.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Cork1905.jpg\", render_factor=37, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BoxedBedEarly1900s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ZoologischerGarten1898.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/EmpireState1930.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Agamemnon1919.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AppalachianLoggers1901.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WWISikhs.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MementoMori1865.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/RepBrennanRadio1922.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Late1800sNative.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GasPrices1939.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1933RockefellerCenter.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Scotland1919.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1920CobblersShopLondon.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1909ParisFirstFemaleTaxisDriver.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HoovervilleSeattle1932.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ElephantLondon1934.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Jane_Addams.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AnselAdamsAdobe.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CricketLondon1930.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Donegal1907Yarn.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AnselAdamsChurch.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BreadDelivery1920sIreland.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BritishTeaBombay1890s.png\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CafeParis1928.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BigManTavern1908NYC.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Cars1890sIreland.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GalwayIreland1902.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HomeIreland1924.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HydeParkLondon1920s.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1929LondonOverFleetSt.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AccordianKid1900Paris.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AnselAdamsBuildings.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/AthleticClubParis1913.jpg\", render_factor=42, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BombedLibraryLondon1940.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Boston1937.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BoulevardDuTemple1838.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/BumperCarsParis1930.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CafeTerrace1925Paris.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CoalDeliveryParis1915.jpg\", render_factor=37, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CorkKids1910.jpg\", render_factor=32, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/DeepSeaDiver1915.png\", render_factor=16, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/EastEndLondonStreetKids1901.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FreightTrainTeens1934.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HarrodsLondon1920.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HerbSeller1899Paris.jpg\", render_factor=17, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CalcuttaPoliceman1920.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ElectricScooter1915.jpeg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GreatGrandparentsIrelandEarly1900s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/HalloweenEarly1900s.jpg\", render_factor=11, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/IceManLondon1919.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LeBonMarcheParis1875.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LittleAirplane1934.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/RoyalUniversityMedStudent1900Ireland.jpg\", render_factor=24, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LewisTomalinLondon1895.png\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SunHelmetsLondon1933.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Killarney1910.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonSheep1920s.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PostOfficeVermont1914.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ServantsBessboroughHouse1908Ireland.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WaterfordIreland1909.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Lisbon1919.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/London1918WartimeClothesManufacture.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonHeatWave1935.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonsSmallestShop1900.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MetropolitanDistrictRailway1869London.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NativeWoman1926.jpg\", render_factor=43, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PaddysMarketCork1900s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PaddysMarketCork1900s.jpg\", render_factor=i, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Paris1920Cart.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ParisLadies1910.jpg\", render_factor=38, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ParisLadies1930s.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Sphinx.jpeg\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TheatreGroupBombay1875.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WorldsFair1900Paris.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/London1850Coach.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/London1900EastEndBlacksmith.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/London1930sCheetah.jpg\", render_factor=42, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonFireBrigadeMember1926.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonGarbageTruck1910.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonRailwayWork1931.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonStreets1900.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/MuffinManlLondon1910.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NativeCouple1912.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NewspaperCivilWar1863.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PaddingtonStationLondon1907.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Paris1899StreetDig.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Paris1926.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ParisWomenFurs1920s.jpg\", render_factor=15, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PeddlerParis1899.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SchoolKidsConnemaraIreland1901.jpg\", render_factor=18, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SecondHandClothesLondonLate1800s.jpg\", render_factor=44, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SoapBoxRacerParis1920s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SoccerMotorcycles1923London.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/WalkingLibraryLondon1930.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonStreetDoctor1877.png\", render_factor=19, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/jacksonville.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ZebraCarriageLondon1900.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/StreetGramaphonePlayerLondon1920s.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/YaleBranchBarnardsExpress.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SynagogueInterior.PNG\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ArmisticeDay1918.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/FlyingMachinesParis1909.jpg\", render_factor=25, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GreatAunt1920.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/NewBrunswick1915.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ShoeMakerLate1800s.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/SpottedBull1908.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TouristsGermany1904.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/TunisianStudents1914.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/Yorktown1862.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/LondonFashion1911.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1939GypsyKids.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1936OpiumShanghai.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1923HollandTunnel.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1939YakimaWAGirl.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/GoldenGateConstruction.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/PostCivilWarAncestors.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1939SewingBike.png\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1930MaineSchoolBus.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1913NewYorkConstruction.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1945HiroshimaChild.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1941GeorgiaFarmhouse.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1934UmbriaItaly.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1900sLadiesTeaParty.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1919WWIAviationOxygenMask.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1900NJThanksgiving.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1940Connecticut.jpg\", render_factor=42, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1911ThanksgivingMaskers.jpg\", render_factor=36, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1910ThanksgivingMaskersII.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1936PetToad.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1908RookeriesLondon.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1890sChineseImmigrants.jpg\", render_factor=36, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1897VancouverAmberlamps.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1929VictorianCosplayLondon.jpg\", render_factor=30, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1959ParisFriends.png\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1925GypsyCampMaryland.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1941PoolTableGeorgia.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1900ParkDog.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1886Hoop.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1950sLondonPoliceChild.jpg\", compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1886ProspectPark.jpg\", render_factor=45, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1930sRooftopPoland.jpg\", render_factor=37, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1919RevereBeach.jpg\", render_factor=20, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1936ParisCafe.jpg\", render_factor=47, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1902FrenchYellowBellies.jpg\", render_factor=35, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1940PAFamily.jpg\", render_factor=34, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1910Finland.jpg\", render_factor=40, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/ZebraCarriageLondon1900.jpg\", render_factor=21, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/1904ChineseMan.jpg\", render_factor=14, compare=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "vis.plot_transformed_image(\"test_images/CrystalPalaceLondon1854.PNG\", render_factor=15, compare=True)"
   ]
  },
  {
Download .txt
gitextract_t921b9n1/

├── .github/
│   └── CODEOWNERS
├── .gitignore
├── .pre-commit-config.yaml
├── .pylintrc
├── .travis.yml
├── ColorFIDBenchmarkArtistic.ipynb
├── ColorizeTrainingArtistic.ipynb
├── ColorizeTrainingStable.ipynb
├── ColorizeTrainingStableLargeBatch.ipynb
├── ColorizeTrainingVideo.ipynb
├── ColorizeTrainingWandb.ipynb
├── ImageColorizer.ipynb
├── ImageColorizerArtisticTests.ipynb
├── ImageColorizerColab.ipynb
├── ImageColorizerColabStable.ipynb
├── ImageColorizerStableTests.ipynb
├── LICENSE
├── MANIFEST.in
├── README.md
├── VideoColorizer.ipynb
├── VideoColorizerColab.ipynb
├── deoldify/
│   ├── __init__.py
│   ├── _device.py
│   ├── augs.py
│   ├── critics.py
│   ├── dataset.py
│   ├── device_id.py
│   ├── filters.py
│   ├── generators.py
│   ├── layers.py
│   ├── loss.py
│   ├── save.py
│   ├── unet.py
│   └── visualize.py
├── environment.yml
├── fastai/
│   ├── LICENSE
│   ├── __init__.py
│   ├── basic_data.py
│   ├── basic_train.py
│   ├── basics.py
│   ├── callback.py
│   ├── callbacks/
│   │   ├── __init__.py
│   │   ├── csv_logger.py
│   │   ├── fp16.py
│   │   ├── general_sched.py
│   │   ├── hooks.py
│   │   ├── loss_metrics.py
│   │   ├── lr_finder.py
│   │   ├── mem.py
│   │   ├── misc.py
│   │   ├── mixup.py
│   │   ├── mlflow.py
│   │   ├── one_cycle.py
│   │   ├── oversampling.py
│   │   ├── rnn.py
│   │   ├── tensorboard.py
│   │   └── tracker.py
│   ├── collab.py
│   ├── core.py
│   ├── data_block.py
│   ├── datasets.py
│   ├── distributed.py
│   ├── gen_doc/
│   │   ├── __init__.py
│   │   ├── autogen.tpl
│   │   ├── convert2html.py
│   │   ├── core.py
│   │   ├── docstrings.py
│   │   ├── doctest.py
│   │   ├── gen_notebooks.py
│   │   ├── hide.tpl
│   │   ├── jekyll.tpl
│   │   ├── nbdoc.py
│   │   └── nbtest.py
│   ├── general_optimizer.py
│   ├── imports/
│   │   ├── __init__.py
│   │   ├── core.py
│   │   └── torch.py
│   ├── launch.py
│   ├── layers.py
│   ├── metrics.py
│   ├── script.py
│   ├── sixel.py
│   ├── tabular/
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── models.py
│   │   └── transform.py
│   ├── test_registry.json
│   ├── text/
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── interpret.py
│   │   ├── learner.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── awd_lstm.py
│   │   │   ├── bwd_forget_mult_cuda.cpp
│   │   │   ├── bwd_forget_mult_cuda_kernel.cu
│   │   │   ├── forget_mult_cuda.cpp
│   │   │   ├── forget_mult_cuda_kernel.cu
│   │   │   ├── qrnn.py
│   │   │   └── transformer.py
│   │   └── transform.py
│   ├── torch_core.py
│   ├── train.py
│   ├── utils/
│   │   ├── __init__.py
│   │   ├── check_perf.py
│   │   ├── collect_env.py
│   │   ├── ipython.py
│   │   ├── mem.py
│   │   ├── mod_display.py
│   │   ├── pynvml_gate.py
│   │   └── show_install.py
│   ├── version.py
│   ├── vision/
│   │   ├── __init__.py
│   │   ├── cyclegan.py
│   │   ├── data.py
│   │   ├── gan.py
│   │   ├── image.py
│   │   ├── interpret.py
│   │   ├── learner.py
│   │   ├── models/
│   │   │   ├── __init__.py
│   │   │   ├── cadene_models.py
│   │   │   ├── darknet.py
│   │   │   ├── presnet.py
│   │   │   ├── unet.py
│   │   │   ├── wrn.py
│   │   │   ├── xception.py
│   │   │   ├── xresnet.py
│   │   │   └── xresnet2.py
│   │   ├── transform.py
│   │   └── tta.py
│   └── widgets/
│       ├── __init__.py
│       ├── class_confusion.py
│       ├── image_cleaner.py
│       └── image_downloader.py
├── fid/
│   ├── LICENSE
│   ├── fid_score.py
│   └── inception.py
├── models/
│   └── .gitkeep
├── requirements-colab.txt
├── requirements-dev.txt
├── requirements.txt
├── setup.py
├── test_images/
│   └── .gitkeep
└── tox.ini
Download .txt
SYMBOL INDEX (2028 symbols across 91 files)

FILE: deoldify/_device.py
  class DeviceException (line 7) | class DeviceException(Exception):
  class _Device (line 10) | class _Device:
    method __init__ (line 11) | def __init__(self):
    method is_gpu (line 14) | def is_gpu(self):
    method current (line 18) | def current(self):
    method set (line 21) | def set(self, device:DeviceId):

FILE: deoldify/augs.py
  function _noisify (line 6) | def _noisify(

FILE: deoldify/critics.py
  function _conv (line 12) | def _conv(ni: int, nf: int, ks: int = 3, stride: int = 1, **kwargs):
  function custom_gan_critic (line 16) | def custom_gan_critic(
  function colorize_crit_learner (line 36) | def colorize_crit_learner(

FILE: deoldify/dataset.py
  function get_colorize_data (line 7) | def get_colorize_data(
  function get_dummy_databunch (line 42) | def get_dummy_databunch() -> ImageDataBunch:

FILE: deoldify/device_id.py
  class DeviceId (line 3) | class DeviceId(IntEnum):

FILE: deoldify/filters.py
  class IFilter (line 15) | class IFilter(ABC):
    method filter (line 17) | def filter(
  class BaseFilter (line 23) | class BaseFilter(IFilter):
    method __init__ (line 24) | def __init__(self, learn: Learner, stats: tuple = imagenet_stats):
    method _transform (line 34) | def _transform(self, image: PilImage) -> PilImage:
    method _scale_to_square (line 37) | def _scale_to_square(self, orig: PilImage, targ: int) -> PilImage:
    method _get_model_ready_image (line 43) | def _get_model_ready_image(self, orig: PilImage, sz: int) -> PilImage:
    method _model_process (line 48) | def _model_process(self, orig: PilImage, sz: int) -> PilImage:
    method _unsquare (line 70) | def _unsquare(self, image: PilImage, orig: PilImage) -> PilImage:
  class ColorizerFilter (line 76) | class ColorizerFilter(BaseFilter):
    method __init__ (line 77) | def __init__(self, learn: Learner, stats: tuple = imagenet_stats):
    method filter (line 81) | def filter(
    method _transform (line 92) | def _transform(self, image: PilImage) -> PilImage:
    method _post_process (line 100) | def _post_process(self, raw_color: PilImage, orig: PilImage) -> PilImage:
  class MasterFilter (line 113) | class MasterFilter(BaseFilter):
    method __init__ (line 114) | def __init__(self, filters: List[IFilter], render_factor: int):
    method filter (line 118) | def filter(

FILE: deoldify/generators.py
  function gen_inference_wide (line 12) | def gen_inference_wide(
  function gen_learner_wide (line 24) | def gen_learner_wide(
  function unet_learner_wide (line 41) | def unet_learner_wide(
  function gen_inference_deep (line 85) | def gen_inference_deep(
  function gen_learner_deep (line 97) | def gen_learner_deep(
  function unet_learner_deep (line 114) | def unet_learner_deep(

FILE: deoldify/layers.py
  function custom_conv_layer (line 8) | def custom_conv_layer(

FILE: deoldify/loss.py
  class FeatureLoss (line 8) | class FeatureLoss(nn.Module):
    method __init__ (line 9) | def __init__(self, layer_wgts=[20, 70, 10]):
    method _make_features (line 26) | def _make_features(self, x, clone=False):
    method forward (line 30) | def forward(self, input, target):
    method __del__ (line 42) | def __del__(self):
  class WassFeatureLoss (line 47) | class WassFeatureLoss(nn.Module):
    method __init__ (line 48) | def __init__(self, layer_wgts=[5, 15, 2], wass_wgts=[3.0, 0.7, 0.01]):
    method _make_features (line 69) | def _make_features(self, x, clone=False):
    method _calc_2_moments (line 73) | def _calc_2_moments(self, tensor):
    method _get_style_vals (line 85) | def _get_style_vals(self, tensor):
    method _calc_l2wass_dist (line 95) | def _calc_l2wass_dist(
    method _single_wass_loss (line 107) | def _single_wass_loss(self, pred, targ):
    method forward (line 115) | def forward(self, input, target):
    method __del__ (line 135) | def __del__(self):

FILE: deoldify/save.py
  class GANSaveCallback (line 5) | class GANSaveCallback(LearnerCallback):
    method __init__ (line 8) | def __init__(
    method on_batch_end (line 20) | def on_batch_end(self, iteration: int, epoch: int, **kwargs) -> None:
    method _save_gen_learner (line 27) | def _save_gen_learner(self, iteration: int, epoch: int):

FILE: deoldify/unet.py
  function _get_sfs_idxs (line 13) | def _get_sfs_idxs(sizes: Sizes) -> List[int]:
  class CustomPixelShuffle_ICNR (line 24) | class CustomPixelShuffle_ICNR(nn.Module):
    method __init__ (line 27) | def __init__(
    method forward (line 50) | def forward(self, x):
  class UnetBlockDeep (line 55) | class UnetBlockDeep(nn.Module):
    method __init__ (line 58) | def __init__(
    method forward (line 84) | def forward(self, up_in: Tensor) -> Tensor:
  class DynamicUnetDeep (line 94) | class DynamicUnetDeep(SequentialEx):
    method __init__ (line 97) | def __init__(
    method __del__ (line 164) | def __del__(self):
  class UnetBlockWide (line 170) | class UnetBlockWide(nn.Module):
    method __init__ (line 173) | def __init__(
    method forward (line 198) | def forward(self, up_in: Tensor) -> Tensor:
  class DynamicUnetWide (line 208) | class DynamicUnetWide(SequentialEx):
    method __init__ (line 211) | def __init__(
    method __del__ (line 283) | def __del__(self):

FILE: deoldify/visualize.py
  function get_watermarked (line 20) | def get_watermarked(pil_image: Image) -> Image:
  class ModelImageVisualizer (line 47) | class ModelImageVisualizer:
    method __init__ (line 48) | def __init__(self, filter: IFilter, results_dir: str = None):
    method _clean_mem (line 53) | def _clean_mem(self):
    method _open_pil_image (line 57) | def _open_pil_image(self, path: Path) -> Image:
    method _get_image_from_url (line 60) | def _get_image_from_url(self, url: str) -> Image:
    method plot_transformed_image_from_url (line 65) | def plot_transformed_image_from_url(
    method plot_transformed_image (line 91) | def plot_transformed_image(
    method _plot_comparison (line 121) | def _plot_comparison(
    method _plot_solo (line 145) | def _plot_solo(
    method _save_result_image (line 161) | def _save_result_image(self, source_path: Path, image: Image, results_...
    method get_transformed_image (line 168) | def get_transformed_image(
    method _plot_image (line 183) | def _plot_image(
    method _get_num_rows_columns (line 204) | def _get_num_rows_columns(self, num_images: int, max_columns: int) -> ...
  class VideoColorizer (line 211) | class VideoColorizer:
    method __init__ (line 212) | def __init__(self, vis: ModelImageVisualizer):
    method _purge_images (line 221) | def _purge_images(self, dir):
    method _get_ffmpeg_probe (line 226) | def _get_ffmpeg_probe(self, path:Path):
    method _get_fps (line 239) | def _get_fps(self, source_path: Path) -> str:
    method _download_video_from_url (line 247) | def _download_video_from_url(self, source_url, source_path: Path):
    method _extract_raw_frames (line 260) | def _extract_raw_frames(self, source_path: Path):
    method _colorize_raw_frames (line 286) | def _colorize_raw_frames(
    method _build_video (line 304) | def _build_video(self, source_path: Path) -> Path:
    method colorize_from_url (line 373) | def colorize_from_url(
    method colorize_from_file_name (line 388) | def colorize_from_file_name(
    method _colorize_from_path (line 396) | def _colorize_from_path(
  function get_video_colorizer (line 410) | def get_video_colorizer(render_factor: int = 21) -> VideoColorizer:
  function get_artistic_video_colorizer (line 414) | def get_artistic_video_colorizer(
  function get_stable_video_colorizer (line 426) | def get_stable_video_colorizer(
  function get_image_colorizer (line 438) | def get_image_colorizer(
  function get_stable_image_colorizer (line 447) | def get_stable_image_colorizer(
  function get_artistic_image_colorizer (line 459) | def get_artistic_image_colorizer(
  function show_image_in_notebook (line 471) | def show_image_in_notebook(image_path: Path):
  function show_video_in_notebook (line 475) | def show_video_in_notebook(video_path: Path):

FILE: fastai/basic_data.py
  function intercept_args (line 10) | def intercept_args(self, dataset, batch_size=1, shuffle=False, sampler=N...
  function DataLoader___getattr__ (line 20) | def DataLoader___getattr__(dl, k:str)->Any: return getattr(dl.dataset, k)
  function DataLoader___setstate__ (line 23) | def DataLoader___setstate__(dl, data:Any): dl.__dict__.update(data)
  class DeviceDataLoader (line 27) | class DeviceDataLoader():
    method __post_init__ (line 33) | def __post_init__(self):
    method __len__ (line 37) | def __len__(self)->int: return len(self.dl)
    method __getattr__ (line 38) | def __getattr__(self,k:str)->Any: return getattr(self.dl, k)
    method __setstate__ (line 39) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method batch_size (line 42) | def batch_size(self):   return self.dl.batch_size
    method batch_size (line 44) | def batch_size(self,v):
    method num_workers (line 50) | def num_workers(self):   return self.dl.num_workers
    method num_workers (line 52) | def num_workers(self,v): self.dl.num_workers = v
    method add_tfm (line 54) | def add_tfm(self,tfm:Callable)->None:
    method remove_tfm (line 57) | def remove_tfm(self,tfm:Callable)->None:
    method new (line 61) | def new(self, **kwargs):
    method proc_batch (line 67) | def proc_batch(self,b:Tensor)->Tensor:
    method __iter__ (line 73) | def __iter__(self):
    method create (line 78) | def create(cls, dataset:Dataset, bs:int=64, shuffle:bool=False, device...
  class DataBunch (line 84) | class DataBunch():
    method __init__ (line 87) | def __init__(self, train_dl:DataLoader, valid_dl:DataLoader, fix_dl:Da...
    method __repr__ (line 102) | def __repr__(self)->str:
    method _init_ds (line 106) | def _init_ds(train_ds:Dataset, valid_ds:Dataset, test_ds:Optional[Data...
    method create (line 112) | def create(cls, train_ds:Dataset, valid_ds:Dataset, test_ds:Optional[D...
    method __getattr__ (line 122) | def __getattr__(self,k:int)->Any: return getattr(self.train_dl, k)
    method __setstate__ (line 123) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method dl (line 125) | def dl(self, ds_type:DatasetType=DatasetType.Valid)->DeviceDataLoader:
    method dls (line 135) | def dls(self)->List[DeviceDataLoader]:
    method add_tfm (line 143) | def add_tfm(self,tfm:Callable)->None:
    method remove_tfm (line 146) | def remove_tfm(self,tfm:Callable)->None:
    method save (line 149) | def save(self, file:PathLikeOrBinaryStream= 'data_save.pkl')->None:
    method add_test (line 156) | def add_test(self, items:Iterator, label:Any=None, tfms=None, tfm_y=No...
    method one_batch (line 163) | def one_batch(self, ds_type:DatasetType=DatasetType.Train, detach:bool...
    method one_item (line 177) | def one_item(self, item, detach:bool=False, denorm:bool=False, cpu:boo...
    method show_batch (line 183) | def show_batch(self, rows:int=5, ds_type:DatasetType=DatasetType.Train...
    method export (line 196) | def export(self, file:PathLikeOrBinaryStream='export.pkl'):
    method _grab_dataset (line 201) | def _grab_dataset(self, dl:DataLoader):
    method train_ds (line 207) | def train_ds(self)->Dataset: return self._grab_dataset(self.train_dl)
    method valid_ds (line 209) | def valid_ds(self)->Dataset: return self._grab_dataset(self.valid_dl)
    method single_ds (line 211) | def single_ds(self)->Dataset: return self._grab_dataset(self.single_dl)
    method loss_func (line 213) | def loss_func(self)->OptLossFunc:
    method test_ds (line 217) | def test_ds(self)->Dataset:
    method empty_val (line 221) | def empty_val(self)->bool:
    method is_empty (line 227) | def is_empty(self)->bool:
    method batch_size (line 233) | def batch_size(self):   return self.train_dl.batch_size
    method batch_size (line 235) | def batch_size(self,v):
    method sanity_check (line 239) | def sanity_check(self):
  function load_data (line 272) | def load_data(path:PathOrStr, file:PathLikeOrBinaryStream='data_save.pkl...

FILE: fastai/basic_train.py
  function loss_batch (line 20) | def loss_batch(model:nn.Module, xb:Tensor, yb:Tensor, loss_func:OptLossF...
  function get_preds (line 43) | def get_preds(model:nn.Module, dl:DataLoader, pbar:Optional[PBar]=None, ...
  function validate (line 53) | def validate(model:nn.Module, dl:DataLoader, loss_func:OptLossFunc=None,...
  function train_epoch (line 72) | def train_epoch(model:nn.Module, dl:DataLoader, opt:optim.Optimizer, los...
  class BasicLearner (line 82) | class BasicLearner():
  function fit (line 88) | def fit(epochs:int, learn:BasicLearner, callbacks:Optional[CallbackList]...
  function _loss_func_name2activ (line 123) | def _loss_func_name2activ(name:str, axis:int=-1):
  function _loss_func2activ (line 128) | def _loss_func2activ(loss_func):
  class Learner (line 148) | class Learner():
    method __post_init__ (line 166) | def __post_init__(self)->None:
    method init (line 177) | def init(self, init): apply_init(self.model, init)
    method _test_writeable_path (line 179) | def _test_writeable_path(self):
    method lr_range (line 188) | def lr_range(self, lr:Union[float,slice])->np.ndarray:
    method fit (line 195) | def fit(self, epochs:int, lr:Union[Floats,slice]=defaults.lr,
    method create_opt (line 206) | def create_opt(self, lr:Floats, wd:Floats=0.)->None:
    method split (line 210) | def split(self, split_on:SplitFuncOrIdxList)->None:
    method freeze_to (line 216) | def freeze_to(self, n:int)->None:
    method freeze (line 224) | def freeze(self)->None:
    method unfreeze (line 229) | def unfreeze(self):
    method export (line 233) | def export(self, file:PathLikeOrBinaryStream='export.pkl', destroy=Fal...
    method save (line 249) | def save(self, file:PathLikeOrBinaryStream=None, return_path:bool=Fals...
    method dl (line 260) | def dl(self, ds_type:DatasetType=DatasetType.Valid):
    method load (line 264) | def load(self, file:PathLikeOrBinaryStream=None, device:torch.device=N...
    method destroy (line 288) | def destroy(self):
    method purge (line 305) | def purge(self, clear_opt:bool=True):
    method get_preds (line 335) | def get_preds(self, ds_type:DatasetType=DatasetType.Valid, with_loss:b...
    method pred_batch (line 342) | def pred_batch(self, ds_type:DatasetType=DatasetType.Valid, batch:Tupl...
    method backward (line 365) | def backward(self, item):
    method predict (line 372) | def predict(self, item:ItemBase, return_x:bool=False, batch_first:bool...
    method validate (line 387) | def validate(self, dl=None, callbacks=None, metrics=None):
    method show_results (line 397) | def show_results(self, ds_type=DatasetType.Valid, rows:int=5, **kwargs):
    method apply_dropout (line 425) | def apply_dropout(self, m):
    method predict_with_mc_dropout (line 429) | def predict_with_mc_dropout(self, item:ItemBase, with_dropout:bool=Tru...
  class RecordOnCPU (line 433) | class RecordOnCPU(Callback):
    method on_batch_begin (line 435) | def on_batch_begin(self, last_input,last_target,**kwargs):
  class LearnerCallback (line 438) | class LearnerCallback(Callback):
    method __init__ (line 440) | def __init__(self, learn):
    method __getattr__ (line 445) | def __getattr__(self,k): return getattr(self.learn, k)
    method __setstate__ (line 446) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method learn (line 449) | def learn(self) -> Learner: return self._learn()
    method learn (line 451) | def learn(self, learn: Learner) -> None: self._learn = weakref.ref(learn)
    method cb_name (line 454) | def cb_name(self): return camel2snake(self.__class__.__name__)
  class Recorder (line 456) | class Recorder(LearnerCallback):
    method __init__ (line 459) | def __init__(self, learn:Learner, add_time:bool=True, silent:bool=False):
    method on_train_begin (line 465) | def on_train_begin(self, pbar:PBar, metrics_names:Collection[str], **k...
    method on_epoch_begin (line 476) | def on_epoch_begin(self, **kwargs:Any)->None:
    method on_batch_begin (line 479) | def on_batch_begin(self, train, **kwargs:Any)->None:
    method on_backward_begin (line 485) | def on_backward_begin(self, smooth_loss:Tensor, **kwargs:Any)->None:
    method on_epoch_end (line 491) | def on_epoch_end(self, epoch:int, num_batch:int, smooth_loss:Tensor,
    method format_stats (line 500) | def format_stats(self, stats:TensorOrNumList)->None:
    method add_metric_names (line 508) | def add_metric_names(self, names):
    method plot_lr (line 513) | def plot_lr(self, show_moms=False, skip_start:int=0, skip_end:int=0, r...
    method smoothen_by_spline (line 535) | def smoothen_by_spline(xs, ys, **kwargs):
    method plot (line 541) | def plot(self, skip_start:int=10, skip_end:int=5, suggestion:bool=Fals...
    method plot_losses (line 567) | def plot_losses(self, skip_start:int=0, skip_end:int=0, return_fig:boo...
    method plot_metrics (line 582) | def plot_metrics(self, skip_start:int=0, skip_end:int=0, return_fig:bo...
    method _split_list (line 597) | def _split_list(self, vals:Collection[float], skip_start:int, skip_end...
    method _split_list_val (line 600) | def _split_list_val(self, vals:Collection[float], skip_start:int, skip...
  class FakeOptimizer (line 606) | class FakeOptimizer():
    method step (line 607) | def step(self): pass
    method zero_grad (line 608) | def zero_grad(self): pass
  function load_callback (line 610) | def load_callback(class_func, state, learn:Learner):
  function load_learner (line 616) | def load_learner(path:PathOrStr, file:PathLikeOrBinaryStream='export.pkl...

FILE: fastai/callback.py
  class OptimWrapper (line 9) | class OptimWrapper():
    method __init__ (line 11) | def __init__(self, opt:optim.Optimizer, wd:Floats=0., true_wd:bool=Fal...
    method create (line 20) | def create(cls, opt_func:Union[type,Callable], lr:Union[float,Tuple,Li...
    method new (line 29) | def new(self, layer_groups:Collection[nn.Module], split_no_wd:bool=True):
    method new_with_params (line 36) | def new_with_params(self, param_groups:Collection[Collection[nn.Parame...
    method __repr__ (line 44) | def __repr__(self)->str:
    method step (line 48) | def step(self)->None:
    method zero_grad (line 59) | def zero_grad(self)->None:
    method __getattr__ (line 64) | def __getattr__(self, k:str)->Any: return getattr(self.opt, k, None)
    method __setstate__ (line 65) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method clear (line 67) | def clear(self):
    method n_params (line 74) | def n_params(self): return sum([len(pg['params']) for pg in self.opt.p...
    method lr (line 78) | def lr(self)->float: return self._lr[-1]
    method lr (line 80) | def lr(self, val:float)->None:
    method mom (line 84) | def mom(self)->float:return self._mom[-1]
    method mom (line 86) | def mom(self, val:float)->None:
    method beta (line 92) | def beta(self)->float: return None if self._beta is None else self._be...
    method beta (line 94) | def beta(self, val:float)->None:
    method wd (line 102) | def wd(self)->float: return self._wd[-1]
    method wd (line 104) | def wd(self, val:float)->None:
    method read_defaults (line 110) | def read_defaults(self)->None:
    method get_stat (line 122) | def get_stat(self, name:str)->float:
    method set_stat (line 125) | def set_stat(self, name:str, value:Union[float, Collection[float]])->N...
    method set_val (line 132) | def set_val(self, key:str, val:Any, bn_groups:bool=True)->Any:
    method read_val (line 140) | def read_val(self, key:str) -> Union[List[float],Tuple[List[float],Lis...
    method get_state (line 146) | def get_state(self):
    method load_with_state_and_layer_group (line 152) | def load_with_state_and_layer_group(cls, state:dict, layer_groups:Coll...
  class Callback (line 159) | class Callback():
    method on_train_begin (line 162) | def on_train_begin(self, **kwargs:Any)->None:
    method on_epoch_begin (line 165) | def on_epoch_begin(self, **kwargs:Any)->None:
    method on_batch_begin (line 168) | def on_batch_begin(self, **kwargs:Any)->None:
    method on_loss_begin (line 171) | def on_loss_begin(self, **kwargs:Any)->None:
    method on_backward_begin (line 174) | def on_backward_begin(self, **kwargs:Any)->None:
    method on_backward_end (line 177) | def on_backward_end(self, **kwargs:Any)->None:
    method on_step_end (line 180) | def on_step_end(self, **kwargs:Any)->None:
    method on_batch_end (line 183) | def on_batch_end(self, **kwargs:Any)->None:
    method on_epoch_end (line 186) | def on_epoch_end(self, **kwargs:Any)->None:
    method on_train_end (line 189) | def on_train_end(self, **kwargs:Any)->None:
    method jump_to_epoch (line 192) | def jump_to_epoch(self, epoch)->None:
    method get_state (line 196) | def get_state(self, minimal:bool=True):
    method __repr__ (line 202) | def  __repr__(self):
  class SmoothenValue (line 208) | class SmoothenValue():
    method __init__ (line 210) | def __init__(self, beta:float):
    method add_value (line 213) | def add_value(self, val:float)->None:
  function _get_init_state (line 221) | def _get_init_state(): return {'epoch':0, 'iteration':0, 'num_batch':0, ...
  class CallbackHandler (line 224) | class CallbackHandler():
    method __post_init__ (line 230) | def __post_init__(self)->None:
    method _call_and_update (line 239) | def _call_and_update(self, cb, cb_name, **kwargs)->None:
    method __call__ (line 247) | def __call__(self, cb_name, call_mets=True, **kwargs)->None:
    method set_dl (line 253) | def set_dl(self, dl:DataLoader):
    method on_train_begin (line 260) | def on_train_begin(self, epochs:int, pbar:PBar, metrics:MetricFuncList...
    method on_epoch_begin (line 270) | def on_epoch_begin(self)->None:
    method on_batch_begin (line 275) | def on_batch_begin(self, xb:Tensor, yb:Tensor, train:bool=True)->Tuple...
    method on_loss_begin (line 282) | def on_loss_begin(self, out:Tensor)->Any:
    method on_backward_begin (line 288) | def on_backward_begin(self, loss:Tensor)->Tuple[Any,Any]:
    method on_backward_end (line 295) | def on_backward_end(self)->Any:
    method on_step_end (line 300) | def on_step_end(self)->Any:
    method on_batch_end (line 305) | def on_batch_end(self, loss:Tensor)->Any:
    method on_epoch_end (line 314) | def on_epoch_end(self, val_loss:Tensor)->bool:
    method on_train_end (line 321) | def on_train_end(self, exception:Union[bool,Exception])->None:
    method skip_validate (line 326) | def skip_validate(self): return self.state_dict['skip_validate']
  class AverageMetric (line 328) | class AverageMetric(Callback):
    method __init__ (line 330) | def __init__(self, func):
    method on_epoch_begin (line 336) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 340) | def on_batch_end(self, last_output, last_target, **kwargs):
    method on_epoch_end (line 351) | def on_epoch_end(self, last_metrics, **kwargs):
  function annealing_no (line 355) | def annealing_no(start:Number, end:Number, pct:float)->Number:
  function annealing_linear (line 358) | def annealing_linear(start:Number, end:Number, pct:float)->Number:
  function annealing_exp (line 361) | def annealing_exp(start:Number, end:Number, pct:float)->Number:
  function annealing_cos (line 364) | def annealing_cos(start:Number, end:Number, pct:float)->Number:
  function do_annealing_poly (line 369) | def do_annealing_poly(start:Number, end:Number, pct:float, degree:Number...
  function annealing_poly (line 372) | def annealing_poly(degree:Number)->Number:
  class Scheduler (line 376) | class Scheduler():
    method __init__ (line 378) | def __init__(self, vals:StartOptEnd, n_iter:int, func:Optional[AnnealF...
    method restart (line 385) | def restart(self): self.n = 0
    method step (line 387) | def step(self)->Number:
    method is_done (line 393) | def is_done(self)->bool:

FILE: fastai/callbacks/csv_logger.py
  class CSVLogger (line 12) | class CSVLogger(LearnerCallback):
    method __init__ (line 14) | def __init__(self, learn:Learner, filename: str = 'history', append: b...
    method read_logged_file (line 19) | def read_logged_file(self):
    method on_train_begin (line 23) | def on_train_begin(self, **kwargs: Any) -> None:
    method on_epoch_begin (line 29) | def on_epoch_begin(self, **kwargs:Any)->None:
    method on_epoch_end (line 32) | def on_epoch_end(self, epoch: int, smooth_loss: Tensor, last_metrics: ...
    method on_train_end (line 41) | def on_train_end(self, **kwargs: Any) -> None:

FILE: fastai/callbacks/fp16.py
  function get_master (line 10) | def get_master(layer_groups:ModuleList, flat_master:bool=False) -> Tuple...
  function model_g2master_g (line 30) | def model_g2master_g(model_params:Sequence[Tensor], master_params:Sequen...
  function master2model (line 45) | def master2model(model_params:Sequence[Tensor], master_params:Sequence[T...
  function grad_overflow (line 56) | def grad_overflow(param_group):
  class MixedPrecision (line 64) | class MixedPrecision(LearnerCallback):
    method __init__ (line 67) | def __init__(self, learn:Learner, loss_scale:float=None, max_noskip:in...
    method on_train_begin (line 76) | def on_train_begin(self, **kwargs:Any)->None:
    method on_loss_begin (line 88) | def on_loss_begin(self, last_output:Tensor, **kwargs:Any) -> Tensor:
    method on_backward_begin (line 92) | def on_backward_begin(self, last_loss:Rank0Tensor, **kwargs:Any) -> Ra...
    method on_backward_end (line 98) | def on_backward_end(self, **kwargs:Any)->None:
    method on_step_end (line 117) | def on_step_end(self, **kwargs:Any)->None:

FILE: fastai/callbacks/general_sched.py
  class TrainingPhase (line 8) | class TrainingPhase():
    method __post_init__ (line 12) | def __post_init__(self): self.scheds = dict()
    method schedule_hp (line 13) | def schedule_hp(self, name, vals, anneal=None):
  class GeneralScheduler (line 18) | class GeneralScheduler(LearnerCallback):
    method __init__ (line 20) | def __init__(self, learn:Learner, phases:Collection[TrainingPhase], st...
    method on_train_begin (line 24) | def on_train_begin(self, epoch:int, **kwargs:Any)->None:
    method jump_to_epoch (line 36) | def jump_to_epoch(self, epoch:int)->None:
    method on_batch_end (line 40) | def on_batch_end(self, train, **kwargs:Any)->None:

FILE: fastai/callbacks/hooks.py
  class Hook (line 10) | class Hook():
    method __init__ (line 12) | def __init__(self, m:nn.Module, hook_func:HookFunc, is_forward:bool=Tr...
    method hook_fn (line 18) | def hook_fn(self, module:nn.Module, input:Tensors, output:Tensors):
    method remove (line 25) | def remove(self):
    method __enter__ (line 31) | def __enter__(self, *args): return self
    method __exit__ (line 32) | def __exit__(self, *args): self.remove()
  class Hooks (line 34) | class Hooks():
    method __init__ (line 36) | def __init__(self, ms:Collection[nn.Module], hook_func:HookFunc, is_fo...
    method __getitem__ (line 39) | def __getitem__(self,i:int)->Hook: return self.hooks[i]
    method __len__ (line 40) | def __len__(self)->int: return len(self.hooks)
    method __iter__ (line 41) | def __iter__(self): return iter(self.hooks)
    method stored (line 43) | def stored(self): return [o.stored for o in self]
    method remove (line 45) | def remove(self):
    method __enter__ (line 49) | def __enter__(self, *args): return self
    method __exit__ (line 50) | def __exit__ (self, *args): self.remove()
  function _hook_inner (line 52) | def _hook_inner(m,i,o): return o if isinstance(o,Tensor) else o if is_li...
  function hook_output (line 54) | def hook_output (module:nn.Module, detach:bool=True, grad:bool=False)->H...
  function hook_outputs (line 58) | def hook_outputs(modules:Collection[nn.Module], detach:bool=True, grad:b...
  class HookCallback (line 62) | class HookCallback(LearnerCallback):
    method __init__ (line 64) | def __init__(self, learn:Learner, modules:Sequence[nn.Module]=None, do...
    method on_train_begin (line 68) | def on_train_begin(self, **kwargs):
    method on_train_end (line 75) | def on_train_end(self, **kwargs):
    method remove (line 79) | def remove(self):
    method __del__ (line 81) | def __del__(self): self.remove()
  class ActivationStats (line 83) | class ActivationStats(HookCallback):
    method on_train_begin (line 86) | def on_train_begin(self, **kwargs):
    method hook (line 91) | def hook(self, m:nn.Module, i:Tensors, o:Tensors)->Tuple[Rank0Tensor,R...
    method on_batch_end (line 94) | def on_batch_end(self, train, **kwargs):
    method on_train_end (line 97) | def on_train_end(self, **kwargs):
  function dummy_batch (line 102) | def dummy_batch(m: nn.Module, size:tuple=(64,64))->Tensor:
  function dummy_eval (line 107) | def dummy_eval(m:nn.Module, size:tuple=(64,64)):
  function model_sizes (line 113) | def model_sizes(m:nn.Module, size:tuple=(64,64))->Tuple[Sizes,Tensor,Hoo...
  function num_features_model (line 119) | def num_features_model(m:nn.Module)->int:
  function total_params (line 128) | def total_params(m:nn.Module)->int:
  function hook_params (line 136) | def hook_params(modules:Collection[nn.Module])->Hooks:
  function params_size (line 139) | def params_size(m: Union[nn.Module,Learner], size: tuple = (3, 64, 64))-...
  function get_layer_name (line 158) | def get_layer_name(layer:nn.Module)->str:
  function layers_info (line 161) | def layers_info(m:Collection[nn.Module]) -> Collection[namedtuple]:
  function model_summary (line 168) | def model_summary(m:Learner, n:int=70):

FILE: fastai/callbacks/loss_metrics.py
  class LossMetrics (line 7) | class LossMetrics(LearnerCallback):
    method on_train_begin (line 11) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 17) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 22) | def on_batch_end(self, last_target, train, **kwargs):
    method on_epoch_end (line 30) | def on_epoch_end(self, last_metrics, **kwargs):

FILE: fastai/callbacks/lr_finder.py
  class LRFinder (line 9) | class LRFinder(LearnerCallback):
    method __init__ (line 11) | def __init__(self, learn:Learner, start_lr:float=1e-7, end_lr:float=10...
    method on_train_begin (line 16) | def on_train_begin(self, pbar, **kwargs:Any)->None:
    method on_batch_end (line 25) | def on_batch_end(self, iteration:int, smooth_loss:TensorOrNumber, **kw...
    method on_train_end (line 33) | def on_train_end(self, **kwargs:Any)->None:

FILE: fastai/callbacks/mem.py
  class PeakMemMetric (line 11) | class PeakMemMetric(LearnerCallback):
    method __init__ (line 16) | def __init__(self, learn:Learner):
    method peak_monitor_start (line 21) | def peak_monitor_start(self):
    method peak_monitor_stop (line 32) | def peak_monitor_stop(self):
    method peak_monitor_func (line 36) | def peak_monitor_func(self):
    method on_train_begin (line 48) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 51) | def on_epoch_begin(self, **kwargs):
    method on_epoch_end (line 55) | def on_epoch_end(self, last_metrics, **kwargs):

FILE: fastai/callbacks/misc.py
  class StopAfterNBatches (line 5) | class StopAfterNBatches(Callback):
    method __init__ (line 7) | def __init__(self, n_batches:int=2):
    method on_batch_end (line 10) | def on_batch_end(self, iteration, **kwargs):

FILE: fastai/callbacks/mixup.py
  class MixUpCallback (line 6) | class MixUpCallback(LearnerCallback):
    method __init__ (line 8) | def __init__(self, learn:Learner, alpha:float=0.4, stack_x:bool=False,...
    method on_train_begin (line 12) | def on_train_begin(self, **kwargs):
    method on_batch_begin (line 15) | def on_batch_begin(self, last_input, last_target, train, **kwargs):
    method on_train_end (line 36) | def on_train_end(self, **kwargs):
  class MixUpLoss (line 40) | class MixUpLoss(Module):
    method __init__ (line 43) | def __init__(self, crit, reduction='mean'):
    method forward (line 54) | def forward(self, output, target):
    method get_old (line 63) | def get_old(self):

FILE: fastai/callbacks/mlflow.py
  class MLFlowTracker (line 9) | class MLFlowTracker(LearnerCallback):
    method __init__ (line 11) | def __init__(self, learn:Learner, exp_name: str, params: dict, nb_path...
    method on_train_begin (line 16) | def on_train_begin(self, **kwargs: Any) -> None:
    method on_epoch_end (line 26) | def on_epoch_end(self, epoch, **kwargs:Any)->None:
    method on_train_end (line 33) | def on_train_end(self, **kwargs: Any) -> None:

FILE: fastai/callbacks/one_cycle.py
  class OneCycleScheduler (line 8) | class OneCycleScheduler(LearnerCallback):
    method __init__ (line 10) | def __init__(self, learn:Learner, lr_max:float, moms:Floats=(0.95,0.85...
    method steps (line 19) | def steps(self, *steps_cfg:StartOptEnd):
    method on_train_begin (line 24) | def on_train_begin(self, n_epochs:int, epoch:int, **kwargs:Any)->None:
    method jump_to_epoch (line 41) | def jump_to_epoch(self, epoch:int)->None:
    method on_batch_end (line 45) | def on_batch_end(self, train, **kwargs:Any)->None:
    method on_epoch_end (line 56) | def on_epoch_end(self, epoch, **kwargs:Any)->None:

FILE: fastai/callbacks/oversampling.py
  class OverSamplingCallback (line 11) | class OverSamplingCallback(LearnerCallback):
    method __init__ (line 12) | def __init__(self,learn:Learner,weights:torch.Tensor=None):
    method on_train_begin (line 21) | def on_train_begin(self, **kwargs):

FILE: fastai/callbacks/rnn.py
  class RNNTrainer (line 8) | class RNNTrainer(LearnerCallback):
    method __init__ (line 10) | def __init__(self, learn:Learner, alpha:float=0., beta:float=0.):
    method on_epoch_begin (line 15) | def on_epoch_begin(self, **kwargs):
    method on_loss_begin (line 19) | def on_loss_begin(self, last_output:Tuple[Tensor,Tensor,Tensor], **kwa...
    method on_backward_begin (line 24) | def on_backward_begin(self, last_loss:Rank0Tensor, last_input:Tensor, ...

FILE: fastai/callbacks/tensorboard.py
  class LearnerTensorboardWriter (line 26) | class LearnerTensorboardWriter(LearnerCallback):
    method __init__ (line 28) | def __init__(self, learn:Learner, base_dir:Path, name:str, loss_iters:...
    method _get_new_batch (line 40) | def _get_new_batch(self, ds_type:DatasetType)->Collection[Tensor]:
    method _update_batches_if_needed (line 44) | def _update_batches_if_needed(self)->None:
    method _write_model_stats (line 53) | def _write_model_stats(self, iteration:int)->None:
    method _write_training_loss (line 57) | def _write_training_loss(self, iteration:int, last_loss:Tensor)->None:
    method _write_weight_histograms (line 63) | def _write_weight_histograms(self, iteration:int)->None:
    method _write_scalar (line 67) | def _write_scalar(self, name:str, scalar_value, iteration:int)->None:
    method _write_metrics (line 73) | def _write_metrics(self, iteration:int, last_metrics:MetricsList, star...
    method on_train_begin (line 81) | def on_train_begin(self, **kwargs: Any) -> None:
    method on_batch_end (line 86) | def on_batch_end(self, last_loss:Tensor, iteration:int, **kwargs)->None:
    method on_backward_end (line 94) | def on_backward_end(self, iteration:int, **kwargs)->None:
    method on_epoch_end (line 100) | def on_epoch_end(self, last_metrics:MetricsList, iteration:int, **kwar...
  class GANTensorboardWriter (line 105) | class GANTensorboardWriter(LearnerTensorboardWriter):
    method __init__ (line 107) | def __init__(self, learn:GANLearner, base_dir:Path, name:str, loss_ite...
    method _write_weight_histograms (line 115) | def _write_weight_histograms(self, iteration:int)->None:
    method _write_gen_model_stats (line 121) | def _write_gen_model_stats(self, iteration:int)->None:
    method _write_critic_model_stats (line 127) | def _write_critic_model_stats(self, iteration:int)->None:
    method _write_model_stats (line 133) | def _write_model_stats(self, iteration:int)->None:
    method _write_training_loss (line 140) | def _write_training_loss(self, iteration:int, last_loss:Tensor)->None:
    method _write_images (line 148) | def _write_images(self, iteration:int)->None:
    method on_batch_end (line 159) | def on_batch_end(self, iteration:int, **kwargs)->None:
    method on_backward_end (line 165) | def on_backward_end(self, iteration:int, **kwargs)->None:
  class ImageGenTensorboardWriter (line 174) | class ImageGenTensorboardWriter(LearnerTensorboardWriter):
    method __init__ (line 176) | def __init__(self, learn:Learner, base_dir:Path, name:str, loss_iters:...
    method _write_images (line 183) | def _write_images(self, iteration:int)->None:
    method on_batch_end (line 188) | def on_batch_end(self, iteration:int, **kwargs)->None:
  class TBWriteRequest (line 195) | class TBWriteRequest(ABC):
    method __init__ (line 197) | def __init__(self, tbwriter: SummaryWriter, iteration:int):
    method write (line 203) | def write(self)->None: pass
  class AsyncTBWriter (line 209) | class AsyncTBWriter():
    method __init__ (line 211) | def __init__(self):
    method request_write (line 218) | def request_write(self, request: TBWriteRequest)->None:
    method _queue_processor (line 223) | def _queue_processor(self)->None:
    method close (line 234) | def close(self)->None:
    method __enter__ (line 241) | def __enter__(self): pass
    method __exit__ (line 243) | def __exit__(self, exc_type, exc_value, traceback): self.close()
  class ModelImageSet (line 247) | class ModelImageSet():
    method get_list_from_model (line 250) | def get_list_from_model(learn:Learner, ds_type:DatasetType, batch:Tupl...
    method __init__ (line 262) | def __init__(self, orig:Image, real:Image, gen:Image): self.orig, self...
  class HistogramTBRequest (line 264) | class HistogramTBRequest(TBWriteRequest):
    method __init__ (line 266) | def __init__(self, model:nn.Module, iteration:int, tbwriter:SummaryWri...
    method _write_histogram (line 271) | def _write_histogram(self, param_name:str, values)->None:
    method write (line 276) | def write(self)->None:
  class HistogramTBWriter (line 281) | class HistogramTBWriter():
    method __init__ (line 283) | def __init__(self): super().__init__()
    method write (line 285) | def write(self, model:nn.Module, iteration:int, tbwriter:SummaryWriter...
  class ModelStatsTBRequest (line 290) | class ModelStatsTBRequest(TBWriteRequest):
    method __init__ (line 292) | def __init__(self, model:nn.Module, iteration:int, tbwriter:SummaryWri...
    method _add_gradient_scalar (line 297) | def _add_gradient_scalar(self, name:str, scalar_value)->None:
    method _write_avg_norm (line 302) | def _write_avg_norm(self, norms:[])->None:
    method _write_median_norm (line 307) | def _write_median_norm(self, norms:[])->None:
    method _write_max_norm (line 312) | def _write_max_norm(self, norms:[])->None:
    method _write_min_norm (line 317) | def _write_min_norm(self, norms:[])->None:
    method _write_num_zeros (line 322) | def _write_num_zeros(self)->None:
    method _write_avg_gradient (line 328) | def _write_avg_gradient(self)->None:
    method _write_median_gradient (line 333) | def _write_median_gradient(self)->None:
    method _write_max_gradient (line 338) | def _write_max_gradient(self)->None:
    method _write_min_gradient (line 343) | def _write_min_gradient(self)->None:
    method write (line 348) | def write(self)->None:
  class ModelStatsTBWriter (line 362) | class ModelStatsTBWriter():
    method write (line 364) | def write(self, model:nn.Module, iteration:int, tbwriter:SummaryWriter...
  class ImageTBRequest (line 369) | class ImageTBRequest(TBWriteRequest):
    method __init__ (line 371) | def __init__(self, learn:Learner, batch:Tuple, iteration:int, tbwriter...
    method _write_images (line 376) | def _write_images(self, name:str, images:[Tensor])->None:
    method _get_image_tensors (line 381) | def _get_image_tensors(self)->([Tensor], [Tensor], [Tensor]):
    method write (line 390) | def write(self)->None:
  class ImageTBWriter (line 398) | class ImageTBWriter():
    method __init__ (line 400) | def __init__(self): super().__init__()
    method write (line 402) | def write(self, learn:Learner, trn_batch:Tuple, val_batch:Tuple, itera...
    method _write_for_dstype (line 407) | def _write_for_dstype(self, learn:Learner, batch:Tuple, iteration:int,...
  class GraphTBRequest (line 412) | class GraphTBRequest(TBWriteRequest):
    method __init__ (line 414) | def __init__(self, model:nn.Module, tbwriter:SummaryWriter, input_to_m...
    method write (line 418) | def write(self)->None:
  class GraphTBWriter (line 422) | class GraphTBWriter():
    method write (line 424) | def write(self, model:nn.Module, tbwriter:SummaryWriter, input_to_mode...

FILE: fastai/callbacks/tracker.py
  class TerminateOnNaNCallback (line 10) | class TerminateOnNaNCallback(Callback):
    method __init__ (line 13) | def __init__(self):
    method on_batch_end (line 16) | def on_batch_end(self, last_loss, epoch, num_batch, **kwargs:Any)->None:
  class TrackerCallback (line 23) | class TrackerCallback(LearnerCallback):
    method __init__ (line 25) | def __init__(self, learn:Learner, monitor:str='valid_loss', mode:str='...
    method on_train_begin (line 35) | def on_train_begin(self, **kwargs:Any)->None:
    method get_monitor_value (line 39) | def get_monitor_value(self):
  class EarlyStoppingCallback (line 53) | class EarlyStoppingCallback(TrackerCallback):
    method __init__ (line 55) | def __init__(self, learn:Learner, monitor:str='valid_loss', mode:str='...
    method on_train_begin (line 60) | def on_train_begin(self, **kwargs:Any)->None:
    method on_epoch_end (line 65) | def on_epoch_end(self, epoch, **kwargs:Any)->None:
  class SaveModelCallback (line 77) | class SaveModelCallback(TrackerCallback):
    method __init__ (line 79) | def __init__(self, learn:Learner, monitor:str='valid_loss', mode:str='...
    method jump_to_epoch (line 86) | def jump_to_epoch(self, epoch:int)->None:
    method on_epoch_end (line 92) | def on_epoch_end(self, epoch:int, **kwargs:Any)->None:
    method on_train_end (line 102) | def on_train_end(self, **kwargs):
  class ReduceLROnPlateauCallback (line 107) | class ReduceLROnPlateauCallback(TrackerCallback):
    method __init__ (line 109) | def __init__(self, learn:Learner, monitor:str='valid_loss', mode:str='...
    method on_train_begin (line 115) | def on_train_begin(self, **kwargs:Any)->None:
    method on_epoch_end (line 120) | def on_epoch_end(self, epoch, **kwargs:Any)->None:
  class TrackEpochCallback (line 133) | class TrackEpochCallback(LearnerCallback):
    method __init__ (line 135) | def __init__(self, learn:Learner, name:str='epoch', epoch_offset:int=N...
    method on_train_begin (line 147) | def on_train_begin(self, **kwargs:Any):
    method on_epoch_end (line 150) | def on_epoch_end(self, epoch, **kwargs:Any)->None:
    method restart (line 153) | def restart(self): os.remove(self.path)

FILE: fastai/collab.py
  class CollabProcessor (line 8) | class CollabProcessor(TabularProcessor):
    method process_one (line 10) | def process_one(self, item):
  class CollabLine (line 14) | class CollabLine(TabularLine):
    method __init__ (line 16) | def __init__(self, cats, conts, classes, names):
  class CollabList (line 20) | class CollabList(TabularList):
    method reconstruct (line 24) | def reconstruct(self, t:Tensor): return CollabLine(tensor(t), tensor([...
  class EmbeddingNN (line 26) | class EmbeddingNN(TabularModel):
    method __init__ (line 28) | def __init__(self, emb_szs:ListSizes, layers:Collection[int]=None, ps:...
    method forward (line 33) | def forward(self, users:LongTensor, items:LongTensor) -> Tensor:
  class EmbeddingDotBias (line 36) | class EmbeddingDotBias(Module):
    method __init__ (line 38) | def __init__(self, n_factors:int, n_users:int, n_items:int, y_range:Tu...
    method forward (line 44) | def forward(self, users:LongTensor, items:LongTensor) -> Tensor:
  class CollabDataBunch (line 50) | class CollabDataBunch(DataBunch):
    method from_df (line 53) | def from_df(cls, ratings:DataFrame, valid_pct:float=0.2, user_name:Opt...
  class CollabLearner (line 68) | class CollabLearner(Learner):
    method get_idx (line 70) | def get_idx(self, arr:Collection, is_item:bool=True):
    method bias (line 82) | def bias(self, arr:Collection, is_item:bool=True):
    method weight (line 89) | def weight(self, arr:Collection, is_item:bool=True):
  function collab_learner (line 96) | def collab_learner(data, n_factors:int=None, use_nn:bool=False, emb_szs:...

FILE: fastai/core.py
  function num_cpus (line 43) | def num_cpus()->int:
  function is_listy (line 51) | def is_listy(x:Any)->bool: return isinstance(x, (tuple,list))
  function is_tuple (line 52) | def is_tuple(x:Any)->bool: return isinstance(x, tuple)
  function is_dict (line 53) | def is_dict(x:Any)->bool: return isinstance(x, dict)
  function is_pathlike (line 54) | def is_pathlike(x:Any)->bool: return isinstance(x, (str,Path))
  function noop (line 55) | def noop(x): return x
  class PrePostInitMeta (line 57) | class PrePostInitMeta(type):
    method __new__ (line 59) | def __new__(cls, name, bases, dct):
  function chunks (line 73) | def chunks(l:Collection, n:int)->Iterable:
  function recurse (line 77) | def recurse(func:Callable, x:Any, *args, **kwargs)->Any:
  function first_el (line 82) | def first_el(x: Any)->Any:
  function to_int (line 88) | def to_int(b:Any)->Union[int,List[int]]:
  function ifnone (line 92) | def ifnone(a:Any,b:Any)->Any:
  function is1d (line 96) | def is1d(a:Collection)->bool:
  function uniqueify (line 100) | def uniqueify(x:Series, sort:bool=False)->List:
  function idx_dict (line 106) | def idx_dict(a):
  function find_classes (line 110) | def find_classes(folder:Path)->FilePathList:
  function arrays_split (line 117) | def arrays_split(mask:NPArrayMask, *arrs:NPArrayableList)->SplitArrayList:
  function random_split (line 123) | def random_split(valid_pct:float, *arrs:NPArrayableList)->SplitArrayList:
  function listify (line 129) | def listify(p:OptListOrItem=None, q:OptListOrItem=None):
  function camel2snake (line 145) | def camel2snake(name:str)->str:
  function even_mults (line 150) | def even_mults(start:float, stop:float, n:int)->np.ndarray:
  function extract_kwargs (line 156) | def extract_kwargs(names:Collection[str], kwargs:KWArgs):
  function partition (line 165) | def partition(a:Collection, sz:int)->List[Collection]:
  function partition_by_cores (line 169) | def partition_by_cores(a:Collection, n_cpus:int)->List[Collection]:
  function series2cat (line 173) | def series2cat(df:DataFrame, *col_names):
  class ItemBase (line 179) | class ItemBase():
    method __init__ (line 181) | def __init__(self, data:Any): self.data=self.obj=data
    method __repr__ (line 182) | def __repr__(self)->str: return f'{self.__class__.__name__} {str(self)}'
    method show (line 183) | def show(self, ax:plt.Axes, **kwargs):
    method apply_tfms (line 186) | def apply_tfms(self, tfms:Collection, **kwargs):
    method __eq__ (line 190) | def __eq__(self, other): return recurse_eq(self.data, other.data)
  function recurse_eq (line 192) | def recurse_eq(arr1, arr2):
  function download_url (line 196) | def download_url(url:str, dest:str, overwrite:bool=False, pbar:ProgressB...
  function range_of (line 229) | def range_of(x):
  function arange_of (line 232) | def arange_of(x):
  function join_path (line 238) | def join_path(fname:PathOrStr, path:PathOrStr='.')->Path:
  function join_paths (line 242) | def join_paths(fnames:FilePathList, path:PathOrStr='.')->Collection[Path]:
  function loadtxt_str (line 247) | def loadtxt_str(path:PathOrStr)->np.ndarray:
  function save_texts (line 252) | def save_texts(fname:PathOrStr, texts:Collection[str]):
  function df_names_to_idx (line 257) | def df_names_to_idx(names:IntsOrStrs, df:DataFrame):
  function one_hot (line 263) | def one_hot(x:Collection[int], c:int):
  function index_row (line 269) | def index_row(a:Union[Collection,pd.DataFrame,pd.Series], idxs:Collectio...
  function func_args (line 278) | def func_args(func)->bool:
  function has_arg (line 283) | def has_arg(func, arg)->bool:
  function split_kwargs_by_func (line 287) | def split_kwargs_by_func(kwargs, func):
  function array (line 293) | def array(a, dtype:type=None, **kwargs)->np.ndarray:
  class EmptyLabel (line 301) | class EmptyLabel(ItemBase):
    method __init__ (line 303) | def __init__(self): self.obj,self.data = 0,0
    method __str__ (line 304) | def __str__(self):  return ''
    method __hash__ (line 305) | def __hash__(self): return hash(str(self))
  class Category (line 307) | class Category(ItemBase):
    method __init__ (line 309) | def __init__(self,data,obj): self.data,self.obj = data,obj
    method __int__ (line 310) | def __int__(self):  return int(self.data)
    method __str__ (line 311) | def __str__(self):  return str(self.obj)
    method __hash__ (line 312) | def __hash__(self): return hash(str(self))
  class MultiCategory (line 314) | class MultiCategory(ItemBase):
    method __init__ (line 316) | def __init__(self,data,obj,raw): self.data,self.obj,self.raw = data,ob...
    method __str__ (line 317) | def __str__(self):  return ';'.join([str(o) for o in self.obj])
    method __hash__ (line 318) | def __hash__(self): return hash(str(self))
  class FloatItem (line 320) | class FloatItem(ItemBase):
    method __init__ (line 322) | def __init__(self,obj): self.data,self.obj = np.array(obj).astype(np.f...
    method __str__ (line 323) | def __str__(self):  return str(self.obj)
    method __hash__ (line 324) | def __hash__(self): return hash(str(self))
  function _treat_html (line 326) | def _treat_html(o:str)->str:
  function text2html_table (line 332) | def text2html_table(items:Collection[Collection[str]])->str:
  function parallel (line 346) | def parallel(func, arr:Collection, max_workers:int=None, leave=False):
  function subplots (line 358) | def subplots(rows:int, cols:int, imgsize:int=4, figsize:Optional[Tuple[i...
  function show_some (line 367) | def show_some(items:Collection, n_max:int=5, sep:str=','):
  function get_tmp_file (line 374) | def get_tmp_file(dir=None):
  function compose (line 378) | def compose(funcs:List[Callable])->Callable:
  class PrettyString (line 385) | class PrettyString(str):
    method __repr__ (line 387) | def __repr__(self): return self
  function float_or_x (line 389) | def float_or_x(x):
  function bunzip (line 394) | def bunzip(fn:PathOrStr):
  function working_directory (line 404) | def working_directory(path:PathOrStr):

FILE: fastai/data_block.py
  function _decode (line 10) | def _decode(df):
  function _maybe_squeeze (line 13) | def _maybe_squeeze(arr): return (arr if is1d(arr) else np.squeeze(arr))
  function _path_to_same_str (line 15) | def _path_to_same_str(p_fn):
  function _get_files (line 22) | def _get_files(parent, p, f, extensions):
  function get_files (line 30) | def get_files(path:PathOrStr, extensions:Collection[str]=None, recurse:b...
  class PreProcessor (line 48) | class PreProcessor():
    method __init__ (line 50) | def __init__(self, ds:Collection=None):  self.ref_ds = ds
    method process_one (line 51) | def process_one(self, item:Any):         return item
    method process (line 52) | def process(self, ds:Collection):        ds.items = array([self.proces...
  class ItemList (line 57) | class ItemList():
    method __init__ (line 61) | def __init__(self, items:Iterator, path:PathOrStr='.', label_cls:Calla...
    method __len__ (line 71) | def __len__(self)->int: return len(self.items) or 1
    method get (line 72) | def get(self, i)->Any:
    method __repr__ (line 75) | def __repr__(self)->str:
    method process (line 79) | def process(self, processor:PreProcessors=None):
    method process_one (line 86) | def process_one(self, item:ItemBase, processor:PreProcessors=None):
    method analyze_pred (line 93) | def analyze_pred(self, pred:Tensor):
    method reconstruct (line 97) | def reconstruct(self, t:Tensor, x:Tensor=None):
    method new (line 101) | def new(self, items:Iterator, processor:PreProcessors=None, **kwargs)-...
    method add (line 108) | def add(self, items:'ItemList'):
    method __getitem__ (line 115) | def __getitem__(self,idxs:int)->Any:
    method from_folder (line 122) | def from_folder(cls, path:PathOrStr, extensions:Collection[str]=None, ...
    method from_df (line 130) | def from_df(cls, df:DataFrame, path:PathOrStr='.', cols:IntsOrStrs=0, ...
    method from_csv (line 138) | def from_csv(cls, path:PathOrStr, csv_name:str, cols:IntsOrStrs=0, del...
    method _relative_item_path (line 144) | def _relative_item_path(self, i): return self.items[i].relative_to(sel...
    method _relative_item_paths (line 145) | def _relative_item_paths(self):   return [self._relative_item_path(i) ...
    method use_partial_data (line 147) | def use_partial_data(self, sample_pct:float=0.01, seed:int=None)->'Ite...
    method to_text (line 154) | def to_text(self, fn:str):
    method filter_by_func (line 158) | def filter_by_func(self, func:Callable)->'ItemList':
    method filter_by_folder (line 163) | def filter_by_folder(self, include=None, exclude=None):
    method filter_by_rand (line 174) | def filter_by_rand(self, p:float, seed:int=None):
    method no_split (line 179) | def no_split(self):
    method split_none (line 183) | def split_none(self):
    method split_by_list (line 189) | def split_by_list(self, train, valid):
    method split_by_idxs (line 193) | def split_by_idxs(self, train_idx, valid_idx):
    method split_by_idx (line 197) | def split_by_idx(self, valid_idx:Collection[int])->'ItemLists':
    method _get_by_folder (line 203) | def _get_by_folder(self, name):
    method split_by_folder (line 207) | def split_by_folder(self, train:str='train', valid:str='valid')->'Item...
    method random_split_by_pct (line 211) | def random_split_by_pct(self, valid_pct:float=0.2, seed:int=None):
    method split_by_rand_pct (line 215) | def split_by_rand_pct(self, valid_pct:float=0.2, seed:int=None)->'Item...
    method split_subsets (line 223) | def split_subsets(self, train_size:float, valid_size:float, seed=None)...
    method split_by_valid_func (line 234) | def split_by_valid_func(self, func:Callable)->'ItemLists':
    method split_by_files (line 239) | def split_by_files(self, valid_names:'ItemList')->'ItemLists':
    method split_by_fname_file (line 244) | def split_by_fname_file(self, fname:PathOrStr, path:PathOrStr=None)->'...
    method split_from_df (line 250) | def split_from_df(self, col:IntsOrStrs=2):
    method get_label_cls (line 255) | def get_label_cls(self, labels, label_cls:Callable=None, label_delim:s...
    method _label_from_list (line 266) | def _label_from_list(self, labels:Iterator, label_cls:Callable=None, f...
    method label_from_df (line 276) | def label_from_df(self, cols:IntsOrStrs=1, label_cls:Callable=None, **...
    method label_const (line 285) | def label_const(self, const:Any=0, label_cls:Callable=None, **kwargs)-...
    method label_empty (line 289) | def label_empty(self, **kwargs):
    method label_from_func (line 294) | def label_from_func(self, func:Callable, label_cls:Callable=None, **kw...
    method label_from_folder (line 298) | def label_from_folder(self, label_cls:Callable=None, **kwargs)->'Label...
    method label_from_re (line 303) | def label_from_re(self, pat:str, full_path:bool=False, label_cls:Calla...
    method databunch (line 313) | def databunch(self, **kwargs):
  class EmptyLabelList (line 317) | class EmptyLabelList(ItemList):
    method get (line 319) | def get(self, i): return EmptyLabel()
    method reconstruct (line 320) | def reconstruct(self, t:Tensor, x:Tensor=None):
  class CategoryProcessor (line 324) | class CategoryProcessor(PreProcessor):
    method __init__ (line 326) | def __init__(self, ds:ItemList):
    method create_classes (line 330) | def create_classes(self, classes):
    method generate_classes (line 334) | def generate_classes(self, items):
    method process_one (line 338) | def process_one(self,item):
    method process (line 344) | def process(self, ds):
    method __getstate__ (line 350) | def __getstate__(self): return {n:getattr(self,n) for n in self.state_...
    method __setstate__ (line 351) | def __setstate__(self, state:dict):
  class CategoryListBase (line 357) | class CategoryListBase(ItemList):
    method __init__ (line 359) | def __init__(self, items:Iterator, classes:Collection=None, **kwargs):
    method c (line 366) | def c(self): return len(self.classes)
  class CategoryList (line 368) | class CategoryList(CategoryListBase):
    method __init__ (line 371) | def __init__(self, items:Iterator, classes:Collection=None, label_deli...
    method get (line 375) | def get(self, i):
    method analyze_pred (line 380) | def analyze_pred(self, pred, thresh:float=0.5): return pred.argmax()
    method reconstruct (line 382) | def reconstruct(self, t):
  class MultiCategoryProcessor (line 385) | class MultiCategoryProcessor(CategoryProcessor):
    method __init__ (line 387) | def __init__(self, ds:ItemList, one_hot:bool=False):
    method process_one (line 392) | def process_one(self,item):
    method generate_classes (line 397) | def generate_classes(self, items):
  class MultiCategoryList (line 405) | class MultiCategoryList(CategoryListBase):
    method __init__ (line 408) | def __init__(self, items:Iterator, classes:Collection=None, label_deli...
    method get (line 418) | def get(self, i):
    method analyze_pred (line 424) | def analyze_pred(self, pred, thresh:float=0.5):
    method reconstruct (line 427) | def reconstruct(self, t):
  class FloatList (line 431) | class FloatList(ItemList):
    method __init__ (line 433) | def __init__(self, items:Iterator, log:bool=False, classes:Collection=...
    method get (line 440) | def get(self, i):
    method reconstruct (line 444) | def reconstruct(self,t): return FloatItem(t.numpy())
  class ItemLists (line 446) | class ItemLists():
    method __init__ (line 448) | def __init__(self, path:PathOrStr, train:ItemList, valid:ItemList):
    method __dir__ (line 457) | def __dir__(self)->List[str]:
    method __repr__ (line 463) | def __repr__(self)->str:
    method __getattr__ (line 466) | def __getattr__(self, k):
    method __setstate__ (line 481) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method lists (line 484) | def lists(self):
    method label_from_lists (line 489) | def label_from_lists(self, train_labels:Iterator, valid_labels:Iterato...
    method transform (line 498) | def transform(self, tfms:Optional[Tuple[TfmList,TfmList]]=(None,None),...
    method transform_y (line 507) | def transform_y(self, tfms:Optional[Tuple[TfmList,TfmList]]=(None,None...
    method databunch (line 515) | def databunch(self, **kwargs):
  class LabelLists (line 519) | class LabelLists(ItemLists):
    method get_processors (line 521) | def get_processors(self):
    method process (line 528) | def process(self):
    method filter_by_func (line 537) | def filter_by_func(self, func:Callable):
    method databunch (line 541) | def databunch(self, path:PathOrStr=None, bs:int=64, val_bs:int=None, n...
    method add_test (line 554) | def add_test(self, items:Iterator, label:Any=None, tfms=None, tfm_y=No...
    method add_test_folder (line 565) | def add_test_folder(self, test_folder:str='test', label:Any=None, tfms...
    method load_state (line 572) | def load_state(cls, path:PathOrStr, state:dict):
    method load_empty (line 580) | def load_empty(cls, path:PathOrStr, fn:PathOrStr='export.pkl'):
  function _check_kwargs (line 586) | def _check_kwargs(ds:ItemList, tfms:TfmList, **kwargs):
  class LabelList (line 595) | class LabelList(Dataset):
    method __init__ (line 597) | def __init__(self, x:ItemList, y:ItemList, tfms:TfmList=None, tfm_y:bo...
    method __len__ (line 603) | def __len__(self)->int: return len(self.x) if self.item is None else 1
    method set_item (line 606) | def set_item(self,item):
    method __repr__ (line 612) | def __repr__(self)->str:
    method predict (line 619) | def predict(self, res):
    method c (line 624) | def c(self): return self.y.c
    method new (line 626) | def new(self, x, y, tfms=None, tfm_y=None, **kwargs)->'LabelList':
    method __getattr__ (line 633) | def __getattr__(self,k:str)->Any:
    method __setstate__ (line 642) | def __setstate__(self,data:Any): self.__dict__.update(data)
    method __getitem__ (line 644) | def __getitem__(self,idxs:Union[int,np.ndarray])->'LabelList':
    method to_df (line 658) | def to_df(self)->None:
    method to_csv (line 662) | def to_csv(self, dest:str)->None:
    method get_state (line 666) | def get_state(self, **kwargs):
    method export (line 675) | def export(self, fn:PathOrStr, **kwargs):
    method load_empty (line 680) | def load_empty(cls, path:PathOrStr, fn:PathOrStr):
    method load_state (line 685) | def load_state(cls, path:PathOrStr, state:dict) -> 'LabelList':
    method process (line 695) | def process(self, xp:PreProcessor=None, yp:PreProcessor=None, name:str...
    method filter_by_func (line 714) | def filter_by_func(self, func:Callable):
    method transform (line 719) | def transform(self, tfms:TfmList, tfm_y:bool=None, **kwargs):
    method transform_y (line 729) | def transform_y(self, tfms:TfmList=None, **kwargs):
    method databunch (line 737) | def databunch(self, **kwargs):
  function _databunch_load_empty (line 742) | def _databunch_load_empty(cls, path, fname:str='export.pkl'):
  class MixedProcessor (line 749) | class MixedProcessor(PreProcessor):
    method __init__ (line 750) | def __init__(self, procs:Collection[Union[PreProcessor, Collection[Pre...
    method process_one (line 753) | def process_one(self, item:Any):
    method process (line 760) | def process(self, ds:Collection):
  class MixedItem (line 764) | class MixedItem(ItemBase):
    method __init__ (line 765) | def __init__(self, items):
    method __repr__ (line 769) | def __repr__(self): return '\n'.join([f'{self.__class__.__name__}'] + ...
    method apply_tfms (line 771) | def apply_tfms(self, tfms:Collection, **kwargs):
  class MixedItemList (line 776) | class MixedItemList(ItemList):
    method __init__ (line 778) | def __init__(self, item_lists, path:PathOrStr=None, label_cls:Callable...
    method new (line 789) | def new(self, item_lists, processor:PreProcessor=None, **kwargs)->'Ite...
    method get (line 796) | def get(self, i):
    method __getitem__ (line 799) | def __getitem__(self,idxs:int)->Any:

FILE: fastai/datasets.py
  class URLs (line 8) | class URLs():
  class Config (line 129) | class Config():
    method get_key (line 140) | def get_key(cls, key):
    method get_path (line 145) | def get_path(cls, path):
    method data_path (line 150) | def data_path(cls):
    method data_archive_path (line 155) | def data_archive_path(cls):
    method model_path (line 160) | def model_path(cls):
    method get (line 165) | def get(cls, fpath=None, create_missing=True):
    method create (line 173) | def create(cls, fpath):
  function _expand_path (line 182) | def _expand_path(fpath): return Path(fpath).expanduser()
  function url2name (line 183) | def url2name(url): return url.split('/')[-1]
  function url2path (line 186) | def url2path(url, data=True, ext:str='.tgz'):
  function _url2tgz (line 190) | def _url2tgz(url, data=True, ext:str='.tgz'):
  function modelpath4file (line 193) | def modelpath4file(filename, ext:str='.tgz'):
  function datapath4file (line 199) | def datapath4file(filename, ext:str='.tgz', archive=True):
  function download_data (line 206) | def download_data(url:str, fname:PathOrStr=None, data:bool=True, ext:str...
  function _check_file (line 215) | def _check_file(fname):
  function untar_data (line 221) | def untar_data(url:str, fname:PathOrStr=None, dest:PathOrStr=None, data=...

FILE: fastai/distributed.py
  function rnn_reset (line 10) | def rnn_reset(self):
  class ParallelTrainer (line 14) | class ParallelTrainer(LearnerCallback):
    method on_train_begin (line 16) | def on_train_begin(self, **kwargs): self.learn.model = DataParallel(se...
    method on_train_end (line 17) | def on_train_end  (self, **kwargs): self.learn.model = self.learn.mode...
  class DistributedTrainer (line 19) | class DistributedTrainer(LearnerCallback):
    method __init__ (line 21) | def __init__(self, learn:Learner, cuda_id:int=0):
    method _change_dl (line 25) | def _change_dl(self, dl, shuffle):
    method on_train_begin (line 31) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 40) | def on_epoch_begin(self, epoch, **kwargs): self.train_sampler.set_epoc...
    method on_train_end (line 42) | def on_train_end(self, **kwargs):
  class DistributedRecorder (line 48) | class DistributedRecorder(LearnerCallback):
    method __init__ (line 49) | def __init__(self, learn:Learner, cuda_id:int=0, cache_dir:PathOrStr='...
    method on_train_begin (line 53) | def on_train_begin(self, **kwargs):
    method on_epoch_end (line 56) | def on_epoch_end(self, **kwargs): self.save_stats()
    method on_train_end (line 57) | def on_train_end(self, **kwargs): self.save_stats()
    method save_stats (line 59) | def save_stats(self):
  function _learner_parallel (line 65) | def _learner_parallel(learn:Learner):
  function _learner_distributed (line 71) | def _learner_distributed(learn:Learner, cuda_id:int, cache_dir:PathOrStr...
  function read_metrics (line 80) | def read_metrics(cache_path:PathOrStr, n_gpus:int, reduce:bool=True):
  function setup_distrib (line 90) | def setup_distrib(gpu:Any=None):
  class OurDistributedSampler (line 98) | class OurDistributedSampler(DistributedSampler):
    method __init__ (line 100) | def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True):
    method __iter__ (line 104) | def __iter__(self):

FILE: fastai/gen_doc/convert2html.py
  function read_nb (line 17) | def read_nb(fname):
  function convert_nb (line 21) | def convert_nb(fname, dest_path='.'):
  function convert_all (line 35) | def convert_all(folder, dest_path='.', force_all=False):

FILE: fastai/gen_doc/core.py
  function strip_fastai (line 4) | def strip_fastai(s):  return re.sub(r'^fastai\.', '', s)

FILE: fastai/gen_doc/docstrings.py
  function trim (line 29) | def trim(docstring):
  function reindent (line 63) | def reindent(string):
  function parse_docstring (line 67) | def parse_docstring(docstring):
  class InfoMixin (line 118) | class InfoMixin(object):
    method _get_doc (line 121) | def _get_doc(cls):
    method get_info (line 130) | def get_info(cls):

FILE: fastai/gen_doc/doctest.py
  function _json_set_default (line 10) | def _json_set_default(obj):
  class TestRegistry (line 14) | class TestRegistry:
    method this_tests (line 28) | def this_tests(*funcs):
    method this_tests_check_on (line 49) | def this_tests_check_on():
    method this_tests_check_off (line 52) | def this_tests_check_off():
    method this_tests_check_run (line 55) | def this_tests_check_run(file_name, test_name):
    method registry_save (line 59) | def registry_save():
    method missing_this_tests_alert (line 70) | def missing_this_tests_alert():
  function a2k (line 81) | def a2k(a): return '::'.join([a['file'], a['test']]), a['line']
  function k2a (line 82) | def k2a(k, v): f,t = k.split('::'); return {"file": f, "line": v, "test"...
  function merge_lists (line 84) | def merge_lists(a, b):
  function merge_registries (line 87) | def merge_registries(a, b):
  function this_tests (line 91) | def this_tests(*funcs): TestRegistry.this_tests(*funcs)
  function str2func (line 93) | def str2func(name):
  function get_func_fq_name (line 107) | def get_func_fq_name(func):
  function get_parent_func (line 118) | def get_parent_func(lineno, lines, ignore_missing=False):
  function relative_test_path (line 126) | def relative_test_path(test_file:Path)->str:
  function get_lines (line 132) | def get_lines(file):

FILE: fastai/gen_doc/gen_notebooks.py
  function get_empty_notebook (line 13) | def get_empty_notebook():
  function get_md_cell (line 29) | def get_md_cell(source, metadata=None):
  function get_empty_cell (line 35) | def get_empty_cell(ctype='markdown'):
  function get_code_cell (line 39) | def get_code_cell(code, hidden=False):
  function get_doc_cell (line 47) | def get_doc_cell(func_name):
  function get_global_vars (line 52) | def get_global_vars(mod):
  function write_nb (line 68) | def write_nb(nb, nb_path, mode='w'):
  class ExecuteShowDocPreprocessor (line 71) | class ExecuteShowDocPreprocessor(ExecutePreprocessor):
    method preprocess_cell (line 73) | def preprocess_cell(self, cell, resources, index):
  function execute_nb (line 79) | def execute_nb(fname, metadata=None, save=True, show_doc_only=False):
  function _symbol_skeleton (line 91) | def _symbol_skeleton(name): return [get_doc_cell(name), get_md_cell(f"`{...
  function create_module_page (line 93) | def create_module_page(mod, dest_path, force=False):
  function get_module_names (line 121) | def get_module_names(path_dir, exclude=None):
  function read_nb (line 134) | def read_nb(fname):
  function read_nb_content (line 139) | def read_nb_content(cells, mod_name):
  function read_nb_types (line 148) | def read_nb_types(cells):
  function link_markdown_cells (line 156) | def link_markdown_cells(cells, modules):
  function get_insert_idx (line 162) | def get_insert_idx(pos_dict, name):
  function update_pos (line 169) | def update_pos(pos_dict, start_key, nbr=2):
  function insert_cells (line 175) | def insert_cells(cells, pos_dict, ft_name, append=False):
  function get_doc_path (line 185) | def get_doc_path(mod, dest_path):
  function generate_missing_metadata (line 189) | def generate_missing_metadata(dest_file):
  function update_nb_metadata (line 204) | def update_nb_metadata(nb_path=None, title=None, summary=None, keywords=...
  function has_metadata_cell (line 214) | def has_metadata_cell(cells, fn):
  function stringify (line 218) | def stringify(s): return f'\'{s}\'' if isinstance(s, str) else s
  function get_imported_modules (line 221) | def get_imported_modules(cells, nb_module_name=''):
  function get_top_level_modules (line 231) | def get_top_level_modules(num_levels=1):
  function parse_sections (line 238) | def parse_sections(cells):
  function remove_undoc_cells (line 250) | def remove_undoc_cells(cells):
  function remove_code_cell_jupyter_widget_state_elem (line 255) | def remove_code_cell_jupyter_widget_state_elem(cells):
  function update_module_page (line 262) | def update_module_page(mod, dest_path='.'):
  function link_nb (line 290) | def link_nb(nb_path):
  function get_module_from_notebook (line 297) | def get_module_from_notebook(doc_path):
  function check_nbconvert_version (line 301) | def check_nbconvert_version():
  function update_notebooks (line 305) | def update_notebooks(source_path, dest_path=None, update_html=True, docu...

FILE: fastai/gen_doc/nbdoc.py
  function is_enum (line 29) | def is_enum(cls): return cls == enum.Enum or cls == enum.EnumMeta
  function link_type (line 31) | def link_type(arg_type, arg_name=None, include_bt:bool=True):
  function is_fastai_class (line 39) | def is_fastai_class(t): return belongs_to_module(t, MODULE_NAME)
  function belongs_to_module (line 41) | def belongs_to_module(t, module_name):
  function code_esc (line 47) | def code_esc(s): return f'`{s}`'
  function type_repr (line 49) | def type_repr(t):
  function partial_repr (line 61) | def partial_repr(t):
  function anno_repr (line 66) | def anno_repr(a): return type_repr(a)
  function format_param (line 68) | def format_param(p):
  function format_ft_def (line 79) | def format_ft_def(func, full_name:str=None)->str:
  function get_enum_doc (line 91) | def get_enum_doc(elt, full_name:str)->str:
  function get_cls_doc (line 96) | def get_cls_doc(elt, full_name:str)->str:
  function show_doc (line 103) | def show_doc(elt, doc_string:bool=True, full_name:str=None, arg_comments...
  function md2html (line 126) | def md2html(md):
  function doc (line 130) | def doc(elt):
  function format_docstring (line 145) | def format_docstring(elt, arg_comments:dict={}, alt_doc_string:str='', i...
  function replace_link (line 165) | def replace_link(m):
  function link_docstring (line 173) | def link_docstring(modules, docstring:str, overwrite:bool=False)->str:
  function find_elt (line 179) | def find_elt(modvars, keyword, match_last=False):
  function import_mod (line 187) | def import_mod(mod_name:str, ignore_errors=False):
  function show_doc_from_name (line 197) | def show_doc_from_name(mod_name, ft_name:str, doc_string:bool=True, arg_...
  function get_exports (line 208) | def get_exports(mod):
  function get_ft_names (line 213) | def get_ft_names(mod, include_inner=False)->List[str]:
  function get_inner_fts (line 234) | def get_inner_fts(elt)->List[str]:
  function get_module_toc (line 245) | def get_module_toc(mod_name):
  function show_video (line 260) | def show_video(url):
  function show_video_from_youtube (line 265) | def show_video_from_youtube(code, start=0):
  function get_anchor (line 270) | def get_anchor(fn)->str:
  function fn_name (line 275) | def fn_name(ft)->str:
  function get_fn_link (line 282) | def get_fn_link(ft)->str:
  function get_module_name (line 290) | def get_module_name(ft)->str: return inspect.getmodule(ft).__name__
  function get_pytorch_link (line 292) | def get_pytorch_link(ft)->str:
  function get_source_link (line 314) | def get_source_link(file, line, display_text="[source]", **kwargs)->str:
  function get_function_source (line 320) | def get_function_source(ft, **kwargs)->str:
  function title_md (line 327) | def title_md(s:str, title_level:int, markdown=True):
  function jekyll_div (line 332) | def jekyll_div(s,c,h,icon=None):
  function jekyll_note (line 337) | def jekyll_note(s): return jekyll_div(s,'info','Note')
  function jekyll_warn (line 338) | def jekyll_warn(s): return jekyll_div(s,'danger','Warning', 'exclamation')
  function jekyll_important (line 339) | def jekyll_important(s): return jekyll_div(s,'warning','Important')

FILE: fastai/gen_doc/nbtest.py
  function show_test (line 20) | def show_test(elt)->str:
  function doctest (line 25) | def doctest(elt):
  function build_tests_markdown (line 32) | def build_tests_markdown(elt):
  function tests2md (line 50) | def tests2md(tests, type_label:str):
  function get_pytest_html (line 55) | def get_pytest_html(elt, anchor_id:str)->Tuple[str,str]:
  function get_pytest_card (line 62) | def get_pytest_card(html, anchor_id):
  function lookup_db (line 71) | def lookup_db(elt)->List[Dict]:
  function find_related_tests (line 81) | def find_related_tests(elt)->Tuple[List[Dict],List[Dict]]:
  function get_tests_dir (line 89) | def get_tests_dir(elt)->Path:
  function get_file (line 95) | def get_file(elt)->str:
  function find_test_files (line 100) | def find_test_files(elt, exact_match:bool=False)->List[Path]:
  function _is_file_match (line 107) | def _is_file_match(elt, file_name:str, exact_match:bool=False)->bool:
  function _submodule_name (line 114) | def _submodule_name(elt)->str:
  function find_test_matches (line 122) | def find_test_matches(elt, test_file:Path)->Tuple[List[Dict],List[Dict]]:
  function get_qualname (line 129) | def get_qualname(elt):
  function separate_comp (line 132) | def separate_comp(qualname:str):
  function remove_underscore (line 139) | def remove_underscore(fn_name):
  function fuzzy_test_match (line 143) | def fuzzy_test_match(fn_name:str, lines:List[Dict], rel_path:str)->List[...
  function _fuzzy_line_match (line 150) | def _fuzzy_line_match(fn_name:str, lines)->List[TestFunctionMatch]:
  function get_lines (line 159) | def get_lines(file:Path)->List[str]:
  function map_test (line 162) | def map_test(test_file, line, line_text):
  function get_links (line 167) | def get_links(metadata)->Tuple[str,str]:
  function pytest_command (line 171) | def pytest_command(file:str, test:str, **kwargs)->str:

FILE: fastai/general_optimizer.py
  class Statistic (line 10) | class Statistic():
    method buf (line 17) | def buf(self): return f'{self.name}_buffer'
    method new_step (line 19) | def new_step(self):
    method accumulate (line 23) | def accumulate(self, val):
    method update (line 27) | def update(self, state, param, val=None, step=None):
  class ConstStatistic (line 31) | class ConstStatistic(Statistic):
    method buf (line 33) | def buf(self): return None
    method new_step (line 34) | def new_step(self):   pass
    method accumulate (line 35) | def accumulate(self): pass
    method update (line 36) | def update(self, state, param, val=None, step=None): return param
  class CounterStat (line 39) | class CounterStat(Statistic):
    method __post_init__ (line 40) | def __post_init__(self): self.init,self._buf,self.name = 0,self.name,None
    method buf (line 42) | def buf(self): return self._buf
    method new_step (line 43) | def new_step(self): pass
    method accumulate (line 44) | def accumulate(self, val): pass
    method update (line 45) | def update(self, state, param, val=None, step=None): return state + 1
  class AvgStatistic (line 48) | class AvgStatistic(Statistic):
    method new_step (line 51) | def new_step(self): self.val,self.count = 0.,0
    method accumulate (line 53) | def accumulate(self, val):
    method _get_val1 (line 57) | def _get_val1(self, val): return val.mean()
    method _get_val2 (line 58) | def _get_val2(self, state, val, param): return state.add_(1-param, val...
    method _get_val3 (line 59) | def _get_val3(self, state, val, param):
    method update (line 63) | def update(self, state, param, val=None, step=None):
  class AvgSquare (line 77) | class AvgSquare(AvgStatistic):
    method __init__ (line 79) | def __init__(self, name:str, param:float=0.9, scope=StatScope.Weight, ...
    method _get_val1 (line 82) | def _get_val1(self, val): return torch.norm(val).pow(2)/val.numel()
    method _get_val2 (line 83) | def _get_val2(self, state, val, param):
    method _get_val3 (line 85) | def _get_val3(self, state, val, param):
  class GeneralOptimizer (line 89) | class GeneralOptimizer(Optimizer):
    method __init__ (line 90) | def __init__(self, params, stats=None, on_step:Callable=None):
    method step (line 97) | def step(self, closure=None):
    method on_step (line 103) | def on_step(self, p, group, group_idx): p.data.add_(-group['lr'], p.gr...
    method _split_stats (line 105) | def _split_stats(self, stats):
    method _init_stats (line 111) | def _init_stats(self, stats, data=None):
    method init_stats (line 115) | def init_stats(self):
    method _set_bufs (line 124) | def _set_bufs(self, p, stats, pg, val=None):
    method update_stats (line 129) | def update_stats(self):

FILE: fastai/imports/core.py
  function try_import (line 39) | def try_import(module):
  function have_min_pkg_version (line 44) | def have_min_pkg_version(package, version):

FILE: fastai/launch.py
  function main (line 5) | def main(

FILE: fastai/layers.py
  class Lambda (line 10) | class Lambda(Module):
    method __init__ (line 12) | def __init__(self, func:LambdaFunc): self.func=func
    method forward (line 13) | def forward(self, x): return self.func(x)
  class View (line 15) | class View(Module):
    method __init__ (line 17) | def __init__(self, *size:int): self.size = size
    method forward (line 18) | def forward(self, x): return x.view(self.size)
  class ResizeBatch (line 20) | class ResizeBatch(Module):
    method __init__ (line 22) | def __init__(self, *size:int): self.size = size
    method forward (line 23) | def forward(self, x): return x.view((x.size(0),) + self.size)
  class Flatten (line 25) | class Flatten(Module):
    method __init__ (line 27) | def __init__(self, full:bool=False): self.full = full
    method forward (line 28) | def forward(self, x): return x.view(-1) if self.full else x.view(x.siz...
  function PoolFlatten (line 30) | def PoolFlatten()->nn.Sequential:
  function batchnorm_2d (line 36) | def batchnorm_2d(nf:int, norm_type:NormType=NormType.Batch):
  function bn_drop_lin (line 44) | def bn_drop_lin(n_in:int, n_out:int, bn:bool=True, p:float=0., actn:Opti...
  function conv1d (line 52) | def conv1d(ni:int, no:int, ks:int=1, stride:int=1, padding:int=0, bias:b...
  class PooledSelfAttention2d (line 59) | class PooledSelfAttention2d(Module):
    method __init__ (line 61) | def __init__(self, n_channels:int):
    method forward (line 69) | def forward(self, x):
  class SelfAttention (line 81) | class SelfAttention(Module):
    method __init__ (line 83) | def __init__(self, n_channels:int):
    method forward (line 89) | def forward(self, x):
  function conv2d (line 98) | def conv2d(ni:int, nf:int, ks:int=3, stride:int=1, padding:int=None, bia...
  function conv2d_trans (line 103) | def conv2d_trans(ni:int, nf:int, ks:int=2, stride:int=2, padding:int=0, ...
  function relu (line 107) | def relu(inplace:bool=False, leaky:float=None):
  function conv_layer (line 111) | def conv_layer(ni:int, nf:int, ks:int=3, stride:int=1, padding:int=None,...
  class SequentialEx (line 128) | class SequentialEx(Module):
    method __init__ (line 130) | def __init__(self, *layers): self.layers = nn.ModuleList(layers)
    method forward (line 132) | def forward(self, x):
    method __getitem__ (line 144) | def __getitem__(self,i): return self.layers[i]
    method append (line 145) | def append(self,l): return self.layers.append(l)
    method extend (line 146) | def extend(self,l): return self.layers.extend(l)
    method insert (line 147) | def insert(self,i,l): return self.layers.insert(i,l)
  class MergeLayer (line 149) | class MergeLayer(Module):
    method __init__ (line 151) | def __init__(self, dense:bool=False): self.dense=dense
    method forward (line 152) | def forward(self, x): return torch.cat([x,x.orig], dim=1) if self.dens...
  function res_block (line 154) | def res_block(nf, dense:bool=False, norm_type:Optional[NormType]=NormTyp...
  function sigmoid_range (line 163) | def sigmoid_range(x:Tensor, low:int, high:int):
  class SigmoidRange (line 167) | class SigmoidRange(Module):
    method __init__ (line 169) | def __init__(self, low:int, high:int): self.low,self.high = low,high
    method forward (line 170) | def forward(self, x): return sigmoid_range(x, self.low, self.high)
  class PartialLayer (line 172) | class PartialLayer(Module):
    method __init__ (line 174) | def __init__(self, func, **kwargs): self.repr,self.func = f'{func}({kw...
    method forward (line 175) | def forward(self, x): return self.func(x)
    method __repr__ (line 176) | def __repr__(self): return self.repr
  class AdaptiveConcatPool2d (line 178) | class AdaptiveConcatPool2d(Module):
    method __init__ (line 180) | def __init__(self, sz:Optional[int]=None):
    method forward (line 186) | def forward(self, x): return torch.cat([self.mp(x), self.ap(x)], 1)
  class Debugger (line 188) | class Debugger(Module):
    method forward (line 190) | def forward(self,x:Tensor) -> Tensor:
  function icnr (line 194) | def icnr(x, scale=2, init=nn.init.kaiming_normal_):
  class PixelShuffle_ICNR (line 204) | class PixelShuffle_ICNR(Module):
    method __init__ (line 206) | def __init__(self, ni:int, nf:int=None, scale:int=2, blur:bool=False, ...
    method forward (line 218) | def forward(self,x):
  class FlattenedLoss (line 222) | class FlattenedLoss():
    method __init__ (line 224) | def __init__(self, func, *args, axis:int=-1, floatify:bool=False, is_2...
    method __repr__ (line 228) | def __repr__(self): return f"FlattenedLoss of {self.func}"
    method reduction (line 230) | def reduction(self): return self.func.reduction
    method reduction (line 232) | def reduction(self, v): self.func.reduction = v
    method __call__ (line 234) | def __call__(self, input:Tensor, target:Tensor, **kwargs)->Rank0Tensor:
  function CrossEntropyFlat (line 241) | def CrossEntropyFlat(*args, axis:int=-1, **kwargs):
  function BCEWithLogitsFlat (line 245) | def BCEWithLogitsFlat(*args, axis:int=-1, floatify:bool=True, **kwargs):
  function BCEFlat (line 249) | def BCEFlat(*args, axis:int=-1, floatify:bool=True, **kwargs):
  function MSELossFlat (line 253) | def MSELossFlat(*args, axis:int=-1, floatify:bool=True, **kwargs):
  class NoopLoss (line 257) | class NoopLoss(Module):
    method forward (line 259) | def forward(self, output, *args): return output.mean()
  class WassersteinLoss (line 261) | class WassersteinLoss(Module):
    method forward (line 263) | def forward(self, real, fake): return real.mean() - fake.mean()
  function simple_cnn (line 265) | def simple_cnn(actns:Collection[int], kernel_szs:Collection[int]=None,
  function trunc_normal_ (line 276) | def trunc_normal_(x:Tensor, mean:float=0., std:float=1.) -> Tensor:
  function embedding (line 281) | def embedding(ni:int,nf:int) -> nn.Module:
  class BatchNorm1dFlat (line 288) | class BatchNorm1dFlat(nn.BatchNorm1d):
    method forward (line 290) | def forward(self, x):
  class LabelSmoothingCrossEntropy (line 296) | class LabelSmoothingCrossEntropy(Module):
    method __init__ (line 297) | def __init__(self, eps:float=0.1, reduction='mean'): self.eps,self.red...
    method forward (line 299) | def forward(self, output, target):

FILE: fastai/metrics.py
  function fbeta (line 13) | def fbeta(y_pred:Tensor, y_true:Tensor, thresh:float=0.2, beta:float=2, ...
  function accuracy (line 25) | def accuracy(input:Tensor, targs:Tensor)->Rank0Tensor:
  function accuracy_thresh (line 32) | def accuracy_thresh(y_pred:Tensor, y_true:Tensor, thresh:float=0.5, sigm...
  function top_k_accuracy (line 37) | def top_k_accuracy(input:Tensor, targs:Tensor, k:int=5)->Rank0Tensor:
  function foreground_acc (line 43) | def foreground_acc(input, target, void_code):
  function error_rate (line 49) | def error_rate(input:Tensor, targs:Tensor)->Rank0Tensor:
  function dice (line 53) | def dice(input:Tensor, targs:Tensor, iou:bool=False, eps:float=1e-8)->Ra...
  function psnr (line 63) | def psnr(input:Tensor, targs:Tensor)->Rank0Tensor:
  function exp_rmspe (line 66) | def exp_rmspe(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function mean_absolute_error (line 73) | def mean_absolute_error(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function mean_squared_error (line 78) | def mean_squared_error(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function root_mean_squared_error (line 83) | def root_mean_squared_error(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function mean_squared_logarithmic_error (line 88) | def mean_squared_logarithmic_error(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function explained_variance (line 93) | def explained_variance(pred:Tensor, targ:Tensor)->Rank0Tensor:
  function r2_score (line 99) | def r2_score(pred:Tensor, targ:Tensor)->Rank0Tensor:
  class RegMetrics (line 106) | class RegMetrics(Callback):
    method on_epoch_begin (line 108) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 111) | def on_batch_end(self, last_output:Tensor, last_target:Tensor, **kwargs):
  class R2Score (line 116) | class R2Score(RegMetrics):
    method on_epoch_end (line 118) | def on_epoch_end(self, last_metrics, **kwargs):
  class ExplainedVariance (line 121) | class ExplainedVariance(RegMetrics):
    method on_epoch_end (line 123) | def on_epoch_end(self, last_metrics, **kwargs):
  class RMSE (line 126) | class RMSE(RegMetrics):
    method on_epoch_end (line 128) | def on_epoch_end(self, last_metrics, **kwargs):
  class ExpRMSPE (line 131) | class ExpRMSPE(RegMetrics):
    method on_epoch_end (line 133) | def on_epoch_end(self, last_metrics, **kwargs):
  class ConfusionMatrix (line 142) | class ConfusionMatrix(Callback):
    method on_train_begin (line 145) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 148) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 151) | def on_batch_end(self, last_output:Tensor, last_target:Tensor, **kwargs):
    method on_epoch_end (line 161) | def on_epoch_end(self, **kwargs):
  class CMScores (line 165) | class CMScores(ConfusionMatrix):
    method _recall (line 171) | def _recall(self):
    method _precision (line 179) | def _precision(self):
    method _weights (line 186) | def _weights(self, avg:str):
  class Recall (line 201) | class Recall(CMScores):
    method on_epoch_end (line 203) | def on_epoch_end(self, last_metrics, **kwargs):
  class Precision (line 206) | class Precision(CMScores):
    method on_epoch_end (line 208) | def on_epoch_end(self, last_metrics, **kwargs):
  class FBeta (line 212) | class FBeta(CMScores):
    method on_train_begin (line 216) | def on_train_begin(self, **kwargs):
    method on_epoch_end (line 222) | def on_epoch_end(self, last_metrics, **kwargs):
    method on_train_end (line 230) | def on_train_end(self, **kwargs): self.average = self.avg
  class KappaScore (line 233) | class KappaScore(ConfusionMatrix):
    method on_epoch_end (line 237) | def on_epoch_end(self, last_metrics, **kwargs):
  class MatthewsCorreff (line 253) | class MatthewsCorreff(ConfusionMatrix):
    method on_epoch_end (line 255) | def on_epoch_end(self, last_metrics, **kwargs):
  class Perplexity (line 265) | class Perplexity(Callback):
    method on_epoch_begin (line 267) | def on_epoch_begin(self, **kwargs): self.loss,self.len = 0.,0
    method on_batch_end (line 269) | def on_batch_end(self, last_output, last_target, **kwargs):
    method on_epoch_end (line 273) | def on_epoch_end(self, last_metrics, **kwargs):
  function auc_roc_score (line 276) | def auc_roc_score(input:Tensor, targ:Tensor):
  function roc_curve (line 284) | def roc_curve(input:Tensor, targ:Tensor):
  class AUROC (line 302) | class AUROC(Callback):
    method on_epoch_begin (line 304) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 307) | def on_batch_end(self, last_output:Tensor, last_target:Tensor, **kwargs):
    method on_epoch_end (line 312) | def on_epoch_end(self, last_metrics, **kwargs):
  class MultiLabelFbeta (line 315) | class MultiLabelFbeta(LearnerCallback):
    method __init__ (line 319) | def __init__(self, learn, beta=2, eps=1e-15, thresh=0.3, sigmoid=True,...
    method on_train_begin (line 324) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 329) | def on_epoch_begin(self, **kwargs):
    method on_batch_end (line 335) | def on_batch_end(self, last_output, last_target, **kwargs):
    method fbeta_score (line 342) | def fbeta_score(self, precision, recall):
    method on_epoch_end (line 345) | def on_epoch_end(self, last_metrics, **kwargs):

FILE: fastai/script.py
  class Param (line 8) | class Param():
    method pre (line 20) | def pre(self): return '--' if self.opt else ''
    method kwargs (line 22) | def kwargs(self): return {k:v for k,v in self.__dict__.items()
  function anno_parser (line 25) | def anno_parser(func):
  function call_parse (line 35) | def call_parse(func):
  function call_plac (line 43) | def call_plac(f):

FILE: fastai/sixel.py
  function _sixel_encode (line 5) | def _sixel_encode(data, width, height):
  function plot_sixel (line 14) | def plot_sixel(fig=None):

FILE: fastai/tabular/data.py
  function emb_sz_rule (line 15) | def emb_sz_rule(n_cat:int)->int: return min(600, round(1.6 * n_cat**0.56))
  function def_emb_sz (line 17) | def def_emb_sz(classes, n, sz_dict=None):
  class TabularLine (line 24) | class TabularLine(ItemBase):
    method __init__ (line 26) | def __init__(self, cats, conts, classes, names):
    method __str__ (line 30) | def __str__(self):
  class TabularProcessor (line 38) | class TabularProcessor(PreProcessor):
    method __init__ (line 40) | def __init__(self, ds:ItemBase=None, procs=None):
    method process_one (line 44) | def process_one(self, item):
    method process (line 57) | def process(self, ds):
  class TabularDataBunch (line 85) | class TabularDataBunch(DataBunch):
    method from_df (line 88) | def from_df(cls, path, df:DataFrame, dep_var:str, valid_idx:Collection...
  class TabularList (line 104) | class TabularList(ItemList):
    method __init__ (line 109) | def __init__(self, items:Iterator, cat_names:OptStrList=None, cont_nam...
    method from_df (line 120) | def from_df(cls, df:DataFrame, cat_names:OptStrList=None, cont_names:O...
    method get (line 124) | def get(self, o):
    method get_emb_szs (line 130) | def get_emb_szs(self, sz_dict=None):
    method reconstruct (line 134) | def reconstruct(self, t:Tensor):
    method show_xys (line 137) | def show_xys(self, xs, ys)->None:
    method show_xyzs (line 154) | def show_xyzs(self, xs, ys, zs):
  function tabular_learner (line 171) | def tabular_learner(data:DataBunch, layers:Collection[int], emb_szs:Dict...

FILE: fastai/tabular/models.py
  class TabularModel (line 9) | class TabularModel(Module):
    method __init__ (line 11) | def __init__(self, emb_szs:ListSizes, n_cont:int, out_sz:int, layers:C...
    method get_sizes (line 29) | def get_sizes(self, layers, out_sz):
    method forward (line 32) | def forward(self, x_cat:Tensor, x_cont:Tensor) -> Tensor:
  function _cl_int_from_learner (line 46) | def _cl_int_from_learner(cls, learn:Learner, ds_type=DatasetType.Valid, ...
  function _cl_int_plot_top_losses (line 51) | def _cl_int_plot_top_losses(self, k, largest:bool=True, return_table:boo...
  function _learner_interpret (line 78) | def _learner_interpret(learn:Learner, ds_type:DatasetType = DatasetType....

FILE: fastai/tabular/transform.py
  function make_date (line 10) | def make_date(df:DataFrame, date_field:str):
  function cyclic_dt_feat_names (line 18) | def cyclic_dt_feat_names(time:bool=True, add_linear:bool=False)->List[str]:
  function cyclic_dt_features (line 26) | def cyclic_dt_features(d:Union[date,datetime], time:bool=True, add_linea...
  function add_cyclic_datepart (line 43) | def add_cyclic_datepart(df:DataFrame, field_name:str, prefix:str=None, d...
  function add_datepart (line 55) | def add_datepart(df:DataFrame, field_name:str, prefix:str=None, drop:boo...
  function _get_elapsed (line 68) | def _get_elapsed(df:DataFrame,field_names:Collection[str], date_field:st...
  function add_elapsed_times (line 80) | def add_elapsed_times(df:DataFrame, field_names:Collection[str], date_fi...
  function cont_cat_split (line 106) | def cont_cat_split(df, max_card=20, dep_var=None)->Tuple[List,List]:
  class TabularProc (line 116) | class TabularProc():
    method __call__ (line 121) | def __call__(self, df:DataFrame, test:bool=False):
    method apply_train (line 126) | def apply_train(self, df:DataFrame):
    method apply_test (line 129) | def apply_test(self, df:DataFrame):
  class Categorify (line 133) | class Categorify(TabularProc):
    method apply_train (line 135) | def apply_train(self, df:DataFrame):
    method apply_test (line 142) | def apply_test(self, df:DataFrame):
  class FillMissing (line 150) | class FillMissing(TabularProc):
    method apply_train (line 155) | def apply_train(self, df:DataFrame):
    method apply_test (line 169) | def apply_test(self, df:DataFrame):
  class Normalize (line 181) | class Normalize(TabularProc):
    method apply_train (line 183) | def apply_train(self, df:DataFrame):
    method apply_test (line 192) | def apply_test(self, df:DataFrame):

FILE: fastai/text/data.py
  class LanguageModelPreLoader (line 16) | class LanguageModelPreLoader(Callback):
    class CircularIndex (line 19) | class CircularIndex():
      method __init__ (line 21) | def __init__(self, length:int, forward:bool): self.idx, self.forward...
      method __getitem__ (line 22) | def __getitem__(self, i):
      method __len__ (line 24) | def __len__(self) -> int: return len(self.idx)
      method shuffle (line 25) | def shuffle(self): np.random.shuffle(self.idx)
    method __init__ (line 27) | def __init__(self, dataset:LabelList, lengths:Collection[int]=None, bs...
    method __len__ (line 33) | def __len__(self):
    method __getattr__ (line 40) | def __getattr__(self,k:str)->Any: return getattr(self.dataset, k)
    method allocate_buffers (line 42) | def allocate_buffers(self):
    method on_epoch_begin (line 53) | def on_epoch_begin(self, **kwargs):
    method on_epoch_end (line 70) | def on_epoch_end(self, **kwargs): self.on_epoch_begin()
    method __getitem__ (line 72) | def __getitem__(self, k:int):
    method fill_row (line 80) | def fill_row(self, forward, items, idx, row, ro, ri, overlap,lengths):
  class SortSampler (line 99) | class SortSampler(Sampler):
    method __init__ (line 102) | def __init__(self, data_source:NPArrayList, key:KeyFunc): self.data_so...
    method __len__ (line 103) | def __len__(self) -> int: return len(self.data_source)
    method __iter__ (line 104) | def __iter__(self):
  class SortishSampler (line 107) | class SortishSampler(Sampler):
    method __init__ (line 110) | def __init__(self, data_source:NPArrayList, key:KeyFunc, bs:int):
    method __len__ (line 113) | def __len__(self) -> int: return len(self.data_source)
    method __iter__ (line 115) | def __iter__(self):
  function pad_collate (line 128) | def pad_collate(samples:BatchSamples, pad_idx:int=1, pad_first:bool=True...
  function _get_processor (line 140) | def _get_processor(tokenizer:Tokenizer=None, vocab:Vocab=None, chunksize...
  class TextDataBunch (line 146) | class TextDataBunch(DataBunch):
    method from_ids (line 150) | def from_ids(cls, path:PathOrStr, vocab:Vocab, train_ids:Collection[Co...
    method load (line 165) | def load(cls, path:PathOrStr, cache_name:PathOrStr='tmp', processor:Pr...
    method from_tokens (line 178) | def from_tokens(cls, path:PathOrStr, trn_tok:Collection[Collection[str...
    method from_df (line 191) | def from_df(cls, path:PathOrStr, train_df:DataFrame, valid_df:DataFram...
    method from_csv (line 210) | def from_csv(cls, path:PathOrStr, csv_name, valid_pct:float=0.2, test:...
    method from_folder (line 227) | def from_folder(cls, path:PathOrStr, train:str='train', valid:str='val...
  class TextLMDataBunch (line 240) | class TextLMDataBunch(TextDataBunch):
    method create (line 243) | def create(cls, train_ds, valid_ds, test_ds=None, path:PathOrStr='.', ...
  class TextClasDataBunch (line 255) | class TextClasDataBunch(TextDataBunch):
    method create (line 258) | def create(cls, train_ds, valid_ds, test_ds=None, path:PathOrStr='.', ...
  function open_text (line 274) | def open_text(fn:PathOrStr, enc='utf-8'):
  class Text (line 278) | class Text(ItemBase):
    method __init__ (line 280) | def __init__(self, ids, text): self.data,self.text = np.array(ids, dty...
    method __str__ (line 281) | def __str__(self):  return str(self.text)
  class TokenizeProcessor (line 283) | class TokenizeProcessor(PreProcessor):
    method __init__ (line 285) | def __init__(self, ds:ItemList=None, tokenizer:Tokenizer=None, chunksi...
    method process_one (line 290) | def process_one(self, item):
    method process (line 293) | def process(self, ds):
  class NumericalizeProcessor (line 300) | class NumericalizeProcessor(PreProcessor):
    method __init__ (line 302) | def __init__(self, ds:ItemList=None, vocab:Vocab=None, max_vocab:int=6...
    method process_one (line 306) | def process_one(self,item): return np.array(self.vocab.numericalize(it...
    method process (line 307) | def process(self, ds):
  class OpenFileProcessor (line 312) | class OpenFileProcessor(PreProcessor):
    method process (line 314) | def process(self, ds:Collection): ds.items = array([self.process_one(i...
    method process_one (line 315) | def process_one(self,item): return open_text(item) if isinstance(item,...
  class TextList (line 317) | class TextList(ItemList):
    method __init__ (line 323) | def __init__(self, items:Iterator, vocab:Vocab=None, pad_idx:int=1, se...
    method get (line 328) | def get(self, i):
    method label_for_lm (line 332) | def label_for_lm(self, **kwargs):
    method reconstruct (line 338) | def reconstruct(self, t:Tensor):
    method from_folder (line 344) | def from_folder(cls, path:PathOrStr='.', extensions:Collection[str]=te...
    method show_xys (line 350) | def show_xys(self, xs, ys, max_len:int=70)->None:
    method show_xyzs (line 363) | def show_xyzs(self, xs, ys, zs, max_len:int=70):
  class LMLabelList (line 375) | class LMLabelList(EmptyLabelList):
    method __init__ (line 377) | def __init__(self, items:Iterator, **kwargs):
  class LMTextList (line 381) | class LMTextList(TextList):
  function _join_texts (line 386) | def _join_texts(texts:Collection[str], mark_fields:bool=False, include_b...
  function apply_rules (line 397) | def apply_rules(text, pre_rules=None, post_rules=None):
  function get_default_size (line 405) | def get_default_size(texts, max_vocab_sz):
  function train_sentencepiece (line 418) | def train_sentencepiece(texts:Collection[str], path:PathOrStr, pre_rules...
  class SPProcessor (line 438) | class SPProcessor(PreProcessor):
    method __init__ (line 440) | def __init__(self, ds:ItemList=None, pre_rules: ListRules=None, post_r...
    method process_one (line 454) | def process_one(self, item, join=True):
    method process (line 459) | def process(self, ds):
    method _encode_batch (line 474) | def _encode_batch(self, texts):
    method load (line 481) | def load(cls, path:PathOrStr, tmp_dir:PathOrStr='tmp', name:str='spm'):

FILE: fastai/text/interpret.py
  function value2rgba (line 9) | def value2rgba(x:float, cmap:Callable=cm.RdYlGn, alpha_mult:float=1.0)->...
  function piece_attn_html (line 16) | def piece_attn_html(pieces:List[str], attns:List[float], sep:str=' ', **...
  function show_piece_attn (line 26) | def show_piece_attn(*args, **kwargs):
  function _eval_dropouts (line 30) | def _eval_dropouts(mod):
  class TextClassificationInterpretation (line 35) | class TextClassificationInterpretation(ClassificationInterpretation):
    method __init__ (line 40) | def __init__(self, learn: Learner, preds: Tensor, y_true: Tensor, loss...
    method from_learner (line 45) | def from_learner(cls, learn: Learner,  ds_type:DatasetType=DatasetType...
    method intrinsic_attention (line 50) | def intrinsic_attention(self, text:str, class_id:int=None):
    method html_intrinsic_attention (line 70) | def html_intrinsic_attention(self, text:str, class_id:int=None, **kwar...
    method show_intrinsic_attention (line 74) | def show_intrinsic_attention(self, text:str, class_id:int=None, **kwar...
    method show_top_losses (line 78) | def show_top_losses(self, k:int, max_len:int=70)->None:

FILE: fastai/text/learner.py
  function convert_weights (line 28) | def convert_weights(wgts:Weights, stoi_wgts:Dict[str,int], itos_new:Coll...
  class RNNLearner (line 45) | class RNNLearner(Learner):
    method __init__ (line 47) | def __init__(self, data:DataBunch, model:nn.Module, split_func:OptSpli...
    method save_encoder (line 57) | def save_encoder(self, name:str):
    method load_encoder (line 64) | def load_encoder(self, name:str, device:torch.device=None):
    method load_pretrained (line 72) | def load_pretrained(self, wgts_fname:str, itos_fname:str, strict:bool=...
    method get_preds (line 81) | def get_preds(self, ds_type:DatasetType=DatasetType.Valid, activ:nn.Mo...
  function decode_spec_tokens (line 94) | def decode_spec_tokens(tokens):
  class LanguageLearner (line 113) | class LanguageLearner(RNNLearner):
    method predict (line 116) | def predict(self, text:str, n_words:int=1, no_unk:bool=True, temperatu...
    method beam_search (line 137) | def beam_search(self, text:str, n_words:int, no_unk:bool=True, top_k:i...
    method show_results (line 165) | def show_results(self, ds_type=DatasetType.Valid, rows:int=5, max_len:...
  function get_language_model (line 187) | def get_language_model(arch:Callable, vocab_sz:int, config:dict=None, dr...
  function language_model_learner (line 201) | def language_model_learner(data:DataBunch, arch, config:dict=None, drop_...
  function masked_concat_pool (line 221) | def masked_concat_pool(outputs, mask):
  class PoolingLinearClassifier (line 230) | class PoolingLinearClassifier(Module):
    method __init__ (line 232) | def __init__(self, layers:Collection[int], drops:Collection[float]):
    method forward (line 240) | def forward(self, input:Tuple[Tensor,Tensor, Tensor])->Tuple[Tensor,Te...
  class MultiBatchEncoder (line 246) | class MultiBatchEncoder(Module):
    method __init__ (line 248) | def __init__(self, bptt:int, max_len:int, module:nn.Module, pad_idx:in...
    method concat (line 251) | def concat(self, arrs:Collection[Tensor])->Tensor:
    method reset (line 255) | def reset(self):
    method forward (line 258) | def forward(self, input:LongTensor)->Tuple[Tensor,Tensor]:
  function get_text_classifier (line 270) | def get_text_classifier(arch:Callable, vocab_sz:int, n_class:int, bptt:i...
  function text_classifier_learner (line 287) | def text_classifier_learner(data:DataBunch, arch:Callable, bptt:int=70, ...

FILE: fastai/text/models/awd_lstm.py
  function dropout_mask (line 13) | def dropout_mask(x:Tensor, sz:Collection[int], p:float):
  class RNNDropout (line 17) | class RNNDropout(Module):
    method __init__ (line 20) | def __init__(self, p:float=0.5): self.p=p
    method forward (line 22) | def forward(self, x:Tensor)->Tensor:
  class WeightDropout (line 27) | class WeightDropout(Module):
    method __init__ (line 30) | def __init__(self, module:nn.Module, weight_p:float, layer_names:Colle...
    method _setweights (line 38) | def _setweights(self):
    method forward (line 44) | def forward(self, *args:ArgStar):
    method reset (line 51) | def reset(self):
  class EmbeddingDropout (line 57) | class EmbeddingDropout(Module):
    method __init__ (line 60) | def __init__(self, emb:nn.Module, embed_p:float):
    method forward (line 65) | def forward(self, words:LongTensor, scale:Optional[float]=None)->Tensor:
  class AWD_LSTM (line 75) | class AWD_LSTM(Module):
    method __init__ (line 80) | def __init__(self, vocab_sz:int, emb_sz:int, n_hid:int, n_layers:int, ...
    method forward (line 103) | def forward(self, input:Tensor, from_embeddings:bool=False)->Tuple[Ten...
    method _one_hidden (line 120) | def _one_hidden(self, l:int)->Tensor:
    method select_hidden (line 125) | def select_hidden(self, idxs):
    method reset (line 130) | def reset(self):
  class LinearDecoder (line 136) | class LinearDecoder(Module):
    method __init__ (line 140) | def __init__(self, n_out:int, n_hid:int, output_p:float, tie_encoder:n...
    method forward (line 147) | def forward(self, input:Tuple[Tensor,Tensor])->Tuple[Tensor,Tensor,Ten...
  class SequentialRNN (line 153) | class SequentialRNN(nn.Sequential):
    method reset (line 155) | def reset(self):
  function awd_lstm_lm_split (line 159) | def awd_lstm_lm_split(model:nn.Module) -> List[nn.Module]:
  function awd_lstm_clas_split (line 164) | def awd_lstm_clas_split(model:nn.Module) -> List[nn.Module]:
  function value2rgba (line 176) | def value2rgba(x:float, cmap:Callable=cm.RdYlGn, alpha_mult:float=1.0)->...
  function piece_attn_html (line 183) | def piece_attn_html(pieces:List[str], attns:List[float], sep:str=' ', **...
  function show_piece_attn (line 193) | def show_piece_attn(*args, **kwargs):
  function _eval_dropouts (line 197) | def _eval_dropouts(mod):
  class TextClassificationInterpretation (line 202) | class TextClassificationInterpretation(ClassificationInterpretation):
    method __init__ (line 207) | def __init__(self, learn: Learner, preds: Tensor, y_true: Tensor, loss...
    method intrinsic_attention (line 211) | def intrinsic_attention(self, text:str, class_id:int=None):
    method html_intrinsic_attention (line 231) | def html_intrinsic_attention(self, text:str, class_id:int=None, **kwar...
    method show_intrinsic_attention (line 235) | def show_intrinsic_attention(self, text:str, class_id:int=None, **kwar...
    method show_top_losses (line 239) | def show_top_losses(self, k:int, max_len:int=70)->None:

FILE: fastai/text/models/bwd_forget_mult_cuda.cpp
  function bwd_forget_mult_forward (line 14) | at::Tensor bwd_forget_mult_forward(at::Tensor x, at::Tensor f, at::Tenso...
  function bwd_forget_mult_backward (line 22) | std::vector<at::Tensor> bwd_forget_mult_backward(at::Tensor x, at::Tenso...
  function PYBIND11_MODULE (line 28) | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {

FILE: fastai/text/models/forget_mult_cuda.cpp
  function forget_mult_forward (line 14) | at::Tensor forget_mult_forward(at::Tensor x, at::Tensor f, at::Tensor ou...
  function forget_mult_backward (line 22) | std::vector<at::Tensor> forget_mult_backward(at::Tensor x, at::Tensor f,...
  function PYBIND11_MODULE (line 28) | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {

FILE: fastai/text/models/qrnn.py
  function dispatch_cuda (line 15) | def dispatch_cuda(cuda_class, cpu_func, x):
  class ForgetMultGPU (line 18) | class ForgetMultGPU(Function):
    method forward (line 21) | def forward(ctx, x:Tensor, f:Tensor, hidden_init:Optional[Tensor]=None...
    method backward (line 38) | def backward(ctx, grad_output):
  class BwdForgetMultGPU (line 43) | class BwdForgetMultGPU(Function):
    method forward (line 46) | def forward(ctx, x:Tensor, f:Tensor, hidden_init:Optional[Tensor]=None...
    method backward (line 63) | def backward(ctx, grad_output:Tensor):
  function forget_mult_CPU (line 68) | def forget_mult_CPU(x:Tensor, f:Tensor, hidden_init:Optional[Tensor]=Non...
  class QRNNLayer (line 81) | class QRNNLayer(Module):
    method __init__ (line 84) | def __init__(self, input_size:int, hidden_size:int=None, save_prev_x:b...
    method reset (line 96) | def reset(self):
    method forward (line 100) | def forward(self, inp, hid=None):
    method _get_source (line 120) | def _get_source(self, inp):
  class QRNN (line 129) | class QRNN(Module):
    method __init__ (line 132) | def __init__(self, input_size:int, hidden_size:int, n_layers:int=1, bi...
    method reset (line 148) | def reset(self):
    method forward (line 154) | def forward(self, inp, hid=None):

FILE: fastai/text/models/transformer.py
  class PositionalEncoding (line 11) | class PositionalEncoding(Module):
    method __init__ (line 13) | def __init__(self, d:int): self.register_buffer('freq', 1 / (10000 ** ...
    method forward (line 15) | def forward(self, pos:Tensor):
  class GeLU (line 20) | class GeLU(Module):
    method forward (line 21) | def forward(self, x): return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / m...
  class Swish (line 23) | class Swish(Module):
    method forward (line 24) | def forward(self, x): return x * torch.sigmoid(x)
  function feed_forward (line 28) | def feed_forward(d_model:int, d_ff:int, ff_p:float=0., act:Activation=Ac...
  class MultiHeadAttention (line 33) | class MultiHeadAttention(Module):
    method __init__ (line 35) | def __init__(self, n_heads:int, d_model:int, d_head:int=None, resid_p:...
    method forward (line 44) | def forward(self, x:Tensor, mask:Tensor=None, **kwargs):
    method _apply_attention (line 47) | def _apply_attention(self, x:Tensor, mask:Tensor=None):
    method _attention_einsum (line 60) | def _attention_einsum(self, x, mask=None):
  function _line_shift (line 81) | def _line_shift(x:Tensor, mask:bool=False):
  class MultiHeadRelativeAttention (line 89) | class MultiHeadRelativeAttention(MultiHeadAttention):
    method __init__ (line 92) | def __init__(self, n_heads:int, d_model:int, d_head:int, resid_p:float...
    method _apply_attention (line 97) | def _apply_attention(self, x:Tensor, r:Tensor=None, u:Tensor=None, v:T...
    method _attention_einsum (line 119) | def _attention_einsum(self, x:Tensor, r:Tensor=None, u:Tensor=None, v:...
  class DecoderLayer (line 138) | class DecoderLayer(Module):
    method __init__ (line 141) | def __init__(self, n_heads:int, d_model:int, d_head:int, d_inner:int, ...
    method forward (line 147) | def forward(self, x:Tensor, mask:Tensor=None, **kwargs): return self.f...
  class Transformer (line 149) | class Transformer(Module):
    method __init__ (line 151) | def __init__(self, vocab_sz:int, ctx_len:int, n_layers:int, n_heads:in...
    method reset (line 163) | def reset(self): pass
    method forward (line 165) | def forward(self, x):
  class TransformerXL (line 174) | class TransformerXL(Module):
    method __init__ (line 176) | def __init__(self, vocab_sz:int, ctx_len:int, n_layers:int, n_heads:in...
    method reset (line 191) | def reset(self):
    method _update_mems (line 195) | def _update_mems(self, hids):
    method select_hidden (line 203) | def select_hidden(self, idxs): self.hidden = [h[idxs] for h in self.hi...
    method forward (line 205) | def forward(self, x):
  function init_transformer (line 228) | def init_transformer(m):
  function tfmer_lm_split (line 248) | def tfmer_lm_split(model:nn.Module) -> List[nn.Module]:
  function tfmer_clas_split (line 255) | def tfmer_clas_split(model:nn.Module) -> List[nn.Module]:
  function tfmerXL_lm_split (line 270) | def tfmerXL_lm_split(model:nn.Module) -> List[nn.Module]:
  function tfmerXL_clas_split (line 277) | def tfmerXL_clas_split(model:nn.Module) -> List[nn.Module]:

FILE: fastai/text/transform.py
  class BaseTokenizer (line 16) | class BaseTokenizer():
    method __init__ (line 18) | def __init__(self, lang:str):                      self.lang = lang
    method tokenizer (line 19) | def tokenizer(self, t:str) -> List[str]:           return t.split(' ')
    method add_special_cases (line 20) | def add_special_cases(self, toks:Collection[str]): pass
  class SpacyTokenizer (line 22) | class SpacyTokenizer(BaseTokenizer):
    method __init__ (line 24) | def __init__(self, lang:str):
    method tokenizer (line 27) | def tokenizer(self, t:str) -> List[str]:
    method add_special_cases (line 30) | def add_special_cases(self, toks:Collection[str]):
  function spec_add_spaces (line 34) | def spec_add_spaces(t:str) -> str:
  function rm_useless_spaces (line 38) | def rm_useless_spaces(t:str) -> str:
  function replace_rep (line 42) | def replace_rep(t:str) -> str:
  function replace_wrep (line 50) | def replace_wrep(t:str) -> str:
  function fix_html (line 58) | def fix_html(x:str) -> str:
  function replace_all_caps (line 67) | def replace_all_caps(x:Collection[str]) -> Collection[str]:
  function deal_caps (line 75) | def deal_caps(x:Collection[str]) -> Collection[str]:
  class Tokenizer (line 87) | class Tokenizer():
    method __init__ (line 89) | def __init__(self, tok_func:Callable=SpacyTokenizer, lang:str='en', pr...
    method __repr__ (line 97) | def __repr__(self) -> str:
    method process_text (line 103) | def process_text(self, t:str, tok:BaseTokenizer) -> List[str]:
    method _process_all_1 (line 110) | def _process_all_1(self, texts:Collection[str]) -> List[List[str]]:
    method process_all (line 116) | def process_all(self, texts:Collection[str]) -> List[List[str]]:
  class Vocab (line 122) | class Vocab():
    method __init__ (line 124) | def __init__(self, itos:Collection[str]):
    method numericalize (line 128) | def numericalize(self, t:Collection[str]) -> List[int]:
    method textify (line 132) | def textify(self, nums:Collection[int], sep=' ') -> List[str]:
    method __getstate__ (line 136) | def __getstate__(self):
    method __setstate__ (line 139) | def __setstate__(self, state:dict):
    method save (line 143) | def save(self, path):
    method create (line 148) | def create(cls, tokens:Tokens, max_vocab:int, min_freq:int) -> 'Vocab':
    method load (line 161) | def load(cls, path):

FILE: fastai/torch_core.py
  function is_pool_type (line 64) | def is_pool_type(l:Callable): return re.search(r'Pool[123]d$', l.__class...
  function _new_torch_cuda_set_device (line 71) | def _new_torch_cuda_set_device(device):
  function tensor (line 76) | def tensor(x:Any, *rest)->Tensor:
  class Module (line 87) | class Module(nn.Module, metaclass=PrePostInitMeta):
    method __pre_init__ (line 89) | def __pre_init__(self): super().__init__()
    method __init__ (line 90) | def __init__(self): pass
  function np_address (line 92) | def np_address(x:np.ndarray)->int:
  function to_detach (line 96) | def to_detach(b:Tensors, cpu:bool=True):
  function to_data (line 104) | def to_data(b:ItemsList):
  function to_cpu (line 108) | def to_cpu(b:ItemsList):
  function to_half (line 112) | def to_half(b:Collection[Tensor])->Collection[Tensor]:
  function to_float (line 116) | def to_float(b:Collection[Tensor])->Collection[Tensor]:
  function to_device (line 120) | def to_device(b:Tensors, device:torch.device):
  function data_collate (line 125) | def data_collate(batch:ItemsList)->Tensor:
  function requires_grad (line 129) | def requires_grad(m:nn.Module, b:Optional[bool]=None)->Optional[bool]:
  function trainable_params (line 136) | def trainable_params(m:nn.Module)->ParamList:
  function children (line 141) | def children(m:nn.Module)->ModuleList:
  function num_children (line 145) | def num_children(m:nn.Module)->int:
  function range_children (line 149) | def range_children(m:nn.Module)->Iterator[int]:
  class ParameterModule (line 153) | class ParameterModule(Module):
    method __init__ (line 155) | def __init__(self, p:nn.Parameter): self.val = p
    method forward (line 156) | def forward(self, x): return x
  function children_and_parameters (line 158) | def children_and_parameters(m:nn.Module):
  function flatten_model (line 166) | def flatten_model(m:nn.Module):
  function first_layer (line 175) | def first_layer(m:nn.Module)->nn.Module:
  function last_layer (line 179) | def last_layer(m:nn.Module)->nn.Module:
  function split_model_idx (line 183) | def split_model_idx(model:nn.Module, idxs:Collection[int])->ModuleList:
  function split_model (line 190) | def split_model(model:nn.Module=None, splits:Collection[Union[nn.Module,...
  function get_param_groups (line 199) | def get_param_groups(layer_groups:Collection[nn.Module])->List[List[nn.P...
  function split_no_wd_params (line 202) | def split_no_wd_params(layer_groups:Collection[nn.Module])->List[List[nn...
  function set_bn_eval (line 220) | def set_bn_eval(m:nn.Module)->None:
  function batch_to_half (line 227) | def batch_to_half(b:Collection[Tensor])->Collection[Tensor]:
  function bn2float (line 231) | def bn2float(module:nn.Module)->nn.Module:
  function model2half (line 237) | def model2half(model:nn.Module)->nn.Module:
  function init_default (line 241) | def init_default(m:nn.Module, func:LayerFunc=nn.init.kaiming_normal_)->n...
  function cond_init (line 248) | def cond_init(m:nn.Module, init_func:LayerFunc):
  function apply_leaf (line 252) | def apply_leaf(m:nn.Module, f:LayerFunc):
  function apply_init (line 258) | def apply_init(m, init_func:LayerFunc):
  function in_channels (line 262) | def in_channels(m:nn.Module) -> List[int]:
  class ModelOnCPU (line 268) | class ModelOnCPU():
    method __init__ (line 270) | def __init__(self, model:nn.Module): self.model = model
    method __enter__ (line 271) | def __enter__(self):
    method __exit__ (line 274) | def __exit__(self, type, value, traceback):
  class NoneReduceOnCPU (line 277) | class NoneReduceOnCPU():
    method __init__ (line 279) | def __init__(self, loss_func:LossFunction):
    method __enter__ (line 282) | def __enter__(self):
    method __exit__ (line 292) | def __exit__(self, type, value, traceback):
  function model_type (line 296) | def model_type(dtype):
  function np2model_tensor (line 302) | def np2model_tensor(a):
  function _pca (line 309) | def _pca(x, k=2):
  function trange_of (line 316) | def trange_of(x):
  function to_np (line 320) | def to_np(x):
  function tensor__array__ (line 325) | def tensor__array__(self, dtype=None):
  function grab_idx (line 332) | def grab_idx(x,i,batch_first:bool=True):
  function logit (line 337) | def logit(x:Tensor)->Tensor:
  function logit_ (line 342) | def logit_(x:Tensor)->Tensor:
  function set_all_seed (line 347) | def set_all_seed(seed:int)->None:
  function uniform (line 353) | def uniform(low:Number, high:Number=None, size:Optional[List[int]]=None)...
  function log_uniform (line 358) | def log_uniform(low, high, size:Optional[List[int]]=None)->FloatOrTensor:
  function rand_bool (line 363) | def rand_bool(p:float, size:Optional[List[int]]=None)->BoolOrTensor:
  function uniform_int (line 367) | def uniform_int(low:int, high:int, size:Optional[List[int]]=None)->IntOr...
  function one_param (line 371) | def one_param(m: nn.Module)->Tensor:
  function try_int (line 375) | def try_int(o:Any)->Any:
  function get_model (line 383) | def get_model(model:nn.Module):
  function flatten_check (line 387) | def flatten_check(out:Tensor, targ:Tensor) -> Tensor:
  function _data_parallel_reset (line 394) | def _data_parallel_reset(self):
  function remove_module_load (line 398) | def remove_module_load(state_dict):
  function num_distrib (line 404) | def num_distrib():
  function rank_distrib (line 408) | def rank_distrib():
  function add_metrics (line 412) | def add_metrics(last_metrics:Collection[Rank0Tensor], mets:Union[Rank0Te...
  function try_save (line 417) | def try_save(state:Dict, path:Path=None, file:PathLikeOrBinaryStream=None):
  function np_func (line 423) | def np_func(f):

FILE: fastai/train.py
  function one_cycle_scheduler (line 10) | def one_cycle_scheduler(lr_max:float, **kwargs:Any)->OneCycleScheduler:
  function fit_one_cycle (line 14) | def fit_one_cycle(learn:Learner, cyc_len:int, max_lr:Union[Floats,slice]...
  function lr_find (line 25) | def lr_find(learn:Learner, start_lr:Floats=1e-7, end_lr:Floats=10, num_i...
  function to_fp16 (line 36) | def to_fp16(learn:Learner, loss_scale:float=None, max_noskip:int=1000, d...
  function to_fp32 (line 47) | def to_fp32(learn:Learner):
  function mixup (line 55) | def mixup(learn:Learner, alpha:float=0.4, stack_x:bool=False, stack_y:bo...
  class ShowGraph (line 66) | class ShowGraph(LearnerCallback):
    method on_epoch_end (line 68) | def on_epoch_end(self, n_epochs:int, last_metrics:MetricsList, **kwarg...
  class BnFreeze (line 79) | class BnFreeze(LearnerCallback):
    method on_epoch_begin (line 81) | def on_epoch_begin(self, **kwargs:Any)->None:
  class GradientClipping (line 85) | class GradientClipping(LearnerCallback):
    method __init__ (line 87) | def __init__(self, learn:Learner, clip:float = 0.):
    method on_backward_end (line 91) | def on_backward_end(self, **kwargs):
  function clip_grad (line 95) | def clip_grad(learn:Learner, clip:float=0.1)->Learner:
  class AccumulateScheduler (line 101) | class AccumulateScheduler(LearnerCallback):
    method __init__ (line 104) | def __init__(self, learn:Learner, n_step:int = 1, drop_last:bool = Fal...
    method on_train_begin (line 108) | def on_train_begin(self, **kwargs):
    method on_epoch_begin (line 113) | def on_epoch_begin(self, **kwargs):
    method on_batch_begin (line 117) | def on_batch_begin(self, last_input, last_target, **kwargs):
    method on_backward_end (line 122) | def on_backward_end(self, **kwargs):
    method on_epoch_end (line 130) | def on_epoch_end(self, **kwargs):
  class Interpretation (line 138) | class Interpretation():
    method __init__ (line 140) | def __init__(self, learn:Learner, preds:Tensor, y_true:Tensor, losses:...
    method from_learner (line 150) | def from_learner(cls, learn: Learner,  ds_type:DatasetType=DatasetType...
    method top_losses (line 155) | def top_losses(self, k:int=None, largest=True):
  class ClassificationInterpretation (line 165) | class ClassificationInterpretation(Interpretation):
    method __init__ (line 167) | def __init__(self, learn:Learner, preds:Tensor, y_true:Tensor, losses:...
    method confusion_matrix (line 171) | def confusion_matrix(self, slice_size:int=1):
    method plot_confusion_matrix (line 183) | def plot_confusion_matrix(self, normalize:bool=False, title:str='Confu...
    method most_confused (line 208) | def most_confused(self, min_val:int=1, slice_size:int=1)->Collection[T...
  function _learner_interpret (line 217) | def _learner_interpret(learn:Learner, ds_type:DatasetType=DatasetType.Va...
  class MultiLabelClassificationInterpretation (line 222) | class MultiLabelClassificationInterpretation(Interpretation):
    method __init__ (line 224) | def __init__(self, learn:Learner, preds:Tensor, y_true:Tensor, losses:...

FILE: fastai/utils/collect_env.py
  function get_env (line 11) | def get_env(name):
  function show_install (line 16) | def show_install(show_nvidia_smi:bool=False):
  function pypi_module_version_is_available (line 129) | def pypi_module_version_is_available(module, version):
  function check_perf (line 150) | def check_perf():

FILE: fastai/utils/ipython.py
  function is_in_ipython (line 5) | def is_in_ipython():
  function is_in_colab (line 19) | def is_in_colab():
  function get_ref_free_exc_info (line 29) | def get_ref_free_exc_info():
  function gpu_mem_restore (line 35) | def gpu_mem_restore(func):
  class gpu_mem_restore_ctx (line 57) | class gpu_mem_restore_ctx():
    method __enter__ (line 59) | def __enter__(self): return self
    method __exit__ (line 60) | def __exit__(self, exc_type, exc_val, exc_tb):

FILE: fastai/utils/mem.py
  function preload_pytorch (line 18) | def preload_pytorch():
  function b2mb (line 21) | def b2mb(num):
  function gpu_mem_get (line 25) | def gpu_mem_get(id=None):
  function gpu_mem_get_all (line 36) | def gpu_mem_get_all():
  function gpu_mem_get_free (line 41) | def gpu_mem_get_free():
  function gpu_mem_get_free_no_cache (line 45) | def gpu_mem_get_free_no_cache():
  function gpu_mem_get_used (line 50) | def gpu_mem_get_used():
  function gpu_mem_get_used_fast (line 54) | def gpu_mem_get_used_fast(gpu_handle):
  function gpu_mem_get_used_no_cache (line 59) | def gpu_mem_get_used_no_cache():
  function gpu_with_max_free_mem (line 64) | def gpu_with_max_free_mem():
  class GPUMemTrace (line 72) | class GPUMemTrace():
    method __init__ (line 74) | def __init__(self, silent=False, ctx=None, on_exit_report=True):
    method reset (line 81) | def reset(self):
    method data_set (line 85) | def data_set(self):
    method data (line 100) | def data(self):
    method start (line 104) | def start(self):
    method stop (line 109) | def stop(self):
    method __enter__ (line 114) | def __enter__(self):
    method __exit__ (line 118) | def __exit__(self, *exc):
    method __del__ (line 122) | def __del__(self):
    method __repr__ (line 125) | def __repr__(self):
    method _get_ctx (line 129) | def _get_ctx(self, subctx=None):
    method silent (line 136) | def silent(self, silent=True):
    method report (line 139) | def report(self, subctx=None):
    method report_n_reset (line 144) | def report_n_reset(self, subctx=None):
    method peak_monitor_start (line 149) | def peak_monitor_start(self):
    method peak_monitor_stop (line 157) | def peak_monitor_stop(self):
    method peak_monitor_func (line 162) | def peak_monitor_func(self):
  function gpu_mem_trace (line 169) | def gpu_mem_trace(func):
  function reduce_mem_usage (line 177) | def reduce_mem_usage(df):

FILE: fastai/utils/mod_display.py
  class progress_disabled_ctx (line 10) | class progress_disabled_ctx():
    method __init__ (line 12) | def __init__(self,learn:Learner):
    method __enter__ (line 15) | def __enter__(self):
    method __exit__ (line 26) | def __exit__(self, *args):

FILE: fastai/utils/pynvml_gate.py
  function _LoadNvmlLibrary (line 18) | def _LoadNvmlLibrary():
  function load_pynvml_env (line 51) | def load_pynvml_env():

FILE: fastai/utils/show_install.py
  function main (line 6) | def main(show_nvidia_smi:Param(opt=False, nargs='?', type=bool)=False):

FILE: fastai/vision/cyclegan.py
  function convT_norm_relu (line 8) | def convT_norm_relu(ch_in:int, ch_out:int, norm_layer:nn.Module, ks:int=...
  function pad_conv_norm_relu (line 12) | def pad_conv_norm_relu(ch_in:int, ch_out:int, pad_mode:str, norm_layer:n...
  class ResnetBlock (line 26) | class ResnetBlock(Module):
    method __init__ (line 27) | def __init__(self, dim:int, pad_mode:str='reflection', norm_layer:nn.M...
    method forward (line 35) | def forward(self, x): return x + self.conv_block(x)
  function resnet_generator (line 37) | def resnet_generator(ch_in:int, ch_out:int, n_ftrs:int=64, norm_layer:nn...
  function conv_norm_lr (line 52) | def conv_norm_lr(ch_in:int, ch_out:int, norm_layer:nn.Module=None, ks:in...
  function critic (line 63) | def critic(ch_in:int, n_ftrs:int=64, n_layers:int=3, norm_layer:nn.Modul...
  class CycleGAN (line 77) | class CycleGAN(Module):
    method __init__ (line 79) | def __init__(self, ch_in:int, ch_out:int, n_features:int=64, disc_laye...
    method forward (line 90) | def forward(self, real_A, real_B):
  class AdaptiveLoss (line 96) | class AdaptiveLoss(Module):
    method __init__ (line 97) | def __init__(self, crit): self.crit = crit
    method forward (line 99) | def forward(self, output, target:bool):
  class CycleGanLoss (line 103) | class CycleGanLoss(Module):
    method __init__ (line 104) | def __init__(self, cgan:nn.Module, lambda_A:float=10., lambda_B:float=...
    method set_input (line 109) | def set_input(self, input):
    method forward (line 112) | def forward(self, output, target):
  class CycleGANTrainer (line 124) | class CycleGANTrainer(LearnerCallback):
    method _set_trainable (line 127) | def _set_trainable(self, D_A=False, D_B=False):
    method on_train_begin (line 139) | def on_train_begin(self, **kwargs):
    method on_batch_begin (line 154) | def on_batch_begin(self, last_input, **kwargs):
    method on_batch_end (line 158) | def on_batch_end(self, last_input, last_output, **kwargs):
    method on_epoch_end (line 177) | def on_epoch_end(self, last_metrics, **kwargs):

FILE: fastai/vision/data.py
  function get_image_files (line 20) | def get_image_files(c:PathOrStr, check_ext:bool=True, recurse=False)->Fi...
  function get_annotations (line 24) | def get_annotations(fname, prefix=None):
  function bb_pad_collate (line 41) | def bb_pad_collate(samples:BatchSamples, pad_idx:int=0) -> Tuple[FloatTe...
  function normalize (line 56) | def normalize(x:TensorImage, mean,std:Tensor)->TensorImage:
  function denormalize (line 60) | def denormalize(x:TensorImage, mean,std:Tensor, do_x:bool=True)->TensorI...
  function _normalize_batch (line 64) | def _normalize_batch(b:Tuple[Tensor,Tensor], mean:Tensor, std:Tensor, do...
  function normalize_funcs (line 72) | def normalize_funcs(mean:Tensor, std:Tensor, do_x:bool=True, do_y:bool=F...
  function channel_view (line 83) | def channel_view(x:Tensor)->Tensor:
  class ImageDataBunch (line 87) | class ImageDataBunch(DataBunch):
    method create_from_ll (line 92) | def create_from_ll(cls, lls:LabelLists, bs:int=64, val_bs:int=None, ds...
    method from_folder (line 105) | def from_folder(cls, path:PathOrStr, train:PathOrStr='train', valid:Pa...
    method from_df (line 116) | def from_df(cls, path:PathOrStr, df:pd.DataFrame, folder:PathOrStr=Non...
    method from_csv (line 125) | def from_csv(cls, path:PathOrStr, folder:PathOrStr=None, label_delim:s...
    method from_lists (line 135) | def from_lists(cls, path:PathOrStr, fnames:FilePathList, labels:Collec...
    method from_name_func (line 145) | def from_name_func(cls, path:PathOrStr, fnames:FilePathList, label_fun...
    method from_name_re (line 152) | def from_name_re(cls, path:PathOrStr, fnames:FilePathList, pat:str, va...
    method single_from_classes (line 163) | def single_from_classes(path:Union[Path, str], classes:Collection[str]...
    method batch_stats (line 170) | def batch_stats(self, funcs:Collection[Callable]=None, ds_type:Dataset...
    method normalize (line 176) | def normalize(self, stats:Collection[Tensor]=None, do_x:bool=True, do_...
  function download_image (line 185) | def download_image(url,dest, timeout=4):
  function _download_image_inner (line 189) | def _download_image_inner(dest, url, i, timeout=4):
  function download_images (line 194) | def download_images(urls:Collection[str], dest:PathOrStr, max_pics:int=1...
  function resize_to (line 201) | def resize_to(img, targ_sz:int, use_min:bool=False):
  function verify_image (line 208) | def verify_image(file:Path, idx:int, delete:bool, max_size:Union[int,Tup...
  function verify_images (line 245) | def verify_images(path:PathOrStr, delete:bool=True, max_workers:int=4, m...
  class ImageList (line 258) | class ImageList(ItemList):
    method __init__ (line 261) | def __init__(self, *args, convert_mode='RGB', after_open:Callable=None...
    method open (line 267) | def open(self, fn):
    method get (line 271) | def get(self, i):
    method from_folder (line 278) | def from_folder(cls, path:PathOrStr='.', extensions:Collection[str]=No...
    method from_df (line 284) | def from_df(cls, df:DataFrame, path:PathOrStr, cols:IntsOrStrs=0, fold...
    method from_csv (line 294) | def from_csv(cls, path:PathOrStr, csv_name:str, header:str='infer', de...
    method reconstruct (line 300) | def reconstruct(self, t:Tensor): return Image(t.float().clamp(min=0,ma...
    method show_xys (line 302) | def show_xys(self, xs, ys, imgsize:int=4, figsize:Optional[Tuple[int,i...
    method show_xyzs (line 310) | def show_xyzs(self, xs, ys, zs, imgsize:int=4, figsize:Optional[Tuple[...
  class ObjectCategoryProcessor (line 325) | class ObjectCategoryProcessor(MultiCategoryProcessor):
    method __init__ (line 327) | def __init__(self, ds:ItemList, pad_idx:int=0):
    method process (line 332) | def process(self, ds:ItemList):
    method process_one (line 336) | def process_one(self,item): return [item[0], [self.c2i.get(o,None) for...
    method generate_classes (line 338) | def generate_classes(self, items):
  function _get_size (line 344) | def _get_size(xs,i):
  class ObjectCategoryList (line 352) | class ObjectCategoryList(MultiCategoryList):
    method get (line 356) | def get(self, i):
    method analyze_pred (line 359) | def analyze_pred(self, pred): return pred
    method reconstruct (line 361) | def reconstruct(self, t, x):
  class ObjectItemList (line 368) | class ObjectItemList(ImageList):
  class SegmentationProcessor (line 372) | class SegmentationProcessor(PreProcessor):
    method __init__ (line 374) | def __init__(self, ds:ItemList): self.classes = ds.classes
    method process (line 375) | def process(self, ds:ItemList):  ds.classes,ds.c = self.classes,len(se...
  class SegmentationLabelList (line 377) | class SegmentationLabelList(ImageList):
    method __init__ (line 380) | def __init__(self, items:Iterator, classes:Collection=None, **kwargs):
    method open (line 385) | def open(self, fn): return open_mask(fn)
    method analyze_pred (line 386) | def analyze_pred(self, pred, thresh:float=0.5): return pred.argmax(dim...
    method reconstruct (line 387) | def reconstruct(self, t:Tensor): return ImageSegment(t)
  class SegmentationItemList (line 389) | class SegmentationItemList(ImageList):
  class PointsProcessor (line 393) | class PointsProcessor(PreProcessor):
    method __init__ (line 395) | def __init__(self, ds:ItemList): self.c = len(ds.items[0].reshape(-1))
    method process (line 396) | def process(self, ds:ItemList):  ds.c = self.c
  class PointsLabelList (line 398) | class PointsLabelList(ItemList):
    method __init__ (line 401) | def __init__(self, items:Iterator, **kwargs):
    method get (line 405) | def get(self, i):
    method analyze_pred (line 409) | def analyze_pred(self, pred, thresh:float=0.5): return pred.view(-1,2)
    method reconstruct (line 410) | def reconstruct(self, t, x): return ImagePoints(FlowField(x.size, t), ...
  class PointsItemList (line 412) | class PointsItemList(ImageList):
  class ImageImageList (line 416) | class ImageImageList(ImageList):
    method show_xys (line 420) | def show_xys(self, xs, ys, imgsize:int=4, figsize:Optional[Tuple[int,i...
    method show_xyzs (line 428) | def show_xyzs(self, xs, ys, zs, imgsize:int=4, figsize:Optional[Tuple[...
  function _ll_pre_transform (line 438) | def _ll_pre_transform(self, train_tfm:List[Callable], valid_tfm:List[Cal...
  function _db_pre_transform (line 444) | def _db_pre_transform(self, train_tfm:List[Callable], valid_tfm:List[Cal...
  function _presize (line 450) | def _presize(self, size:int, val_xtra_size:int=32, scale:Tuple[float]=(0...

FILE: fastai/vision/gan.py
  function AvgFlatten (line 13) | def AvgFlatten():
  function basic_critic (line 17) | def basic_critic(in_size:int, n_channels:int, n_features:int=64, n_extra...
  function basic_generator (line 28) | def basic_generator(in_size:int, n_channels:int, noise_sz:int=100, n_fea...
  class GANModule (line 41) | class GANModule(Module):
    method __init__ (line 43) | def __init__(self, generator:nn.Module=None, critic:nn.Module=None, ge...
    method forward (line 47) | def forward(self, *args):
    method switch (line 50) | def switch(self, gen_mode:bool=None):
  class GANLoss (line 54) | class GANLoss(GANModule):
    method __init__ (line 56) | def __init__(self, loss_funcG:Callable, loss_funcC:Callable, gan_model...
    method generator (line 60) | def generator(self, output, target):
    method critic (line 65) | def critic(self, real_pred, input):
  class GANTrainer (line 71) | class GANTrainer(LearnerCallback):
    method __init__ (line 74) | def __init__(self, learn:Learner, switch_eval:bool=False, clip:float=N...
    method _set_trainable (line 80) | def _set_trainable(self):
    method on_train_begin (line 89) | def on_train_begin(self, **kwargs):
    method on_train_end (line 105) | def on_train_end(self, **kwargs):
    method on_batch_begin (line 109) | def on_batch_begin(self, last_input, last_target, **kwargs):
    method on_backward_begin (line 115) | def on_backward_begin(self, last_loss, last_output, **kwargs):
    method on_epoch_begin (line 126) | def on_epoch_begin(self, epoch, **kwargs):
    method on_epoch_end (line 130) | def on_epoch_end(self, pbar, epoch, last_metrics, **kwargs):
    method switch (line 143) | def switch(self, gen_mode:bool=None):
  class FixedGANSwitcher (line 151) | class FixedGANSwitcher(LearnerCallback):
    method __init__ (line 153) | def __init__(self, learn:Learner, n_crit:Union[int,Callable]=1, n_gen:...
    method on_train_begin (line 157) | def on_train_begin(self, **kwargs):
    method on_batch_end (line 161) | def on_batch_end(self, iteration, **kwargs):
  class AdaptiveGANSwitcher (line 175) | class AdaptiveGANSwitcher(LearnerCallback):
    method __init__ (line 177) | def __init__(self, learn:Learner, gen_thresh:float=None, critic_thresh...
    method on_batch_end (line 181) | def on_batch_end(self, last_loss, **kwargs):
  function gan_loss_from_func (line 190) | def gan_loss_from_func(loss_gen, loss_crit, weights_gen:Tuple[float,floa...
  class GANLearner (line 204) | class GANLearner(Learner):
    method __init__ (line 206) | def __init__(self, data:DataBunch, generator:nn.Module, critic:nn.Modu...
    method from_learners (line 218) | def from_learners(cls, learn_gen:Learner, learn_crit:Learner, switcher...
    method wgan (line 225) | def wgan(cls, data:DataBunch, generator:nn.Module, critic:nn.Module, s...
  class NoisyItem (line 229) | class NoisyItem(ItemBase):
    method __init__ (line 231) | def __init__(self, noise_sz): self.obj,self.data = noise_sz,torch.rand...
    method __str__ (line 232) | def __str__(self):  return ''
    method apply_tfms (line 233) | def apply_tfms(self, tfms, **kwargs): return self
  class GANItemList (line 235) | class GANItemList(ImageList):
    method __init__ (line 239) | def __init__(self, items, noise_sz:int=100, **kwargs):
    method get (line 244) | def get(self, i): return NoisyItem(self.noise_sz)
    method reconstruct (line 245) | def reconstruct(self, t): return NoisyItem(t.size(0))
    method show_xys (line 247) | def show_xys(self, xs, ys, imgsize:int=4, figsize:Optional[Tuple[int,i...
    method show_xyzs (line 251) | def show_xyzs(self, xs, ys, zs, imgsize:int=4, figsize:Optional[Tuple[...
  function _conv (line 257) | def _conv(ni:int, nf:int, ks:int=3, stride:int=1, **kwargs):
  function gan_critic (line 260) | def gan_critic(n_channels:int=3, nf:int=128, n_blocks:int=3, p:int=0.15):
  class GANDiscriminativeLR (line 277) | class GANDiscriminativeLR(LearnerCallback):
    method __init__ (line 279) | def __init__(self, learn:Learner, mult_lr:float = 5.):
    method on_batch_begin (line 283) | def on_batch_begin(self, train, **kwargs):
    method on_step_end (line 287) | def on_step_end(self, **kwargs):
  class AdaptiveLoss (line 291) | class AdaptiveLoss(Module):
    method __init__ (line 293) | def __init__(self, crit):
    method forward (line 296) | def forward(self, output, target):
  function accuracy_thresh_expand (line 299) | def accuracy_thresh_expand(y_pred:Tensor, y_true:Tensor, thresh:float=0....

FILE: fastai/vision/image.py
  function pil2tensor (line 14) | def pil2tensor(image:Union[NPImage,NPArray],dtype:np.dtype)->TensorImage:
  function image2np (line 22) | def image2np(image:Tensor)->np.ndarray:
  function bb2hw (line 27) | def bb2hw(a:Collection[int])->np.ndarray:
  function tis2hw (line 31) | def tis2hw(size:Union[int,TensorImageSize]) -> Tuple[int,int]:
  function _draw_outline (line 36) | def _draw_outline(o:Patch, lw:int):
  function _draw_rect (line 41) | def _draw_rect(ax:plt.Axes, b:Collection[int], color:str='white', text=N...
  function _get_default_args (line 49) | def _get_default_args(func:Callable):
  class FlowField (line 55) | class FlowField():
  class Image (line 62) | class Image(ItemBase):
    method __init__ (line 64) | def __init__(self, px:Tensor):
    method set_sample (line 71) | def set_sample(self, **kwargs)->'ImageBase':
    method clone (line 76) | def clone(self):
    method shape (line 81) | def shape(self)->Tuple[int,int,int]: return self._px.shape
    method size (line 83) | def size(self)->Tuple[int,int]: return self.shape[-2:]
    method device (line 85) | def device(self)->torch.device: return self._px.device
    method __repr__ (line 87) | def __repr__(self): return f'{self.__class__.__name__} {tuple(self.sha...
    method _repr_png_ (line 88) | def _repr_png_(self): return self._repr_image_format('png')
    method _repr_jpeg_ (line 89) | def _repr_jpeg_(self): return self._repr_image_format('jpeg')
    method _repr_image_format (line 91) | def _repr_image_format(self, format_str):
    method apply_tfms (line 96) | def apply_tfms(self, tfms:TfmList, do_resolve:bool=True, xtra:Optional...
    method refresh (line 133) | def refresh(self)->None:
    method save (line 144) | def save(self, fn:PathOrStr):
    method px (line 150) | def px(self)->TensorImage:
    method px (line 155) | def px(self,v:TensorImage)->None:
    method flow (line 160) | def flow(self)->FlowField:
    method flow (line 170) | def flow(self,v:FlowField): self._flow=v
    method lighting (line 172) | def lighting(self, func:LightingFunc, *args:Any, **kwargs:Any):
    method pixel (line 177) | def pixel(self, func:PixelFunc, *args, **kwargs)->'Image':
    method coord (line 182) | def coord(self, func:CoordFunc, *args, **kwargs)->'Image':
    method affine (line 187) | def affine(self, func:AffineFunc, *args, **kwargs)->'Image':
    method resize (line 193) | def resize(self, size:Union[int,TensorImageSize])->'Image':
    method affine_mat (line 202) | def affine_mat(self)->AffineMatrix:
    method affine_mat (line 208) | def affine_mat(self,v)->None: self._affine_mat=v
    method logit_px (line 211) | def logit_px(self)->LogitTensorImage:
    method logit_px (line 216) | def logit_px(self,v:LogitTensorImage)->None: self._logit_px=v
    method data (line 219) | def data(self)->TensorImage:
    method show (line 223) | def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[s...
  class ImageSegment (line 231) | class ImageSegment(Image):
    method lighting (line 233) | def lighting(self, func:LightingFunc, *args:Any, **kwargs:Any)->'Image...
    method refresh (line 235) | def refresh(self):
    method data (line 240) | def data(self)->TensorImage:
    method show (line 244) | def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[s...
    method reconstruct (line 251) | def reconstruct(self, t:Tensor): return ImageSegment(t)
  class ImagePoints (line 253) | class ImagePoints(Image):
    method __init__ (line 255) | def __init__(self, flow:FlowField, scale:bool=True, y_first:bool=True):
    method clone (line 265) | def clone(self):
    method shape (line 270) | def shape(self)->Tuple[int,int,int]: return (1, *self._flow.size)
    method size (line 272) | def size(self)->Tuple[int,int]: return self._flow.size
    method size (line 274) | def size(self, sz:int): self._flow.size=sz
    method device (line 276) | def device(self)->torch.device: return self._flow.flow.device
    method __repr__ (line 278) | def __repr__(self): return f'{self.__class__.__name__} {tuple(self.siz...
    method _repr_image_format (line 279) | def _repr_image_format(self, format_str): return None
    method flow (line 282) | def flow(self)->FlowField:
    method flow (line 295) | def flow(self,v:FlowField):  self._flow=v
    method coord (line 297) | def coord(self, func:CoordFunc, *args, **kwargs)->'ImagePoints':
    method lighting (line 304) | def lighting(self, func:LightingFunc, *args:Any, **kwargs:Any)->'Image...
    method pixel (line 306) | def pixel(self, func:PixelFunc, *args, **kwargs)->'ImagePoints':
    method refresh (line 312) | def refresh(self) -> 'ImagePoints':
    method resize (line 315) | def resize(self, size:Union[int,TensorImageSize]) -> 'ImagePoints':
    method data (line 322) | def data(self)->Tensor:
    method show (line 331) | def show(self, ax:plt.Axes=None, figsize:tuple=(3,3), title:Optional[s...
  class ImageBBox (line 340) | class ImageBBox(ImagePoints):
    method __init__ (line 342) | def __init__(self, flow:FlowField, scale:bool=True, y_first:bool=True,...
    method clone (line 350) | def clone(self) -> 'ImageBBox':
    method create (line 356) | def create(cls, h:int, w:int, bboxes:Collection[Collection[int]], labe...
    method _compute_boxes (line 367) | def _compute_boxes(self) -> Tuple[LongTensor, LongTensor]:
    method data (line 378) | def data(self)->Union[FloatTensor, Tuple[FloatTensor,LongTensor]]:
    method show (line 383) | def show(self, y:Image=None, ax:plt.Axes=None, figsize:tuple=(3,3), ti...
  function open_image (line 395) | def open_image(fn:PathOrStr, div:bool=True, convert_mode:str='RGB', cls:...
  function open_mask (line 406) | def open_mask(fn:PathOrStr, div=False, convert_mode='L', after_open:Call...
  function open_mask_rle (line 410) | def open_mask_rle(mask_rle:str, shape:Tuple[int, int])->ImageSegment:
  function rle_encode (line 416) | def rle_encode(img:NPArrayMask)->str:
  function rle_decode (line 423) | def rle_decode(mask_rle:str, shape:Tuple[int,int])->NPArrayMask:
  function show_image (line 433) | def show_image(img:Image, ax:plt.Axes=None, figsize:tuple=(3,3), hide_ax...
  function scale_flow (line 441) | def scale_flow(flow, to_unit=True):
  function _remove_points_out (line 448) | def _remove_points_out(flow:FlowField):
  class Transform (line 453) | class Transform():
    method __init__ (line 457) | def __init__(self, func:Callable, order:Optional[int]=None):
    method __call__ (line 469) | def __call__(self, *args:Any, p:float=1., is_random:bool=True, use_on_...
    method calc (line 474) | def calc(self, x:Image, *args:Any, **kwargs:Any)->Image:
    method name (line 480) | def name(self)->str: return self.__class__.__name__
    method __repr__ (line 482) | def __repr__(self)->str: return f'{self.name} ({self.func.__name__})'
  class RandTransform (line 485) | class RandTransform():
    method __post_init__ (line 494) | def __post_init__(self): functools.update_wrapper(self, self.tfm)
    method resolve (line 496) | def resolve(self)->None:
    method order (line 521) | def order(self)->int: return self.tfm.order
    method __call__ (line 523) | def __call__(self, x:Image, *args, **kwargs)->Image:
  function _resolve_tfms (line 527) | def _resolve_tfms(tfms:TfmList):
  function _grid_sample (line 531) | def _grid_sample(x:TensorImage, coords:FlowField, mode:str='bilinear', p...
  function _affine_grid (line 544) | def _affine_grid(size:TensorImageSize)->FlowField:
  function _affine_mult (line 554) | def _affine_mult(c:FlowField,m:AffineMatrix)->FlowField:
  function _affine_inv_mult (line 565) | def _affine_inv_mult(c, m):
  class TfmAffine (line 576) | class TfmAffine(Transform):
  class TfmPixel (line 579) | class TfmPixel(Transform):
  class TfmCoord (line 582) | class TfmCoord(Transform):
  class TfmCrop (line 585) | class TfmCrop(TfmPixel):
  class TfmLighting (line 588) | class TfmLighting(Transform):
  function _round_multiple (line 592) | def _round_multiple(x:int, mult:int=None)->int:
  function _get_crop_target (line 596) | def _get_crop_target(target_px:Union[int,TensorImageSize], mult:int=None...
  function _get_resize_target (line 601) | def _get_resize_target(img, crop_target, do_crop=False)->TensorImageSize:
  function plot_flat (line 609) | def plot_flat(r, c, figsize):
  function plot_multi (line 613) | def plot_multi(func:Callable[[int,int,plt.Axes],None], r:int=1, c:int=1,...
  function show_multi (line 619) | def show_multi(func:Callable[[int,int],Image], r:int=1, c:int=1, figsize...
  function show_all (line 623) | def show_all(imgs:Collection[Image], r:int=1, c:Optional[int]=None, figs...

FILE: fastai/vision/interpret.py
  class SegmentationInterpretation (line 10) | class SegmentationInterpretation(Interpretation):
    method __init__ (line 12) | def __init__(self, learn:Learner, preds:Tensor, y_true:Tensor, losses:...
    method top_losses (line 19) | def top_losses(self, sizes:Tuple, k:int=None, largest=True):
    method _interp_show (line 24) | def _interp_show(self, ims:ImageSegment, classes:Collection=None, sz:i...
    method show_xyz (line 53) | def show_xyz(self, i, classes:list=None, sz=10):
    method _generate_confusion (line 60) | def _generate_confusion(self):
    method _plot_intersect_cm (line 79) | def _plot_intersect_cm(self, cm, title="Intersection with Predict give...
  class ObjectDetectionInterpretation (line 101) | class ObjectDetectionInterpretation(Interpretation):
    method __init__ (line 103) | def __init__(self, learn:Learner, preds:Tensor, y_true:Tensor, losses:...

FILE: fastai/vision/learner.py
  function _default_split (line 14) | def _default_split(m:nn.Module): return (m[1],)
  function _resnet_split (line 16) | def _resnet_split(m:nn.Module): return (m[0][6],m[1])
  function _squeezenet_split (line 18) | def _squeezenet_split(m:nn.Module): return (m[0][0][5], m[0][0][8], m[1])
  function _densenet_split (line 19) | def _densenet_split(m:nn.Module): return (m[0][0][7],m[1])
  function _vgg_split (line 20) | def _vgg_split(m:nn.Module): return (m[0][0][22],m[1])
  function _alexnet_split (line 21) | def _alexnet_split(m:nn.Module): return (m[0][0][6],m[1])
  function cnn_config (line 43) | def cnn_config(arch):
  function has_pool_type (line 48) | def has_pool_type(m):
  function create_body (line 54) | def create_body(arch:Callable, pretrained:bool=True, cut:Optional[Union[...
  function create_head (line 66) | def create_head(nf:int, nc:int, lin_ftrs:Optional[Collection[int]]=None,...
  function create_cnn_model (line 80) | def create_cnn_model(base_arch:Callable, nc:int, cut:Union[int,Callable]...
  function cnn_learner (line 91) | def cnn_learner(data:DataBunch, base_arch:Callable, cut:Union[int,Callab...
  function create_cnn (line 105) | def create_cnn(data, base_arch, **kwargs):
  function unet_learner (line 109) | def unet_learner(data:DataBunch, arch:Callable, pretrained:bool=True, bl...
  function _cl_int_from_learner (line 128) | def _cl_int_from_learner(cls, learn:Learner, ds_type:DatasetType=Dataset...
  function _test_cnn (line 134) | def _test_cnn(m):
  function _cl_int_gradcam (line 138) | def _cl_int_gradcam(self, idx, heatmap_thresh:int=16, image:bool=True):
  function _cl_int_plot_top_losses (line 163) | def _cl_int_plot_top_losses(self, k, largest=True, figsize=(12,12), heat...
  function _cl_int_plot_multi_top_losses (line 186) | def _cl_int_plot_multi_top_losses(self, samples:int=3, figsize:Tuple[int...
  function _learner_interpret (line 233) | def _learner_interpret(learn:Learner, ds_type:DatasetType=DatasetType.Va...

FILE: fastai/vision/models/cadene_models.py
  function get_model (line 14) | def get_model(model_name:str, pretrained:bool, seq:bool=False, pname:str...
  function inceptionv4 (line 19) | def inceptionv4(pretrained:bool=False):
  function nasnetamobile (line 25) | def nasnetamobile(pretrained:bool=False):
  function pnasnet5large (line 31) | def pnasnet5large(pretrained:bool=False):
  function inceptionresnetv2 (line 37) | def inceptionresnetv2(pretrained:bool=False):   return get_model('incept...
  function dpn92 (line 38) | def dpn92(pretrained:bool=False):               return get_model('dpn92'...
  function xception_cadene (line 39) | def xception_cadene(pretrained=False):          return get_model('xcepti...
  function se_resnet50 (line 40) | def se_resnet50(pretrained:bool=False):         return get_model('se_res...
  function se_resnet101 (line 41) | def se_resnet101(pretrained:bool=False):        return get_model('se_res...
  function se_resnext50_32x4d (line 42) | def se_resnext50_32x4d(pretrained:bool=False):  return get_model('se_res...
  function se_resnext101_32x4d (line 43) | def se_resnext101_32x4d(pretrained:bool=False): return get_model('se_res...
  function senet154 (line 44) | def senet154(pretrained:bool=False):            return get_model('senet1...

FILE: fastai/vision/models/darknet.py
  function conv_bn_lrelu (line 6) | def conv_bn_lrelu(ni:int, nf:int, ks:int=3, stride:int=1)->nn.Sequential:
  class ResLayer (line 13) | class ResLayer(Module):
    method __init__ (line 15) | def __init__(self, ni:int):
    method forward (line 19) | def forward(self, x): return x + self.conv2(self.conv1(x))
  class Darknet (line 21) | class Darknet(Module):
    method make_group_layer (line 23) | def make_group_layer(self, ch_in:int, num_blocks:int, stride:int=1):
    method __init__ (line 28) | def __init__(self, num_blocks:Collection[int], num_classes:int, nf=32):
    method forward (line 37) | def forward(self, x): return self.layers(x)

FILE: fastai/vision/models/presnet.py
  function init_cnn (line 12) | def init_cnn(m):
  function conv (line 18) | def conv(ni, nf, ks=3, stride=1, bias=False):
  function conv_layer (line 21) | def conv_layer(conv_1st, ni, nf, ks=3, stride=1, zero_bn=False, bias=Fal...
  function conv_act (line 29) | def conv_act(*args, **kwargs): return conv_layer(True , *args, **kwargs)
  function act_conv (line 30) | def act_conv(*args, **kwargs): return conv_layer(False, *args, **kwargs)
  class BasicBlock (line 32) | class BasicBlock(Module):
    method __init__ (line 35) | def __init__(self, ni, nf, stride=1, downsample=None):
    method forward (line 42) | def forward(self, x):
  class Bottleneck (line 49) | class Bottleneck(Module):
    method __init__ (line 52) | def __init__(self, ni, nf, stride=1, downsample=None):
    method forward (line 60) | def forward(self, x):
  class PResNet (line 68) | class PResNet(Module):
    method __init__ (line 70) | def __init__(self, block, layers, num_classes=1000):
    method _make_layer (line 88) | def _make_layer(self, block, nf, blocks, stride=1):
    method forward (line 101) | def forward(self, x):
  function presnet (line 120) | def presnet(block, n_layers, name, pre=False, **kwargs):
  function presnet18 (line 126) | def presnet18(pretrained=False, **kwargs):
  function presnet34 (line 129) | def presnet34(pretrained=False, **kwargs):
  function presnet50 (line 132) | def presnet50(pretrained=False, **kwargs):
  function presnet101 (line 135) | def presnet101(pretrained=False, **kwargs):
  function presnet152 (line 138) | def presnet152(pretrained=False, **kwargs):

FILE: fastai/vision/models/unet.py
  function _get_sfs_idxs (line 7) | def _get_sfs_idxs(sizes:Sizes) -> List[int]:
  class UnetBlock (line 14) | class UnetBlock(Module):
    method __init__ (line 16) | def __init__(self, up_in_c:int, x_in_c:int, hook:Hook, final_div:bool=...
    method forward (line 27) | def forward(self, up_in:Tensor) -> Tensor:
  class DynamicUnet (line 37) | class DynamicUnet(SequentialEx):
    method __init__ (line 39) | def __init__(self, encoder:nn.Module, n_classes:int, img_size:Tuple[in...
    method __del__ (line 76) | def __del__(self):

FILE: fastai/vision/models/wrn.py
  function _bn (line 6) | def _bn(ni, init_zero=False):
  function bn_relu_conv (line 13) | def bn_relu_conv(ni, nf, ks, stride, init_zero=False):
  class BasicBlock (line 17) | class BasicBlock(Module):
    method __init__ (line 19) | def __init__(self, ni, nf, stride, drop_p=0.0):
    method forward (line 26) | def forward(self, x):
  function _make_group (line 34) | def _make_group(N, ni, nf, block, stride, drop_p):
  class WideResNet (line 37) | class WideResNet(Module):
    method __init__ (line 39) | def __init__(self, num_groups:int, N:int, num_classes:int, k:int=1, dr...
    method forward (line 51) | def forward(self, x): return self.features(x)
  function wrn_22 (line 54) | def wrn_22():

FILE: fastai/vision/models/xception.py
  function sep_conv (line 5) | def sep_conv(ni,nf,pad=None,pool=False,act=True):
  function conv (line 15) | def conv(ni,nf,ks=1,stride=1, pad=None, act=True):
  class ConvSkip (line 24) | class ConvSkip(Module):
    method __init__ (line 25) | def __init__(self,ni,nf=None,act=True):
    method forward (line 34) | def forward(self,x): return self.conv(x) + self.m(x)
  function middle_flow (line 36) | def middle_flow(nf):
  function xception (line 40) | def xception(c, k=8, n_middle=8):

FILE: fastai/vision/models/xresnet.py
  class Flatten (line 12) | class Flatten(Module):
    method forward (line 13) | def forward(self, x): return x.view(x.size(0), -1)
  function init_cnn (line 15) | def init_cnn(m):
  function conv (line 20) | def conv(ni, nf, ks=3, stride=1, bias=False):
  function noop (line 23) | def noop(x): return x
  function conv_layer (line 25) | def conv_layer(ni, nf, ks=3, stride=1, zero_bn=False, act=True):
  class ResBlock (line 32) | class ResBlock(Module):
    method __init__ (line 33) | def __init__(self, expansion, ni, nh, stride=1):
    method forward (line 47) | def forward(self, x): return act_fn(self.convs(x) + self.idconv(self.p...
  function filt_sz (line 49) | def filt_sz(recep): return min(64, 2**math.floor(math.log2(recep*0.75)))
  class XResNet (line 51) | class XResNet(nn.Sequential):
    method __init__ (line 52) | def __init__(self, expansion, layers, c_in=3, c_out=1000):
    method _make_layer (line 73) | def _make_layer(self, expansion, ni, nf, blocks, stride):
  function xresnet (line 78) | def xresnet(expansion, n_layers, name, pretrained=False, **kwargs):

FILE: fastai/vision/models/xresnet2.py
  function conv3x3 (line 11) | def conv3x3(in_planes, out_planes, stride=1):
  class BasicBlock (line 15) | class BasicBlock(Module):
    method __init__ (line 18) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 28) | def forward(self, x):
  class Bottleneck (line 46) | class Bottleneck(Module):
    method __init__ (line 49) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 62) | def forward(self, x):
  function conv2d (line 83) | def conv2d(ni, nf, stride):
  class XResNet (line 87) | class XResNet(Module):
    method __init__ (line 89) | def __init__(self, block, layers, c_out=1000):
    method _make_layer (line 115) | def _make_layer(self, block, planes, blocks, stride=1):
    method forward (line 131) | def forward(self, x):
  function xresnet18 (line 149) | def xresnet18(pretrained=False, **kwargs):
  function xresnet34_2 (line 160) | def xresnet34_2(pretrained=False, **kwargs):
  function xresnet50_2 (line 171) | def xresnet50_2(pretrained=False, **kwargs):
  function xresnet101 (line 182) | def xresnet101(pretrained=False, **kwargs):
  function xresnet152 (line 193) | def xresnet152(pretrained=False, **kwargs):

FILE: fastai/vision/transform.py
  function _brightness (line 15) | def _brightness(x, change:uniform):
  function _contrast (line 20) | def _contrast(x, scale:log_uniform):
  function _rotate (line 25) | def _rotate(degrees:uniform):
  function _get_zoom_mat (line 33) | def _get_zoom_mat(sw:float, sh:float, c:float, r:float)->AffineMatrix:
  function _zoom (line 39) | def _zoom(scale:uniform=1.0, row_pct:uniform=0.5, col_pct:uniform=0.5):
  function _squish (line 47) | def _squish(scale:uniform=1.0, row_pct:uniform=0.5, col_pct:uniform=0.5):
  function _jitter (line 57) | def _jitter(c, magnitude:uniform):
  function _flip_lr (line 63) | def _flip_lr(x):
  function _flip_affine (line 72) | def _flip_affine() -> TfmAffine:
  function _dihedral (line 79) | def _dihedral(x, k:partial(uniform_int,0,7)):
  function _dihedral_affine (line 89) | def _dihedral_affine(k:partial(uniform_int,0,7)):
  function _pad_coord (line 101) | def _pad_coord(x, row_pad:int, col_pad:int, mode='zeros'):
  function _pad_default (line 108) | def _pad_default(x, padding:int, mode='reflection'):
  function _pad_image_points (line 113) | def _pad_image_points(x, padding:int, mode='reflection'):
  function _pad (line 116) | def _pad(x, padding:int, mode='reflection'):
  function _cutout (line 122) | def _cutout(x, n_holes:uniform_int=1, length:uniform_int=40):
  function _rgb_randomize (line 137) | def _rgb_randomize(x, channel:int=None, thresh:float=0.3):
  function _minus_epsilon (line 145) | def _minus_epsilon(row_pct:float, col_pct:float, eps:float=1e-7):
  function _crop_default (line 150) | def _crop_default(x, size, row_pct:uniform=0.5, col_pct:uniform=0.5):
  function _crop_image_points (line 158) | def _crop_image_points(x, size, row_pct=0.5, col_pct=0.5):
  function _crop (line 169) | def _crop(x, size, row_pct:uniform=0.5, col_pct:uniform=0.5):
  function _crop_pad_default (line 175) | def _crop_pad_default(x, size, padding_mode='reflection', row_pct:unifor...
  function _crop_pad_image_points (line 191) | def _crop_pad_image_points(x, size, padding_mode='reflection', row_pct =...
  function _crop_pad (line 200) | def _crop_pad(x, size, padding_mode='reflection', row_pct:uniform = 0.5,...
  function _image_maybe_add_crop_pad (line 206) | def _image_maybe_add_crop_pad(img, tfms):
  function rand_pad (line 213) | def rand_pad(padding:int, size:int, mode:str='reflection'):
  function rand_zoom (line 218) | def rand_zoom(scale:uniform=1.0, p:float=1.):
  function rand_crop (line 222) | def rand_crop(*args, padding_mode='reflection', p:float=1.):
  function zoom_crop (line 226) | def zoom_crop(scale:float, do_rand:bool=False, p:float=1.0):
  function _find_coeffs (line 232) | def _find_coeffs(orig_pts:Points, targ_pts:Points)->Tensor:
  function _apply_perspective (line 245) | def _apply_perspective(coords:FlowField, coeffs:Points)->FlowField:
  function _do_perspective_warp (line 259) | def _do_perspective_warp(c:FlowField, targ_pts:Points, invert=False):
  function _perspective_warp (line 264) | def _perspective_warp(c, magnitude:partial(uniform,size=8)=0, invert=Fal...
  function _symmetric_warp (line 271) | def _symmetric_warp(c, magnitude:partial(uniform,size=4)=0, invert=False):
  function _tilt (line 278) | def _tilt(c, direction:uniform_int, magnitude:uniform=0, invert=False):
  function _skew (line 289) | def _skew(c, direction:uniform_int, magnitude:uniform=0, invert=False):
  function get_transforms (line 304) | def get_transforms(do_flip:bool=True, flip_vert:bool=False, max_rotate:f...
  function _compute_zs_mat (line 319) | def _compute_zs_mat(sz:TensorImageSize, scale:float, squish:float,
  function _zoom_squish (line 335) | def _zoom_squish(c, scale:uniform=1.0, squish:uniform=1.0, invert:rand_b...
  function rand_resize_crop (line 343) | def rand_resize_crop(size:int, max_scale:float=2., ratios:Tuple[float,fl...

FILE: fastai/vision/tta.py
  function _tta_only (line 10) | def _tta_only(learn:Learner, ds_type:DatasetType=DatasetType.Valid, acti...
  function _TTA (line 33) | def _TTA(learn:Learner, beta:float=0.4, scale:float=1.35, ds_type:Datase...

FILE: fastai/widgets/class_confusion.py
  class ClassConfusion (line 10) | class ClassConfusion():
    method __init__ (line 12) | def __init__(self, interp:ClassificationInterpretation, classlist:list,
    method _show_losses (line 30) | def _show_losses(self, classl:list, **kwargs):
    method _create_tabs (line 35) | def _create_tabs(self):
    method _populate_tabs (line 60) | def _populate_tabs(self):
    method _plot_tab (line 69) | def _plot_tab(self, tab:str):
    method _plot_imgs (line 107) | def _plot_imgs(self, tab:str, i:int ,**kwargs):
    method _tab_losses (line 138) | def _tab_losses(self, **kwargs):

FILE: fastai/widgets/image_cleaner.py
  class DatasetFormatter (line 14) | class DatasetFormatter():
    method from_toplosses (line 17) | def from_toplosses(cls, learn, n_imgs=None, **kwargs):
    method get_toplosses_idxs (line 23) | def get_toplosses_idxs(cls, learn, n_imgs, **kwargs):
    method padded_ds (line 31) | def padded_ds(ll_input, size=(250, 300), resize_method=ResizeMethod.CR...
    method from_similars (line 36) | def from_similars(cls, learn, layer_ls:list=[0, 7, 2], **kwargs):
    method get_similars_idxs (line 42) | def get_similars_idxs(cls, learn, layer_ls, **kwargs):
    method get_actns (line 53) | def get_actns(learn, hook:Hook, dl:DataLoader, pool=AdaptiveConcatPool...
    method comb_similarity (line 71) | def comb_similarity(t1: torch.Tensor, t2: torch.Tensor, **kwargs):
    method largest_indices (line 82) | def largest_indices(arr, n):
    method sort_idxs (line 91) | def sort_idxs(cls, similarities):
  class ImageCleaner (line 97) | class ImageCleaner():
    method __init__ (line 99) | def __init__(self, dataset, fns_idxs, path, batch_size:int=5, duplicat...
    method make_img_widget (line 113) | def make_img_widget(cls, img, layout=Layout(), format='jpg'):
    method make_button_widget (line 118) | def make_button_widget(cls, label, file_path=None, handler=None, style...
    method make_dropdown_widget (line 128) | def make_dropdown_widget(cls, description='Description', options=['Lab...
    method make_horizontal_box (line 137) | def make_horizontal_box(cls, children, layout=Layout()):
    method make_vertical_box (line 142) | def make_vertical_box(cls, children, layout=Layout(), duplicates=False):
    method create_image_list (line 147) | def create_image_list(self, dataset, fns_idxs):
    method relabel (line 158) | def relabel(self, change):
    method next_batch (line 165) | def next_batch(self, _):
    method on_delete (line 176) | def on_delete(self, btn):
    method empty_batch (line 181) | def empty_batch(self): self._batch[:] = []
    method delete_image (line 183) | def delete_image(self, file_path):
    method empty (line 186) | def empty(self):
    method get_widgets (line 189) | def get_widgets(self, duplicates):
    method batch_contains_deleted (line 203) | def batch_contains_deleted(self):
    method write_csv (line 209) | def write_csv(self):
    method render (line 220) | def render(self):

FILE: fastai/widgets/image_downloader.py
  class ImageDownloader (line 16) | class ImageDownloader():
    method __init__ (line 21) | def __init__(self, path:Union[Path,str]='data'):
    method _init_ui (line 27) | def _init_ui(self) -> VBox:
    method render (line 44) | def render(self) -> None:
    method clear_imgs (line 48) | def clear_imgs(self) -> None:
    method validate_search_input (line 53) | def validate_search_input(self) -> bool:
    method on_download_button_click (line 60) | def on_download_button_click(self, btn) -> None:
    method display_images_widgets (line 72) | def display_images_widgets(self, fnames:list) -> None:
  function download_google_images (line 78) | def download_google_images(path:PathOrStr, search_term:str, size:str='>4...
  function _url_params (line 93) | def _url_params(size:str='>400*300', format:str='jpg') -> str:
  function _search_url (line 103) | def _search_url(search_term:str, size:str='>400*300', format:str='jpg') ...
  function _img_fname (line 109) | def _img_fname(img_url:str) -> str:
  function _fetch_img_tuples (line 113) | def _fetch_img_tuples(url:str, format:str='jpg', n_images:int=10) -> list:
  function _html_to_img_tuples (line 119) | def _html_to_img_tuples(html:str, format:str='jpg', n_images:int=10) -> ...
  function _fetch_img_tuples_webdriver (line 127) | def _fetch_img_tuples_webdriver(url:str, format:str='jpg', n_images:int=...
  function _download_images (line 159) | def _download_images(label_path:PathOrStr, img_tuples:list, max_workers:...
  function _download_single_image (line 170) | def _download_single_image(label_path:Path, img_tuple:tuple, i:int, time...

FILE: fid/fid_score.py
  function tqdm (line 54) | def tqdm(x):
  function load_image_resized (line 83) | def load_image_resized(fn, sz):
  function get_activations (line 89) | def get_activations(
  function calculate_frechet_distance (line 175) | def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
  function calculate_activation_statistics (line 235) | def calculate_activation_statistics(
  function _compute_statistics_of_path (line 261) | def _compute_statistics_of_path(path, model, batch_size, dims, cuda):
  function calculate_fid_given_paths (line 274) | def calculate_fid_given_paths(paths, batch_size, cuda, dims):

FILE: fid/inception.py
  class InceptionV3 (line 16) | class InceptionV3(nn.Module):
    method __init__ (line 31) | def __init__(
    method forward (line 130) | def forward(self, inp):
  function fid_inception_v3 (line 164) | def fid_inception_v3():
  class FIDInceptionA (line 191) | class FIDInceptionA(models.inception.InceptionA):
    method __init__ (line 194) | def __init__(self, in_channels, pool_features):
    method forward (line 197) | def forward(self, x):
  class FIDInceptionC (line 218) | class FIDInceptionC(models.inception.InceptionC):
    method __init__ (line 221) | def __init__(self, in_channels, channels_7x7):
    method forward (line 224) | def forward(self, x):
  class FIDInceptionE_1 (line 248) | class FIDInceptionE_1(models.inception.InceptionE):
    method __init__ (line 251) | def __init__(self, in_channels):
    method forward (line 254) | def forward(self, x):
  class FIDInceptionE_2 (line 283) | class FIDInceptionE_2(models.inception.InceptionE):
    method __init__ (line 286) | def __init__(self, in_channels):
    method forward (line 289) | def forward(self, x):

FILE: setup.py
  function get_description (line 4) | def get_description():
  function get_requirements (line 13) | def get_requirements():
Condensed preview — 143 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,211K chars).
[
  {
    "path": ".github/CODEOWNERS",
    "chars": 170,
    "preview": "# See: https://help.github.com/en/articles/about-code-owners\n#\n# Owners will be requested for review when someone opens "
  },
  {
    "path": ".gitignore",
    "chars": 1537,
    "preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
  },
  {
    "path": ".pre-commit-config.yaml",
    "chars": 141,
    "preview": "repos:\n-   repo: https://github.com/ambv/black\n    rev: stable\n    hooks:\n    - id: black\n      args: [-S]\n      languag"
  },
  {
    "path": ".pylintrc",
    "chars": 18008,
    "preview": "[MASTER]\n\n# A comma-separated list of package or module names from where C extensions may\n# be loaded. Extensions are lo"
  },
  {
    "path": ".travis.yml",
    "chars": 181,
    "preview": "sudo: false\nlanguage: python\ninstall: pip install tox\nmatrix:\n  include:\n  - python: \"3.6\"\n    env: TOX_ENV=static\n  - p"
  },
  {
    "path": "ColorFIDBenchmarkArtistic.ipynb",
    "chars": 7379,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Color FID Benchmark (HQ)\"\n   ]\n "
  },
  {
    "path": "ColorizeTrainingArtistic.ipynb",
    "chars": 15025,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Artistic Model Training\"\n   ]\n  "
  },
  {
    "path": "ColorizeTrainingStable.ipynb",
    "chars": 15033,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Stable Model Training\"\n   ]\n  },"
  },
  {
    "path": "ColorizeTrainingStableLargeBatch.ipynb",
    "chars": 18888,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Stable Model Training (Large Bat"
  },
  {
    "path": "ColorizeTrainingVideo.ipynb",
    "chars": 12035,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Video Model Training\"\n   ]\n  },\n"
  },
  {
    "path": "ColorizeTrainingWandb.ipynb",
    "chars": 27047,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {},\n   \"source\": [\n    \"## Stable Model Training with monit"
  },
  {
    "path": "ImageColorizer.ipynb",
    "chars": 5670,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": "
  },
  {
    "path": "ImageColorizerArtisticTests.ipynb",
    "chars": 79684,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": "
  },
  {
    "path": "ImageColorizerColab.ipynb",
    "chars": 7850,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {\n    \"colab_type\": \"text\",\n    \"id\": \"view-in-github\"\n   }"
  },
  {
    "path": "ImageColorizerColabStable.ipynb",
    "chars": 7795,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {\n    \"colab_type\": \"text\",\n    \"id\": \"view-in-github\"\n   }"
  },
  {
    "path": "ImageColorizerStableTests.ipynb",
    "chars": 78929,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": "
  },
  {
    "path": "LICENSE",
    "chars": 1067,
    "preview": "MIT License\n\nCopyright (c) 2018 Jason Antic\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
  },
  {
    "path": "MANIFEST.in",
    "chars": 59,
    "preview": "include README.md\ninclude LICENSE\ninclude requirements.txt\n"
  },
  {
    "path": "README.md",
    "chars": 27286,
    "preview": "\n# DeOldify\n\n**This Reposisitory is Archived**  This project was a wild ride since I started it back in 2018.  6 years a"
  },
  {
    "path": "VideoColorizer.ipynb",
    "chars": 6339,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"code\",\n   \"execution_count\": null,\n   \"metadata\": {},\n   \"outputs\": [],\n   \"source\": "
  },
  {
    "path": "VideoColorizerColab.ipynb",
    "chars": 9900,
    "preview": "{\n \"cells\": [\n  {\n   \"cell_type\": \"markdown\",\n   \"metadata\": {\n    \"colab_type\": \"text\",\n    \"id\": \"view-in-github\"\n   }"
  },
  {
    "path": "deoldify/__init__.py",
    "chars": 192,
    "preview": "import sys\nimport logging\nlogging.getLogger().addHandler(logging.StreamHandler(sys.stdout))\nlogging.getLogger().setLevel"
  },
  {
    "path": "deoldify/_device.py",
    "chars": 833,
    "preview": "import os\nfrom enum import Enum\nfrom .device_id import DeviceId\n\n#NOTE:  This must be called first before any torch impo"
  },
  {
    "path": "deoldify/augs.py",
    "chars": 796,
    "preview": "import random\n\nfrom fastai.vision.image import TfmPixel\n\n# Contributed by Rani Horev. Thank you!\ndef _noisify(\n    x, pc"
  },
  {
    "path": "deoldify/critics.py",
    "chars": 1403,
    "preview": "from fastai.basic_train import Learner\nfrom fastai.core import *\nfrom fastai.layers import NormType, conv_layer\nfrom fas"
  },
  {
    "path": "deoldify/dataset.py",
    "chars": 1247,
    "preview": "from fastai import *\nfrom fastai.core import *\nfrom fastai.vision.transform import get_transforms\nfrom fastai.vision.dat"
  },
  {
    "path": "deoldify/device_id.py",
    "chars": 176,
    "preview": "from enum import IntEnum\n\nclass DeviceId(IntEnum):\n    GPU0 = 0,\n    GPU1 = 1,\n    GPU2 = 2,\n    GPU3 = 3,\n    GPU4 = 4,"
  },
  {
    "path": "deoldify/filters.py",
    "chars": 4839,
    "preview": "from fastai.basic_data import DatasetType\nfrom fastai.basic_train import Learner\nfrom abc import ABC, abstractmethod\nfro"
  },
  {
    "path": "deoldify/generators.py",
    "chars": 4475,
    "preview": "from fastai.basic_data import DataBunch\nfrom fastai.basic_train import Learner\nfrom fastai.layers import NormType\nfrom f"
  },
  {
    "path": "deoldify/layers.py",
    "chars": 1474,
    "preview": "from fastai.layers import *\nfrom fastai.torch_core import *\n\n\n# The code below is meant to be merged into fastaiv1 ideal"
  },
  {
    "path": "deoldify/loss.py",
    "chars": 5112,
    "preview": "from fastai import *\nfrom fastai.core import *\nfrom fastai.torch_core import *\nfrom fastai.callbacks import hook_outputs"
  },
  {
    "path": "deoldify/save.py",
    "chars": 936,
    "preview": "from fastai.basic_train import Learner, LearnerCallback\nfrom fastai.vision.gan import GANLearner\n\n\nclass GANSaveCallback"
  },
  {
    "path": "deoldify/unet.py",
    "chars": 9417,
    "preview": "from fastai.layers import *\nfrom .layers import *\nfrom fastai.torch_core import *\nfrom fastai.callbacks.hooks import *\nf"
  },
  {
    "path": "deoldify/visualize.py",
    "chars": 17652,
    "preview": "from fastai.core import *\nfrom fastai.vision import *\nfrom matplotlib.axes import Axes\nfrom .filters import IFilter, Mas"
  },
  {
    "path": "environment.yml",
    "chars": 333,
    "preview": "name: deoldify\nchannels:\n- fastai\n- conda-forge\n- defaults\ndependencies:\n- pip\n- fastai=1.0.60\n- mkl=2024.0\n- python=3.1"
  },
  {
    "path": "fastai/LICENSE",
    "chars": 9144,
    "preview": "Apache License, Version 2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/\n\nTERMS AND CONDITIO"
  },
  {
    "path": "fastai/__init__.py",
    "chars": 34,
    "preview": "from .version import __version__\n\n"
  },
  {
    "path": "fastai/basic_data.py",
    "chars": 14626,
    "preview": "\"`fastai.data` loads and manages datasets with `DataBunch`\"\nfrom .torch_core import *\nfrom torch.utils.data.dataloader i"
  },
  {
    "path": "fastai/basic_train.py",
    "chars": 31764,
    "preview": "\"Provides basic training and validation with `Learner`\"\nfrom .torch_core import *\nfrom .basic_data import *\nfrom .callba"
  },
  {
    "path": "fastai/basics.py",
    "chars": 976,
    "preview": "from .basic_train import *\nfrom .callback import *\nfrom .core import *\nfrom .basic_data import *\nfrom .data_block import"
  },
  {
    "path": "fastai/callback.py",
    "chars": 18176,
    "preview": "\"Callbacks provides extensibility to the `basic_train` loop. See `train` for examples of custom callbacks.\"\nfrom .basic_"
  },
  {
    "path": "fastai/callbacks/__init__.py",
    "chars": 265,
    "preview": "from .lr_finder import *\nfrom .one_cycle import *\nfrom .fp16 import *\nfrom .general_sched import *\nfrom .hooks import *\n"
  },
  {
    "path": "fastai/callbacks/csv_logger.py",
    "chars": 2062,
    "preview": "\"A `Callback` that saves tracked metrics into a persistent file.\"\n#Contribution from devforfu: https://nbviewer.jupyter."
  },
  {
    "path": "fastai/callbacks/fp16.py",
    "chars": 6433,
    "preview": "\"Callback support for half precision (fp16) training. Increases training speed.\"\nfrom ..torch_core import *\nfrom ..callb"
  },
  {
    "path": "fastai/callbacks/general_sched.py",
    "chars": 1892,
    "preview": "from ..core import *\nfrom ..callback import *\nfrom ..basic_train import Learner, LearnerCallback\n\n__all__ = ['GeneralSch"
  },
  {
    "path": "fastai/callbacks/hooks.py",
    "chars": 9302,
    "preview": "\"Hooks provide extensibility at the model level.\"\nfrom ..torch_core import *\nfrom ..callback import *\nfrom ..basic_train"
  },
  {
    "path": "fastai/callbacks/loss_metrics.py",
    "chars": 1362,
    "preview": "from ..torch_core import *\nfrom ..callback import *\nfrom ..basic_train import Learner, LearnerCallback\n\n__all__ = ['Loss"
  },
  {
    "path": "fastai/callbacks/lr_finder.py",
    "chars": 1943,
    "preview": "\"Tools to help find the optimal learning rate for training\"\nfrom ..torch_core import *\nfrom ..basic_data import DataBunc"
  },
  {
    "path": "fastai/callbacks/mem.py",
    "chars": 2425,
    "preview": "\" Memory profiling callbacks \"\n\nimport tracemalloc, threading, torch, time\nfrom ..utils.mem import *\nfrom ..basic_train "
  },
  {
    "path": "fastai/callbacks/misc.py",
    "chars": 454,
    "preview": "\" Miscellaneous callbacks \"\n\nfrom fastai.callback import Callback\n\nclass StopAfterNBatches(Callback):\n    \"Stop training"
  },
  {
    "path": "fastai/callbacks/mixup.py",
    "chars": 3015,
    "preview": "\"Implements [mixup](https://arxiv.org/abs/1710.09412) training method\"\nfrom ..torch_core import *\nfrom ..callback import"
  },
  {
    "path": "fastai/callbacks/mlflow.py",
    "chars": 1983,
    "preview": "\"A `Callback` that saves tracked metrics and notebook file into MLflow server.\"\nfrom ..torch_core import *\nfrom ..callba"
  },
  {
    "path": "fastai/callbacks/one_cycle.py",
    "chars": 2981,
    "preview": "\"Supports 1-Cycle style training\"\nfrom ..core import *\nfrom ..callback import *\nfrom ..basic_train import Learner,Learne"
  },
  {
    "path": "fastai/callbacks/oversampling.py",
    "chars": 1074,
    "preview": "from ..torch_core import *\nfrom ..basic_data import DataBunch\nfrom ..callback import *\nfrom ..basic_train import Learner"
  },
  {
    "path": "fastai/callbacks/rnn.py",
    "chars": 1299,
    "preview": "\"Regroups lr adjustment to seq_len, AR and TAR\"\nfrom ..torch_core import *\nfrom ..callback import *\nfrom ..basic_train i"
  },
  {
    "path": "fastai/callbacks/tensorboard.py",
    "chars": 22906,
    "preview": "\"Provides convenient callbacks for Learners that write model images, metrics/losses, stats and histograms to Tensorboard"
  },
  {
    "path": "fastai/callbacks/tracker.py",
    "chars": 7357,
    "preview": "# Contribution from @fredguth, https://github.com/fredguth/fastai_playground.\n\nfrom fastai.torch_core import *\nfrom fast"
  },
  {
    "path": "fastai/collab.py",
    "chars": 5946,
    "preview": "\"Module support for Collaborative Filtering\"\nfrom .tabular import *\nfrom . import tabular\n\n__all__ = [*tabular.__all__, "
  },
  {
    "path": "fastai/core.py",
    "chars": 16889,
    "preview": "\"`fastai.core` contains essential util functions to format and split data\"\nfrom .imports.core import *\n\nwarnings.filterw"
  },
  {
    "path": "fastai/data_block.py",
    "chars": 39739,
    "preview": "from .torch_core import *\nfrom .basic_data import *\nfrom .layers import *\nfrom numbers import Integral\n\n__all__ = ['Item"
  },
  {
    "path": "fastai/datasets.py",
    "chars": 11110,
    "preview": "from .core import *\nimport hashlib\n\n__all__ = ['URLs', 'Config', 'untar_data', 'download_data', 'datapath4file', 'url2na"
  },
  {
    "path": "fastai/distributed.py",
    "chars": 5232,
    "preview": "from .torch_core import *\nfrom .basic_train import Learner,LearnerCallback\nfrom torch.nn.parallel import DistributedData"
  },
  {
    "path": "fastai/gen_doc/__init__.py",
    "chars": 58,
    "preview": "from . import gen_notebooks, nbdoc, core, doctest, nbtest\n"
  },
  {
    "path": "fastai/gen_doc/autogen.tpl",
    "chars": 257,
    "preview": "<!--\n\n\n#################################################\n### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###\n#############"
  },
  {
    "path": "fastai/gen_doc/convert2html.py",
    "chars": 2087,
    "preview": "import os.path, re, nbformat, jupyter_contrib_nbextensions\nfrom nbconvert.preprocessors import Preprocessor\nfrom nbconve"
  },
  {
    "path": "fastai/gen_doc/core.py",
    "chars": 90,
    "preview": "from ..core import *\nimport re\n\ndef strip_fastai(s):  return re.sub(r'^fastai\\.', '', s)\n\n"
  },
  {
    "path": "fastai/gen_doc/docstrings.py",
    "chars": 4672,
    "preview": "# https://github.com/openstack/rally/blob/master/rally/common/plugin/info.py\n# Copyright 2015: Mirantis Inc.\n# All Right"
  },
  {
    "path": "fastai/gen_doc/doctest.py",
    "chars": 5568,
    "preview": "import sys, re, json, pprint\nfrom pathlib import Path\nfrom collections import defaultdict\nfrom inspect import currentfra"
  },
  {
    "path": "fastai/gen_doc/gen_notebooks.py",
    "chars": 16188,
    "preview": "\"`gen_doc.nbdoc` generates notebook documentation from module functions and links to correct places\"\nimport pkgutil, ins"
  },
  {
    "path": "fastai/gen_doc/hide.tpl",
    "chars": 532,
    "preview": "{%- extends 'basic.tpl' -%}\n\n{% block input_group -%}\n{%- if cell.metadata.hide_input or nb.metadata.hide_input -%}\n{%- "
  },
  {
    "path": "fastai/gen_doc/jekyll.tpl",
    "chars": 607,
    "preview": "{%- extends 'hide.tpl' -%}{% block body %}---\n{% if resources.toc != \"\" and resources.toc != nil %}toc: {{resources.toc}"
  },
  {
    "path": "fastai/gen_doc/nbdoc.py",
    "chars": 15671,
    "preview": "\"`gen_doc.nbdoc` generates notebook documentation from module functions and links to correct places\"\n\nimport inspect,imp"
  },
  {
    "path": "fastai/gen_doc/nbtest.py",
    "chars": 7372,
    "preview": "\"`gen_doc.nbtest` shows pytest documentation for module functions\"\n\nimport inspect, os, re\nfrom os.path import abspath, "
  },
  {
    "path": "fastai/general_optimizer.py",
    "chars": 6028,
    "preview": "from .torch_core import *\nfrom torch.optim import Optimizer\nimport types\n\n__all__ = ['StatScope', 'Statistic', 'ConstSta"
  },
  {
    "path": "fastai/imports/__init__.py",
    "chars": 41,
    "preview": "from .core import *\nfrom .torch import *\n"
  },
  {
    "path": "fastai/imports/core.py",
    "chars": 2036,
    "preview": "import csv, gc, gzip, os, pickle, shutil, sys, warnings, yaml, io, subprocess\nimport math, matplotlib.pyplot as plt, num"
  },
  {
    "path": "fastai/imports/torch.py",
    "chars": 320,
    "preview": "import torch, torch.nn.functional as F\nfrom torch import ByteTensor, DoubleTensor, FloatTensor, HalfTensor, LongTensor, "
  },
  {
    "path": "fastai/launch.py",
    "chars": 959,
    "preview": "import subprocess, torch\nfrom fastai.script import *\n\n@call_parse\ndef main(\n    gpus:Param(\"The GPUs to use for distribu"
  },
  {
    "path": "fastai/layers.py",
    "chars": 14873,
    "preview": "\"`fastai.layers` provides essential functions to building and modifying `model` architectures\"\nfrom .torch_core import *"
  },
  {
    "path": "fastai/metrics.py",
    "chars": 16163,
    "preview": "\"Implements various metrics to measure training accuracy\"\nfrom .torch_core import *\nfrom .callback import *\nfrom .layers"
  },
  {
    "path": "fastai/script.py",
    "chars": 1590,
    "preview": "import os, sys, subprocess, inspect\nfrom dataclasses import dataclass\nfrom typing import Any\nfrom argparse import Argume"
  },
  {
    "path": "fastai/sixel.py",
    "chars": 818,
    "preview": "from .core import *\n\nlibsixel = try_import('libsixel')\n\ndef _sixel_encode(data, width, height):\n    s = io.BytesIO()\n   "
  },
  {
    "path": "fastai/tabular/__init__.py",
    "chars": 228,
    "preview": "from .. import basics\nfrom ..basics import *\nfrom .data import *\nfrom .transform import *\nfrom .models import *\nfrom .. "
  },
  {
    "path": "fastai/tabular/data.py",
    "chars": 9337,
    "preview": "\"Data loading pipeline for structured data support. Loads from pandas DataFrame\"\nfrom ..torch_core import *\nfrom .transf"
  },
  {
    "path": "fastai/tabular/models.py",
    "chars": 3680,
    "preview": "from ..torch_core import *\nfrom ..layers import *\nfrom ..basic_data import *\nfrom ..basic_train import *\nfrom ..train im"
  },
  {
    "path": "fastai/tabular/transform.py",
    "chars": 9761,
    "preview": "\"Cleaning and feature engineering functions for structured data\"\nfrom ..torch_core import *\nfrom pandas.api.types import"
  },
  {
    "path": "fastai/test_registry.json",
    "chars": 49631,
    "preview": "{\n    \"fastai.basic_data.DataBunch\": [\n        {\n            \"file\": \"tests/test_data_block.py\",\n            \"line\": 152"
  },
  {
    "path": "fastai/text/__init__.py",
    "chars": 264,
    "preview": "from .. import basics\nfrom ..basics import *\nfrom .learner import *\nfrom .data import *\nfrom .transform import *\nfrom .m"
  },
  {
    "path": "fastai/text/data.py",
    "chars": 28614,
    "preview": "\"NLP data loading pipeline. Supports csv, folders, and preprocessed data.\"\nfrom ..torch_core import *\nfrom .transform im"
  },
  {
    "path": "fastai/text/interpret.py",
    "chars": 4862,
    "preview": "from ..torch_core import *\nfrom ..basic_data import *\nfrom ..basic_train import *\nfrom ..train import ClassificationInte"
  },
  {
    "path": "fastai/text/learner.py",
    "chars": 16208,
    "preview": "'Model training for NLP'\nfrom ..torch_core import *\nfrom ..basic_train import *\nfrom ..callbacks import *\nfrom ..data_bl"
  },
  {
    "path": "fastai/text/models/__init__.py",
    "chars": 103,
    "preview": "from .awd_lstm import *\nfrom .transformer import *\n__all__ = [*awd_lstm.__all__, *transformer.__all__]\n"
  },
  {
    "path": "fastai/text/models/awd_lstm.py",
    "chars": 12935,
    "preview": "from ...torch_core import *\nfrom ...layers import *\nfrom ...train import ClassificationInterpretation\nfrom ...basic_trai"
  },
  {
    "path": "fastai/text/models/bwd_forget_mult_cuda.cpp",
    "chars": 1309,
    "preview": "#include <torch/torch.h>\n\n#include <vector>\n\n// CUDA forward declarations\nat::Tensor bwd_forget_mult_cuda_forward(at::Te"
  },
  {
    "path": "fastai/text/models/bwd_forget_mult_cuda_kernel.cu",
    "chars": 4693,
    "preview": "#include <ATen/ATen.h>\n#include <THC/THC.h>\n\n#include <cuda.h>\n#include <cuda_runtime.h>\n\n#include <vector>\n\ntemplate <t"
  },
  {
    "path": "fastai/text/models/forget_mult_cuda.cpp",
    "chars": 1271,
    "preview": "#include <torch/torch.h>\n\n#include <vector>\n\n// CUDA forward declarations\nat::Tensor forget_mult_cuda_forward(at::Tensor"
  },
  {
    "path": "fastai/text/models/forget_mult_cuda_kernel.cu",
    "chars": 4861,
    "preview": "#include <ATen/ATen.h>\n#include <THC/THC.h>\n\n#include <cuda.h>\n#include <cuda_runtime.h>\n\n#include <vector>\n\ntemplate <t"
  },
  {
    "path": "fastai/text/models/qrnn.py",
    "chars": 9110,
    "preview": "from ...torch_core import *\nfrom torch.utils.cpp_extension import load\nfrom torch.autograd import Function\n\n__all__ = ['"
  },
  {
    "path": "fastai/text/models/transformer.py",
    "chars": 16521,
    "preview": "from ...torch_core import *\nfrom ...layers import *\nfrom .awd_lstm import RNNDropout, LinearDecoder, SequentialRNN\n\n__al"
  },
  {
    "path": "fastai/text/transform.py",
    "chars": 7048,
    "preview": "\"NLP data processing; tokenizes text and creates vocab indexes\"\nfrom ..torch_core import *\n\nimport spacy\nfrom spacy.symb"
  },
  {
    "path": "fastai/torch_core.py",
    "chars": 18781,
    "preview": "\"Utility functions to help deal with tensors\"\nfrom .imports.torch import *\nfrom .core import *\nfrom collections import O"
  },
  {
    "path": "fastai/train.py",
    "chars": 11900,
    "preview": "\"Provides advanced training extensions to `fastai.basic_train`. Includes half-precision, learning rate finder, mixup, an"
  },
  {
    "path": "fastai/utils/__init__.py",
    "chars": 61,
    "preview": "from .collect_env import *\n\n__all__ = [*collect_env.__all__]\n"
  },
  {
    "path": "fastai/utils/check_perf.py",
    "chars": 115,
    "preview": "from ..script import *\nfrom .collect_env import *\n\n# Temporary POC for module-based script\ncall_parse(check_perf)\n\n"
  },
  {
    "path": "fastai/utils/collect_env.py",
    "chars": 8613,
    "preview": "\"Utility functions to help deal with user environment\"\n\nfrom ..imports.torch import *\nfrom ..core import *\nfrom ..script"
  },
  {
    "path": "fastai/utils/ipython.py",
    "chars": 2418,
    "preview": "\"ipython utils\"\n\nimport os, functools, traceback, gc\n\ndef is_in_ipython():\n    \"Is the code running in the ipython envir"
  },
  {
    "path": "fastai/utils/mem.py",
    "chars": 8417,
    "preview": "\"Utility functions for memory management\"\n\nfrom ..imports.torch import *\nfrom ..core import *\nfrom ..script import *\nimp"
  },
  {
    "path": "fastai/utils/mod_display.py",
    "chars": 1157,
    "preview": "\" Utils for modifying what is displayed in notebooks and command line\"\nimport fastai\nimport fastprogress\n\nfrom ..basic_t"
  },
  {
    "path": "fastai/utils/pynvml_gate.py",
    "chars": 2197,
    "preview": "\"\"\"Get OS specific nvml wrapper. On OSX we use pynvx as drop in replacement for pynvml\"\"\"\n\nimport platform\nfrom ..script"
  },
  {
    "path": "fastai/utils/show_install.py",
    "chars": 217,
    "preview": "from ..script import *\nfrom .collect_env import *\n\n# Temporary POC for module-based script\n@call_parse\ndef main(show_nvi"
  },
  {
    "path": "fastai/version.py",
    "chars": 54,
    "preview": "__all__ = ['__version__']\n__version__ = '1.0.56.dev0'\n"
  },
  {
    "path": "fastai/vision/__init__.py",
    "chars": 330,
    "preview": "from .. import basics\nfrom ..basics import *\nfrom .learner import *\nfrom .image import *\nfrom .data import *\nfrom .trans"
  },
  {
    "path": "fastai/vision/cyclegan.py",
    "chars": 9644,
    "preview": "from ..torch_core import *\nfrom ..layers import *\nfrom ..callback import *\nfrom ..basic_train import Learner, LearnerCal"
  },
  {
    "path": "fastai/vision/data.py",
    "chars": 23540,
    "preview": "\"Manages data input pipeline - folderstransformbatch input. Includes support for classification, segmentation and boundi"
  },
  {
    "path": "fastai/vision/gan.py",
    "chars": 14706,
    "preview": "from ..torch_core import *\nfrom ..layers import *\nfrom ..callback import *\nfrom ..basic_data import *\nfrom ..basic_train"
  },
  {
    "path": "fastai/vision/image.py",
    "chars": 27358,
    "preview": "\"`Image` provides support to convert, transform and show images\"\nfrom ..torch_core import *\nfrom ..basic_data import *\nf"
  },
  {
    "path": "fastai/vision/interpret.py",
    "chars": 5230,
    "preview": "from ..torch_core import *\nfrom ..basic_data import *\nfrom ..basic_train import *\nfrom .image import *\nfrom ..train impo"
  },
  {
    "path": "fastai/vision/learner.py",
    "chars": 12458,
    "preview": "\"`Learner` support for computer vision\"\nfrom ..torch_core import *\nfrom ..basic_train import *\nfrom ..basic_data import "
  },
  {
    "path": "fastai/vision/models/__init__.py",
    "chars": 400,
    "preview": "from .xresnet import *\nfrom torchvision.models import ResNet,resnet18,resnet34,resnet50,resnet101,resnet152\nfrom torchvi"
  },
  {
    "path": "fastai/vision/models/cadene_models.py",
    "chars": 3293,
    "preview": "#These models are dowloaded via the repo https://github.com/Cadene/pretrained-models.pytorch\n#See licence here: https://"
  },
  {
    "path": "fastai/vision/models/darknet.py",
    "chars": 1544,
    "preview": "from ...torch_core import *\nfrom ...layers import *\n\n__all__ = ['Darknet', 'ResLayer']\n\ndef conv_bn_lrelu(ni:int, nf:int"
  },
  {
    "path": "fastai/vision/models/presnet.py",
    "chars": 4926,
    "preview": "from pdb import set_trace\nimport torch.nn.functional as F\nimport torch.nn as nn\nimport torch\nimport math\nimport torch.ut"
  },
  {
    "path": "fastai/vision/models/unet.py",
    "chars": 3599,
    "preview": "from ...torch_core import *\nfrom ...layers import *\nfrom ...callbacks.hooks import *\n\n__all__ = ['DynamicUnet', 'UnetBlo"
  },
  {
    "path": "fastai/vision/models/wrn.py",
    "chars": 2187,
    "preview": "from ...layers import *\nfrom ...torch_core import *\n\n__all__ = ['BasicBlock', 'WideResNet', 'wrn_22']\n\ndef _bn(ni, init_"
  },
  {
    "path": "fastai/vision/models/xception.py",
    "chars": 1732,
    "preview": "from ...vision import *\n\n__all__ = ['xception']\n\ndef sep_conv(ni,nf,pad=None,pool=False,act=True):\n    layers =  [nn.ReL"
  },
  {
    "path": "fastai/vision/models/xresnet.py",
    "chars": 3438,
    "preview": "import torch.nn as nn\nimport torch,math,sys\nimport torch.utils.model_zoo as model_zoo\nfrom functools import partial\nfrom"
  },
  {
    "path": "fastai/vision/models/xresnet2.py",
    "chars": 6602,
    "preview": "import torch.nn as nn\nimport torch\nimport math\nimport torch.utils.model_zoo as model_zoo\nfrom ...torch_core import Modul"
  },
  {
    "path": "fastai/vision/transform.py",
    "chars": 15409,
    "preview": "\"Image transformations for data augmentation. All transforms are done on the tensor level\"\nfrom ..torch_core import *\nfr"
  },
  {
    "path": "fastai/vision/tta.py",
    "chars": 1896,
    "preview": "\"Brings TTA (Test Time Functionality) to the `Learner` class. Use `learner.TTA()` instead\"\nfrom ..torch_core import *\nfr"
  },
  {
    "path": "fastai/widgets/__init__.py",
    "chars": 92,
    "preview": "from .class_confusion import *\nfrom .image_cleaner import *\nfrom .image_downloader import *\n"
  },
  {
    "path": "fastai/widgets/class_confusion.py",
    "chars": 8760,
    "preview": "import math\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom tqdm import tqdm\nfrom itertools import permutations"
  },
  {
    "path": "fastai/widgets/image_cleaner.py",
    "chars": 10884,
    "preview": "from ..torch_core import *\nfrom ..basic_train import *\nfrom ..basic_data import *\nfrom ..vision.data import *\nfrom ..vis"
  },
  {
    "path": "fastai/widgets/image_downloader.py",
    "chars": 9509,
    "preview": "from ..core import *\nfrom ..vision.data import *\nfrom ipywidgets import widgets, Layout, Output, HBox, VBox, Text, Bound"
  },
  {
    "path": "fid/LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "fid/fid_score.py",
    "chars": 10026,
    "preview": "#!/usr/bin/env python3\n\n# Code adapted and modified from https://github.com/mseitzer/pytorch-fid.  Licensing\n# and descr"
  },
  {
    "path": "fid/inception.py",
    "chars": 11399,
    "preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torchvision import models\n\ntry:\n    from torchvi"
  },
  {
    "path": "models/.gitkeep",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "requirements-colab.txt",
    "chars": 107,
    "preview": "fastai==1.0.60\ntensorboardX>=1.6\nffmpeg-python\nyt-dlp\nopencv-python>=4.2.0.32\nPillow\ntornado\nimgaug==0.2.6\n"
  },
  {
    "path": "requirements-dev.txt",
    "chars": 17,
    "preview": "black\npre-commit\n"
  },
  {
    "path": "requirements.txt",
    "chars": 218,
    "preview": "wandb\nfastai==1.0.60\ntensorboardX>=1.6\nffmpeg\nffmpeg-python\nyt-dlp\njupyterlab\nopencv-python>=4.2.0.32\nPillow==9.3.0\n--ex"
  },
  {
    "path": "setup.py",
    "chars": 1209,
    "preview": "from setuptools import setup, find_packages\n\n\ndef get_description():\n    return \"Deep Learning library for colorizing an"
  },
  {
    "path": "test_images/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "tox.ini",
    "chars": 303,
    "preview": "[tox]\nenvlist=static,format\nskipsdist=True\n\n[testenv]\nwhitelist_externals=\n\t/usr/bin/sh\n\t/usr/bin/test\n\n[testenv:format]"
  }
]

About this extraction

This page contains the full source code of the jantic/DeOldify GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 143 files (1.1 MB), approximately 308.3k tokens, and a symbol index with 2028 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!