from tglcourse.utils import *
The Library
This course is written in Jupyter notebooks. If you view the raw notebooks rather than the rendered website, you’ll see lots of extra syntax sprinkled around - thigs like ‘#|hide’ or ‘#|export’ at the top of a code cell. These are NBDev directives. Many are for visual formatting, but some (like ‘#|export’) tell the processing system to export parts of the code into separate files where they form components of the tglcourse
library. This means that any functions or classes defined in the notebooks and exported in this way can be used at a later date. In this notebook we’ll demonstrate some of these functions and their potential uses - if you’re curious about each you can always go back to the lesson where it is defined for more background info.
If you haven’t already, make sure you install the library and its requirements with pip install tglcourse
This is a WIP and needs some love.
= pil_from_url('https://johnowhitaker.github.io/tglcourse/index_files/figure-html/cell-2-output-1.png')
im 128, 128)) im.resize((
# TODO generation example (fix device requirements for OTStyleLossToTarget and co)
# TODO get list of all the things exported and what notebooks they come from
import glob
for f in glob.glob('tglcourse/*.py'):
if f.split('/')[1][0]!= '_':
with open(f, 'r') as ff:
print(f)
= ff.readlines()[:5]
lines print('From:', lines[0].split('../')[1].strip())
print('__all__:', lines[3].split('=')[1].strip(), '\n')
tglcourse/data_utils.py
From: 61_Datasets.ipynb.
__all__: ['to_tensor', 'mnist_transform', 'get_mnist_dl']
tglcourse/generation_utils.py
From: 62_Generators_and_Losses.ipynb.
__all__: ['PixelGenerator', 'MSELossToTarget', 'ImStackGenerator', 'calc_vgg_features', 'ContentLossToTarget',
tglcourse/lesson12.py
From: 12_DM1.ipynb.
__all__: ['BasicConvNet', 'PreNormResidual', 'FeedForward', 'MLPMixer', 'BasicUNet', 'NoiseConditionedUNet']
tglcourse/utils.py
From: 01_PyTorch_Basics.ipynb.
__all__: ['load_image_pil', 'pil_from_url', 'pil_to_tensor', 'tensor_to_pil']