Image classification for projects and researches

Overview

Python 3.7 Python 3.8 MIT License Coverage

KERAS CLASSIFY

Image classification for projects and researches

About The Project

Image classification is a commonly used problem in the experimental part of scientific papers and also frequently appears as part of the projects. With the desire to reduce time and effort, Keras Classify was created.

Getting Started

Installation

  1. Clone the repo: https://github.com/nguyentruonglau/keras-classify.git

  2. Install packages

    > python -m venv 
         
          
    > activate.bat (in scripts folder)
    > pip install -r requirements.txt
    
         

Todo List:

  • Cosine learning rate scheduler
  • Gradient-based Localization
  • Sota models
  • Synthetic data
  • Smart Resize
  • Support Python 3.X and Tf 2.X
  • Use imagaug for augmentation data
  • Use prefetching and multiprocessing to training.
  • Analysis Of Input Shape
  • Compiled using XLA, auto-clustering on GPU
  • Receiver operating characteristic

Quick Start

Analysis Of Input Shape

If your data has random input_shape, you don't know which input_shape to choose, the analysis program is the right choice for you. The algorithm is applied to analyze: Kernel Density Estimation.

Convert Data

From tensorflow 2.3.x already support auto fit_generator, however moving the data to npy file will make it easier to manage. The algorithm is applied to shuffle data: Random Permutation. Read more here.

Run: python convert/convert_npy.py

Training Model.

Design your model at model/models.py, we have made EfficientNetB0 the default. Adjust the appropriate hyperparameters and run: python train.py

Evaluate Model.

  • Statistics number of images per class after suffle on test data.

  • Provide model evalution indicators such as: Accuracy, Precesion, Recall, F1-Score and AUC (Area Under the Curve).

  • Plot training history of Accuracy, Loss, Receiver Operating Characteristic curve and Confusion Matrix.

Explainable AI.

Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization. "We propose a technique for producing 'visual explanations' for decisions from a large class of CNN-based models, making them more transparent" Ramprasaath R. Selvaraju ... Read more here.

Example Code

Use for projects

from keras.preprocessing.image import load_img, img_to_array
from keras.preprocessing.image import smart_resize
from tensorflow.keras.models import load_model
import tensorflow as tf
import numpy as np

#load pretrained model
model_path = 'data/output/model/val_accuracy_max.h5'
model = load_model(model_path)

#load data
img_path = 'images/images.jpg'
img = load_img(img_path)
img = img_to_array(img)
img = smart_resize(img, (72,72)) #resize to HxW
img = np.expand_dims(img, axis=0)

#prediction
y_pred = model.predict(img)
y_pred = np.argmax(y_pred, axis=1)

#see convert/output/label_decode.json
print(y_pred)

Smart resize (tf < 2.4.1)

from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.preprocessing.image load_img
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import image_ops
import numpy as np

def smart_resize(img, new_size, interpolation='bilinear'):
    """Resize images to a target size without aspect ratio distortion.

    Arguments:
      img (3D array): image data
      new_size (tuple): HxW

    Returns:
      [3D array]: image after resize
    """
    # Get infor of the image
    height, width, _ = img.shape
    target_height, target_width = new_size

    crop_height = (width * target_height) // target_width
    crop_width = (height * target_width) // target_height

    # Set back to input height / width if crop_height / crop_width is not smaller.
    crop_height = np.min([height, crop_height])
    crop_width = np.min([width, crop_width])

    crop_box_hstart = (height - crop_height) // 2
    crop_box_wstart = (width - crop_width) // 2

    # Infor to resize image
    crop_box_start = array_ops.stack([crop_box_hstart, crop_box_wstart, 0])
    crop_box_size = array_ops.stack([crop_height, crop_width, -1])

    img = array_ops.slice(img, crop_box_start, crop_box_size)
    img = image_ops.resize_images_v2(
        images=img,
        size=new_size,
        method=interpolation)
    return img.numpy()

Contributor

  1. BS Nguyen Truong Lau ([email protected])
  2. PhD Thai Trung Hieu ([email protected])

License

Distributed under the MIT License. See LICENSE for more information.

You might also like...
An end-to-end PyTorch framework for image and video classification
An end-to-end PyTorch framework for image and video classification

What's New: March 2021: Added RegNetZ models November 2020: Vision Transformers now available, with training recipes! 2020-11-20: Classy Vision v0.5 R

Scripts for training an AI to play the endless runner Subway Surfers using a supervised machine learning approach by imitation and a convolutional neural network (CNN) for image classification
Scripts for training an AI to play the endless runner Subway Surfers using a supervised machine learning approach by imitation and a convolutional neural network (CNN) for image classification

About subwAI subwAI - a project for training an AI to play the endless runner Subway Surfers using a supervised machine learning approach by imitation

PyTorch implementation of our method for adversarial attacks and defenses in hyperspectral image classification.
PyTorch implementation of our method for adversarial attacks and defenses in hyperspectral image classification.

Self-Attention Context Network for Hyperspectral Image Classification PyTorch implementation of our method for adversarial attacks and defenses in hyp

Code image classification of MNIST dataset using different architectures: simple linear NN, autoencoder, and highway network

Deep Learning for image classification pip install -r http://webia.lip6.fr/~baskiotisn/requirements-amal.txt Train an autoencoder python3 train_auto

A PyTorch Image-Classification With AlexNet And ResNet50.

PyTorch 图像分类 依赖库的下载与安装 在终端中执行 pip install -r -requirements.txt 完成项目依赖库的安装 使用方式 数据集的准备 STL10 数据集 下载:STL-10 Dataset 存储位置:将下载后的数据集中 train_X.bin,train_y.b

CNN Based Meta-Learning for Noisy Image Classification and Template Matching

CNN Based Meta-Learning for Noisy Image Classification and Template Matching Introduction This master thesis used a few-shot meta learning approach to

Code of Classification Saliency-Based Rule for Visible and Infrared Image Fusion

CSF Code of Classification Saliency-Based Rule for Visible and Infrared Image Fusion Tips: For testing: CUDA_VISIBLE_DEVICES=0 python main.py For trai

A python-image-classification web application project, written in Python and served through the Flask Microframework
A python-image-classification web application project, written in Python and served through the Flask Microframework

A python-image-classification web application project, written in Python and served through the Flask Microframework. This Project implements the VGG16 covolutional neural network, through Keras and Tensorflow wrappers, to make predictions on uploaded images.

All the essential resources and template code needed to understand and practice data structures and algorithms in python with few small projects to demonstrate their practical application.

Data Structures and Algorithms Python INDEX 1. Resources - Books Data Structures - Reema Thareja competitiveCoding Big-O Cheat Sheet DAA Syllabus Inte

Releases(v1.0.0)
Owner
Nguyễn Trường Lâu
AI Researcher at FPT Software
Nguyễn Trường Lâu
A PyTorch implementation of EfficientDet.

A PyTorch impl of EfficientDet faithful to the original Google impl w/ ported weights

Ross Wightman 1.4k Jan 07, 2023
Pytorch implementation of SimSiam Architecture

SimSiam-pytorch A simple pytorch implementation of Exploring Simple Siamese Representation Learning which is developed by Facebook AI Research (FAIR)

Saeed Shurrab 1 Oct 20, 2021
Pytorch implementation of One-Shot Affordance Detection

One-shot Affordance Detection PyTorch implementation of our one-shot affordance detection models. This repository contains PyTorch evaluation code, tr

46 Dec 12, 2022
A Robust Unsupervised Ensemble of Feature-Based Explanations using Restricted Boltzmann Machines

A Robust Unsupervised Ensemble of Feature-Based Explanations using Restricted Boltzmann Machines Understanding the results of deep neural networks is

Johan van den Heuvel 2 Dec 13, 2021
Plato: A New Framework for Federated Learning Research

a new software framework to facilitate scalable federated learning research.

System <a href=[email protected] Lab"> 192 Jan 05, 2023
Image Segmentation with U-Net Algorithm on Carvana Dataset using AWS Sagemaker

Image Segmentation with U-Net Algorithm on Carvana Dataset using AWS Sagemaker This is a full project of image segmentation using the model built with

Htin Aung Lu 1 Jan 04, 2022
MINOS: Multimodal Indoor Simulator

MINOS Simulator MINOS is a simulator designed to support the development of multisensory models for goal-directed navigation in complex indoor environ

194 Dec 27, 2022
Automated Melanoma Recognition in Dermoscopy Images via Very Deep Residual Networks

Introduction This repository contains the modified caffe library and network architectures for our paper "Automated Melanoma Recognition in Dermoscopy

Lequan Yu 47 Nov 24, 2022
DUE: End-to-End Document Understanding Benchmark

This is the repository that provide tools to download data, reproduce the baseline results and evaluation. What can you achieve with this guide Based

21 Dec 29, 2022
FL-WBC: Enhancing Robustness against Model Poisoning Attacks in Federated Learning from a Client Perspective

FL-WBC: Enhancing Robustness against Model Poisoning Attacks in Federated Learning from a Client Perspective Official implementation of "FL-WBC: Enhan

Jingwei Sun 26 Nov 28, 2022
Machine Learning Models were applied to predict the mass of the brain based on gender, age ranges, and head size.

Brain Weight in Humans Variations of head sizes and brain weights in humans Kaggle dataset obtained from this link by Anubhab Swain. Image obtained fr

Anne Livia 1 Feb 02, 2022
An official implementation of the Anchor DETR.

Anchor DETR: Query Design for Transformer-Based Detector Introduction This repository is an official implementation of the Anchor DETR. We encode the

MEGVII Research 276 Dec 28, 2022
This project aims to be a handler for input creation and running of multiple RICEWQ simulations.

What is autoRICEWQ? This project aims to be a handler for input creation and running of multiple RICEWQ simulations. What is RICEWQ? From the descript

Yass Fuentes 1 Feb 01, 2022
MapReader: A computer vision pipeline for the semantic exploration of maps at scale

MapReader A computer vision pipeline for the semantic exploration of maps at scale MapReader is an end-to-end computer vision (CV) pipeline designed b

Living with Machines 25 Dec 26, 2022
Stochastic Scene-Aware Motion Prediction

Stochastic Scene-Aware Motion Prediction [Project Page] [Paper] Description This repository contains the training code for MotionNet and GoalNet of SA

Mohamed Hassan 31 Dec 09, 2022
BOVText: A Large-Scale, Multidimensional Multilingual Dataset for Video Text Spotting

BOVText: A Large-Scale, Bilingual Open World Dataset for Video Text Spotting Updated on December 10, 2021 (Release all dataset(2021 videos)) Updated o

weijiawu 47 Dec 26, 2022
Universal Adversarial Examples in Remote Sensing: Methodology and Benchmark

Universal Adversarial Examples in Remote Sensing: Methodology and Benchmark Yong

19 Dec 17, 2022
Instant neural graphics primitives: lightning fast NeRF and more

Instant Neural Graphics Primitives Ever wanted to train a NeRF model of a fox in under 5 seconds? Or fly around a scene captured from photos of a fact

NVIDIA Research Projects 10.6k Jan 01, 2023
We present a framework for training multi-modal deep learning models on unlabelled video data by forcing the network to learn invariances to transformations applied to both the audio and video streams.

Multi-Modal Self-Supervision using GDT and StiCa This is an official pytorch implementation of papers: Multi-modal Self-Supervision from Generalized D

Facebook Research 42 Dec 09, 2022
HW3 ― GAN, ACGAN and UDA

HW3 ― GAN, ACGAN and UDA In this assignment, you are given datasets of human face and digit images. You will need to implement the models of both GAN

grassking100 1 Dec 13, 2021