From 65659bcf108e75d17cd3a416de655597c47d0bee Mon Sep 17 00:00:00 2001 From: Alycia Date: Sun, 17 Feb 2019 15:28:54 -0800 Subject: [PATCH] Add lower() to mirror, small edits to README --- AutoTransformPy/mirror.py | 6 +++--- README.md | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/AutoTransformPy/mirror.py b/AutoTransformPy/mirror.py index ae4bd2c..9477cdd 100644 --- a/AutoTransformPy/mirror.py +++ b/AutoTransformPy/mirror.py @@ -39,7 +39,7 @@ def mirror (image_path, direction = 'all'): if not isinstance(direction, str): raise TypeError("The direction must be a string: 'horizontal', 'vertical', or 'all'") - if not direction in ["horizontal","vertical", "all"]: + if not direction.lower() in ["horizontal","vertical", "all"]: raise ValueError("The direction must be 'horizontal', 'vertical' or 'all'") if not os.path.isfile(image_path): @@ -50,12 +50,12 @@ def mirror (image_path, direction = 'all'): mirrored_images = [img] # flip horizontally - if direction == 'horizontal' or direction == 'all': + if direction.lower() == 'horizontal' or direction.lower() == 'all': horiz_image = np.fliplr(img) mirrored_images.append(horiz_image) # flip vertically - if direction == 'vertical' or direction == 'all': + if direction.lower() == 'vertical' or direction.lower() == 'all': vert_image = img[::-1] mirrored_images.append(vert_image) diff --git a/README.md b/README.md index eed82cb..669b13b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AutoTransform -### Contributors +## Contributors | Name | GitHub | |---|---| @@ -9,11 +9,11 @@ | Rayce Rossum | [RayceRossum](https://github.com/RayceRossum) | -### Overview +## Overview A common application of supervised machine learning is identifying the object of an image. One issue that users encounter is a model misclassifying a new image because the object is rotated or translated in some way that was not captured in the training images. The purpose of this package is to create a more robust set of images for users to train their model with. The package will accept an image as an input, apply a series of transformations to it, and return an array of transformed pixel values. Transformations include: rotating, mirroring, and translating (shifting the object's location in the frame). -### Functions +## Functions #### Rotate @@ -28,21 +28,21 @@ Mirrors an image in the horizontal and/or vertical direction and returns the pix Translate will move an image within its frame, so that the topic of the image will be shifted to a new location in the frame. The distance and direction of translation will be chosen randomly, but the user specifies the maximum distance of the translation and the number of images they want generated. It returns the pixel values of the translated images. -### Python Environment +## Python Environment Scikit-image is a image processing package that contains functions for performing various operations to images, such as rotating or resizing, among many others. AutoTransformPy utilizes some of this packages functionality and builds it out, so the user can easily gain many variations of an image. The intended usage of this package is for the development of a larger set of training images for the training of an image classification algorithms. -### Installation +## Installation To install AutoTransformPy: 1. In your console, type: `pip install git+https://github.com/UBC-MDS/AutoTransformPy.git` 2. You can now use AutoTransformPy. See usage instructions below: -### Usage +## Usage -#### Rotate +### Rotate `from AutoTransformPy.rotate import rotate` @@ -56,14 +56,14 @@ To install AutoTransformPy: **Output:** -- An np.array of pixel values of the rotated images. Array contains `num_images`. +- An np.array of pixel values of the rotated images. Array contains `num_images` + 1 images (original plus all translated images) **Example:** - `rotate("../tests/imgs/milad.jpg", 10, 280)` -#### Mirror +### Mirror `from AutoTransformPy.mirror import mirror` @@ -83,7 +83,7 @@ To install AutoTransformPy: - `mirror("../tests/imgs/milad.jpg", "horizontal")` -#### Translate +### Translate `from AutoTransformPy.translate import translate` @@ -104,7 +104,7 @@ To install AutoTransformPy: - `translate("../tests/imgs/milad.jpg", 5, 80)` -### Package Dependencies +## Package Dependencies - `numpy` - `skimage`