Fastai implementation of papers.
Project description
Welcome to fastpapers
Play LEGO with papers.
#all_slow
fastpapers
is a python library where I use fastai to reproduce papers on Jupyter Notebooks. I use nbdev to turn these notebooks into modules.
Install
pip install fastpapers
How to use
Train DETR in 3 lines of code
Download the data
path = download_coco(force_download=False)
Create the DataLoaders, the Learner, and fit.
dls = CocoDataLoaders.from_sources(path, vocab=coco_vocab, num_workers=0)
learnd = detr_learner(dls)
learnd.fit(1, lr=[1e-5, 1e-5, 1e-5])
epoch | train_loss | valid_loss | AP | AP50 | AP75 | AP_small | AP_medium | AP_large | AR1 | AR10 | AR100 | AR_small | AR_medium | AR_large | time |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 5.892842 | 7.636298 | 0.475381 | 0.574125 | 0.506063 | 0.297741 | 0.458006 | 0.560994 | 0.355018 | 0.545646 | 0.560374 | 0.375141 | 0.541728 | 0.630330 | 2:05:24 |
Show the results
with learnd.removed_cbs(learnd.coco_eval): learnd.show_results(max_n=8, figsize=(10,10))
Superresolution in 4 lines of code
Download the data
path = untar_data(URLs.IMAGENETTE)
Create the DataLoaders, the Learner adn fit.
#hide_output
db = DataBlock(blocks=(ResImageBlock(72), ResImageBlock(288)),
get_items=get_image_files,
batch_tfms=Normalize.from_stats([0.5]*3, [0.5]*3))
dls = db.dataloaders(path, bs=4, num_workers=4)
learn = superres_learner(dls)
learn.fit(16, lr=1e-3, wd=0)
learn.show_results()
Library structure
The name of each module is the bibtexkey of the corresponing paper. For example, if you want to use the FID metric from Heusel, Martin, et al. 2017, you can import it like so:
from fastpapers.heusel2017gans import FIDMetric
If you want to train a pix2pix model from Isola, Phillip, et al you can import a pix2pix_learner
from fastpapers.isola2017image import pix2pix_learner
The core
module contains functions and classes that are useful for several papers.
For example, you have a ImageNTuple
to work with an arbitrary amount of images as input.
path = untar_data(URLs.PETS)
files = get_image_files(path/"images")
it = ImageNTuple.create((files[0], files[1], files[2]))
it = Resize(224)(it)
it = ToTensor()(it)
it.show();
Or useful functions for debuging like explode_shapes
or explode_ranges
explode_shapes(it)
[(3, 224, 224), (3, 224, 224), (3, 224, 224)]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastpapers-0.0.8.tar.gz
.
File metadata
- Download URL: fastpapers-0.0.8.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a39c92482e6e1b30da6ff76a3757e4cba970a6615d7d81818f4e286052891f |
|
MD5 | 487dc19fac3809118dab54e383ae1648 |
|
BLAKE2b-256 | 6206057e42be702a137aca416a218be8a33b066d719fef1b091cd4d6fac0cb66 |
File details
Details for the file fastpapers-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: fastpapers-0.0.8-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a7b2615e6aeacf615e5aea4150623040612ebe1f02fd385876e531814b06b4 |
|
MD5 | c2687fdbb0706e76dffb59e327aac5d4 |
|
BLAKE2b-256 | 9cd0689a192bb0e0f2700d95faf72cae2fc7706db494dee3195eb719c51d7154 |