Skip to content

Commit

Permalink
explaining image classifiers initial commit 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
SkalskiP committed Feb 16, 2020
1 parent c6a4351 commit 7660e53
Show file tree
Hide file tree
Showing 10 changed files with 5,073 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .gitignore
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

Large diffs are not rendered by default.

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
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
Loading

0 comments on commit 7660e53

Please sign in to comment.