All Projects → Ximilar-com → tf-image

Ximilar-com / tf-image

Licence: MIT license
TensorFlow2+ graph image augmentation library optimized for tf.data.Dataset.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to tf-image

transformer
Build English-Vietnamese machine translation with ProtonX Transformer. :D
Stars: ✭ 41 (+70.83%)
Mutual labels:  tensorflow2
Open-Source-Models
Address book for computer vision models.
Stars: ✭ 30 (+25%)
Mutual labels:  tensorflow2
golang-tf
Working golang + tensorflow
Stars: ✭ 21 (-12.5%)
Mutual labels:  tensorflow2
tensorflow-maml
TensorFlow 2.0 implementation of MAML.
Stars: ✭ 79 (+229.17%)
Mutual labels:  tensorflow2
TensorFlow2.0 SSD
A tensorflow_2.0 implementation of SSD (Single Shot MultiBox Detector) .
Stars: ✭ 83 (+245.83%)
Mutual labels:  tensorflow2
gans-2.0
Generative Adversarial Networks in TensorFlow 2.0
Stars: ✭ 76 (+216.67%)
Mutual labels:  tensorflow2
AiSpace
AiSpace: Better practices for deep learning model development and deployment For Tensorflow 2.0
Stars: ✭ 28 (+16.67%)
Mutual labels:  tensorflow2
doctr
docTR (Document Text Recognition) - a seamless, high-performing & accessible library for OCR-related tasks powered by Deep Learning.
Stars: ✭ 1,409 (+5770.83%)
Mutual labels:  tensorflow2
3D-GuidedGradCAM-for-Medical-Imaging
This Repo containes the implemnetation of generating Guided-GradCAM for 3D medical Imaging using Nifti file in tensorflow 2.0. Different input files can be used in that case need to edit the input to the Guided-gradCAM model.
Stars: ✭ 60 (+150%)
Mutual labels:  tensorflow2
CV
本仓库将使用Pytorch框架实现经典的图像分类网络、目标检测网络、图像分割网络,图像生成网络等,并会持续更新!!!
Stars: ✭ 72 (+200%)
Mutual labels:  image-augmentation
E2E-Object-Detection-in-TFLite
This repository shows how to train a custom detection model with the TFOD API, optimize it with TFLite, and perform inference with the optimized model.
Stars: ✭ 28 (+16.67%)
Mutual labels:  tensorflow2
manning tf2 in action
The official code repository for "TensorFlow in Action" by Manning.
Stars: ✭ 61 (+154.17%)
Mutual labels:  tensorflow2
Bearcat captcha
熊猫识别不定长验证码,基于tensorflow2.2(tensorflow2.3也可以运行)轻松就能练出不错的模型
Stars: ✭ 67 (+179.17%)
Mutual labels:  tensorflow2
checkmate
Training neural networks in TensorFlow 2.0 with 5x less memory
Stars: ✭ 116 (+383.33%)
Mutual labels:  tensorflow2
Adaptive-Gradient-Clipping
Minimal implementation of adaptive gradient clipping (https://arxiv.org/abs/2102.06171) in TensorFlow 2.
Stars: ✭ 74 (+208.33%)
Mutual labels:  tensorflow2
pyradox
State of the Art Neural Networks for Deep Learning
Stars: ✭ 61 (+154.17%)
Mutual labels:  tensorflow2
Image-Rotation-and-Cropping-tensorflow
Image rotation and cropping out the black borders in TensorFlow
Stars: ✭ 14 (-41.67%)
Mutual labels:  image-augmentation
A-Barebones-Image-Retrieval-System
This project presents a simple framework to retrieve images similar to a query image.
Stars: ✭ 25 (+4.17%)
Mutual labels:  tensorflow2
point-cloud-segmentation
TF2 implementation of PointNet for segmenting point clouds
Stars: ✭ 33 (+37.5%)
Mutual labels:  tensorflow2
potato-disease-classification
Potato Disease Classification - Training, Rest APIs, and Frontend to test.
Stars: ✭ 95 (+295.83%)
Mutual labels:  tensorflow2

tf-image

tf-image implements methods for image augmentation for Tensorflow 2.+ / tf.data.Dataset.

Why?

Official TensorFlow 2+ tf.image package contains just a few and simple operations for image augmentation. This is not enough if you want to augment images and using all the power of tf.data.Dataset. There is also tf-addons projects which contains more of the operations (for example rotate), but it still not enough. And on top of that, none of those two supports operation on bounding boxes and therefore is not fully usable for augmentation object detection datasets.

If you do not require the operations in graph then simply use cv2, imgaug or albumentations together with tf.py_function. They have (at the moment) much more operations and options for image augmentation.

Installation

Use pip:

pip install tf-image

For installation from source code, clone the repository and install it from code (pip install -e .). There are no dependencies specified. You have to install TensorFlow 2+ and appropriate TensorFlow Addons. Specific version is on you, we wanted to keep this library as general as possible.

Image and bounding boxes formats

We use channel last format for images. Images can be represented either in 0.0 - 1.0 or 0 - 255 range. Similar is true for bounding boxes. They can be provided either in relative coordinates with range 0.0 - 1.0 using float dtype or in absolute image coordinates using integer dtype. Internally, This is done using convert_type decorator on functions which needs it. This decorator converts the images into the type we use (tf.float and 0.0-1.1 in both cases) and after the function is done, original format is restored. If performing multiple operations, you can use this decorator on own function. (Conversions after each operation will not be needed.)

Quickstart

For your convenience, we included a simple and configurable application, which combines all the provided augmentations. They are performed in a random order to make the augmentation even more powerful.

There is also one script which uses this augmentation function and which outputs three augmented image without bounding boxes and three with bonding boxes. See example/example.py for more information.

If you want to use the functions alone, here is how:

import tensorflow as tf
import tensorflow_addons as tfa

from tf_image.core.random import random_function
from tf_image.core.colors import rgb_shift, channel_drop
from tf_image.core.convert_type_decorator import convert_type


@convert_type
def augment_image(image):
    # use TensorFlow library
    image = tf.image.random_flip_left_right(image)
    image = tf.image.random_flip_up_down(image)

    # use tf-image library
    image = random_function(
        image, rgb_shift, 0.1, None, **{"r_shift": 0.1, "g_shift": 0.1, "b_shift": 0.1}
    )  # do rgb shift with 10 % prob
    image = random_function(image, channel_drop, 0.1, None)
    # and whatever else you want

    # use TensorFlow Addons library
    image = tfa.image.rotate(image, 10)

    return image


def map_function(image_file, label):
    image = tf.io.read_file(image_file)
    image = tf.image.decode_jpeg(image)
    image = augment_image(image)

    return image, label


def return_dataset(image_files, labels):
    dataset = (
        tf.data.Dataset.from_tensor_slices((image_files, labels))
        .cache()
        .shuffle(len(image_files))
        .map(map_function)
        .batch(20)
        .prefetch(tf.data.experimental.AUTOTUNE)
    )

    return dataset

return_dataset(["images/ximilar-similar.jpg"], [[1,2,3]])

Supported operations

Image augmentations:

  • aspect ration deformations (inc. bounding boxes)
  • channel drop
  • channel swap
  • erase, see [https://arxiv.org/abs/1708.04552] (repeated, inc. bounding boxes)
  • flip up-down, left-right (inc. bounding boxes)
  • grayscale
  • gaussian noise
  • clip (inc. bounding boxes)
  • rgb shift
  • resize with different methods (inc. bounding boxes)
  • rotate (inc. bounding boxes)

Random operations:

  • random_function: calls function on image with some probability [0.0, 0.1]
  • random_function_bboxes: calls function on image and bounding boxes with some probability [0.0, 0.1]

Feel free to improve and add more functions. We are looking forward to your merge requests! (Please only plain tensorflow2+, no opencv.)

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].