duckgoose
Utility scripts for the online fast.ai course. There are two main parts: one to download and organise arbitrary image classes, and one to highlight what parts of an image is activating the decision for a classification.
- Utility for Lesson 1 experimentation with external image classes. The script:
- Downloads images from google images for specific classes
- Sanity checks that images can be opened and have three channels
- Organises the images into separate folders (train/valid/test + classes) as expected by the fast.ai library
- Utility for creating Class Activation Maps for both classifications.
Prerequisites
chromedriveris required. On ubuntu/debian:sudo apt-get chromium-chromedriver
Installation
pip install duckgoose
Usage
Fetching, sanity checking and organising images
from duckgoose import fetchImagesAndPrepForClassification
# dictionary structure `class_name => search term`
image_classes = { 'ducks' : 'ducks -rubber' , 'geese' : 'geese' }
download_path = '/home/myuser/data/downloaded_from_google'
output_path = '/home/myuser/data/ducksgeese/'
number_of_images = 100
fetchImagesAndPrepForClassification(image_classes, download_path, output_path, number_of_images)
Create Class Activation Maps (CAM)
Note: This was implemented for fastai v2 part 1. Here is a full example of creating a class activation maps for ducks and geese using fast ai.
from fastai.imports import *
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *
from duckgoose.cam import calculateAndChartHeatZoneFor
PATH = "data/ducksgeese/"
sz=224
arch = resnet34
bs = 64
m = arch(True)
m = nn.Sequential(*children(m)[:-2],
nn.Conv2d(512, 2, 3, padding=1),
nn.AdaptiveAvgPool2d(1),
Flatten(),
nn.LogSoftmax())
tfms = tfms_from_model(arch, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
data = ImageClassifierData.from_paths(PATH, tfms=tfms, bs=bs)
learn = ConvLearner.from_model_data(m, data)
learn.freeze_to(-4)
_, val_tfms = tfms_from_model(learn.model, sz)
learn.fit(0.01, 2)
calculateAndChartHeatZoneFor('./data/ducksgeese/test/ducks/ducks_427.jpg', val_tfms, learn)
License
Metadata
Release files for duckgoose 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| duckgoose-0.1.8.tar.gz | 5.2 kB | Without provenance | Details for duckgoose-0.1.8.tar.gz |
Release files / duckgoose-0.1.8.tar.gz
| Download URL | duckgoose-0.1.8.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b767cb7d06c07febe6104956cb38eaa2bb447876d624010f3f99fd0cfc45cb91
|
|
BLAKE2b-256 checksum How to use checksums |
802256e3dee6d7c3c78b420f3d28b1ee66eefb3e8a531275d8a77ae66ac4a95c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
|
Security for duckgoose 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.