forked from SkalskiP/ILearnDeepLearning.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
explaining image classifiers initial commit 🎉
- Loading branch information
Showing
10 changed files
with
5,073 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
.idea/* | ||
**/data | ||
.env/* | ||
# Notebook data files | ||
notebooks/*.pkl | ||
notebooks/*.tsv | ||
# Jupyter checkpoints | ||
**/.ipynb_checkpoints | ||
|
||
# PyCharm and mac and azure ml and VS Code files | ||
.idea | ||
.DS_Store | ||
.azureml | ||
.vscode | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Environments | ||
**/data | ||
**/dataset | ||
**/.env |
948 changes: 948 additions & 0 deletions
948
...ining_image_classifier_predictions/01_coco_res_net/coco-resnet-keras-resnet-34-eli5.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...science_toolkit/03_explaining_image_classifier_predictions/01_coco_res_net/coco_loader.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from skimage.io import imread | ||
from skimage.transform import resize | ||
import numpy as np | ||
|
||
class CocoLoader: | ||
|
||
IMG_WIDTH = 224 | ||
IMG_HEIGHT = 224 | ||
IMG_CHANNEL = 3 | ||
|
||
def preprocess_image(self, path: str): | ||
x = imread(path) | ||
x = resize(x, (CocoLoader.IMG_WIDTH, CocoLoader.IMG_HEIGHT)) * 255 | ||
return x | ||
|
||
def load_sample(self, size: int): | ||
with open("./dataset/5k.txt", "r") as f: | ||
images_paths = f.read().split('\n') | ||
dataset = np.ndarray(shape=(size, CocoLoader.IMG_WIDTH, CocoLoader.IMG_HEIGHT, CocoLoader.IMG_CHANNEL), dtype=np.float32) | ||
for index, images_path in enumerate(images_paths[:size]): | ||
dataset[index] = self.preprocess_image(images_path) | ||
return dataset |
28 changes: 28 additions & 0 deletions
28
...kit/03_explaining_image_classifier_predictions/01_coco_res_net/get_coco_dataset_sample.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# CREDIT: https://github.com/pjreddie/darknet/tree/master/scripts/get_coco_dataset.sh | ||
|
||
mkdir dataset | ||
cd dataset | ||
|
||
mkdir coco | ||
cd coco | ||
|
||
mkdir images | ||
cd images | ||
|
||
# Download Images | ||
wget -c https://pjreddie.com/media/files/val2014.zip | ||
|
||
# Unzip | ||
unzip -q val2014.zip | ||
|
||
cd .. | ||
cd .. | ||
|
||
wget -c https://pjreddie.com/media/files/coco/5k.part | ||
wget -c https://pjreddie.com/media/files/coco/labels.tgz | ||
tar xzf labels.tgz | ||
|
||
# Set Up Image Lists | ||
paste <(awk "{print \"$PWD/coco\"}" <5k.part) 5k.part | tr -d '\t' > 5k.txt |
Oops, something went wrong.