All Projects → kobiso → Image-Rotation-and-Cropping-tensorflow

kobiso / Image-Rotation-and-Cropping-tensorflow

Licence: other
Image rotation and cropping out the black borders in TensorFlow

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Image-Rotation-and-Cropping-tensorflow

Dali
A GPU-accelerated library containing highly optimized building blocks and an execution engine for data processing to accelerate deep learning training and inference applications.
Stars: ✭ 3,624 (+25785.71%)
Mutual labels:  data-augmentation, image-augmentation
mrnet
Building an ACL tear detector to spot knee injuries from MRIs with PyTorch (MRNet)
Stars: ✭ 98 (+600%)
Mutual labels:  data-augmentation
Stylealign
[ICCV 2019]Aggregation via Separation: Boosting Facial Landmark Detector with Semi-Supervised Style Transition
Stars: ✭ 172 (+1128.57%)
Mutual labels:  data-augmentation
Nlp Data Augmentation
Data Augmentation for NLP. NLP数据增强
Stars: ✭ 235 (+1578.57%)
Mutual labels:  data-augmentation
Muda
A library for augmenting annotated audio data
Stars: ✭ 177 (+1164.29%)
Mutual labels:  data-augmentation
Solt
Streaming over lightweight data transformations
Stars: ✭ 249 (+1678.57%)
Mutual labels:  data-augmentation
Imagecorruptions
Python package to corrupt arbitrary images.
Stars: ✭ 158 (+1028.57%)
Mutual labels:  data-augmentation
advchain
[Medical Image Analysis] Adversarial Data Augmentation with Chained Transformations (AdvChain)
Stars: ✭ 32 (+128.57%)
Mutual labels:  data-augmentation
ChineseNER
中文NER的那些事儿
Stars: ✭ 241 (+1621.43%)
Mutual labels:  data-augmentation
Syndata Generation
Code used to generate synthetic scenes and bounding box annotations for object detection. This was used to generate data used in the Cut, Paste and Learn paper
Stars: ✭ 214 (+1428.57%)
Mutual labels:  data-augmentation
Face.evolve.pytorch
🔥🔥High-Performance Face Recognition Library on PaddlePaddle & PyTorch🔥🔥
Stars: ✭ 2,719 (+19321.43%)
Mutual labels:  data-augmentation
Tsaug
A Python package for time series augmentation
Stars: ✭ 180 (+1185.71%)
Mutual labels:  data-augmentation
Mixup Generator
An implementation of "mixup: Beyond Empirical Risk Minimization"
Stars: ✭ 250 (+1685.71%)
Mutual labels:  data-augmentation
Torch videovision
Transforms for video datasets in pytorch
Stars: ✭ 174 (+1142.86%)
Mutual labels:  data-augmentation
machine learning course
Artificial intelligence/machine learning course at UCF in Spring 2020 (Fall 2019 and Spring 2019)
Stars: ✭ 47 (+235.71%)
Mutual labels:  data-augmentation
Torch Audiomentations
Fast audio data augmentation in PyTorch. Inspired by audiomentations. Useful for deep learning.
Stars: ✭ 164 (+1071.43%)
Mutual labels:  data-augmentation
Scaper
A library for soundscape synthesis and augmentation
Stars: ✭ 186 (+1228.57%)
Mutual labels:  data-augmentation
Zeroth
Kaldi-based Korean ASR (한국어 음성인식) open-source project
Stars: ✭ 248 (+1671.43%)
Mutual labels:  data-augmentation
specAugment
Tensor2tensor experiment with SpecAugment
Stars: ✭ 46 (+228.57%)
Mutual labels:  data-augmentation
GaNDLF
A generalizable application framework for segmentation, regression, and classification using PyTorch
Stars: ✭ 77 (+450%)
Mutual labels:  data-augmentation

Image Rotation and Cropping in TensorFlow

This is an implementation and visualization of image rotation and cropping out black borders in TensorFlow. TensorFlow support only image rotation function tf.contrib.image.rotate(images, angles, interpolation, name). However, when you rotate an image with this function, there will be black noise on each border as below.

Goal

So, we want to cropping out this black borders in TensorFlow, especially when the image is loaded as Tensor and it has to go through preprocessing phase. The implementation include example and visualization with Tiny Imagenet.

Core Functions

If you do not want to run the code or see the visualization, you can just copy and paste the core functions. In read_tfrecord.py file, _rotate_and_crop(image, output_height, output_width, rotation_degree, do_crop) and _largest_rotated_rect(w, h, angle) are core functions.

Prerequisites

  • Python 3.4+
  • TensorFlow 1.5+
  • Jupyter Notebook
  • Python packages: requirements.txt
    • Simply install it by running : pip install -r /path/to/requirements.txt in the shell

Prepare the Tiny ImageNet

Download the Tiny ImageNet in this link and unzip it. Set the path of the dataset on variable TINY_IMAGENET_DIRECTORY in build_tfrecords.ipynb file.

Convert to TFRecords

As test set does not include class labels and bounding boxes, validation set will be used as test set in this implementation. And training set will be divided with certain percentage (as you defined) into training set and validation set. Each data set (training, validation and test) will have iamges, labels and bounding box information.

To convert Tiny ImageNet to TFRecords, set each requiring path in build_tfrecords.ipynb and run all cell. Then TFRecords files will be created in the designated path you defined. Note that you can set the validation ratio in the variable VALIDATION_RATIO.

Visualize Original, Rotated and Cropped Image

You can check and visualize TFRecords file in check_tfrecords.ipynb. In read_tfrecord.read_tfrecord() function, you can set rotation_degree and do_crop arguments to rotate and crop images.

  • Original Image

Example1

  • Rotated Image

Example2

  • Rotated and Cropped Image

Example3

Reference

Author

Byung Soo Ko / [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].