A general, feasible, and extensible framework for classification tasks.

Overview

Pytorch Classification

  • A general, feasible and extensible framework for 2D image classification.

Features

  • Easy to configure (model, hyperparameters)
  • Training progress monitoring and visualization
  • Weighted sampling / weighted loss / kappa loss / focal loss for imbalance dataset
  • Kappa metric for evaluating model on imbalance dataset
  • Different learning rate schedulers and warmup support
  • Data augmentation
  • Multiple GPUs support

Installation

Recommended environment:

  • python 3.8+
  • pytorch 1.7.1+
  • torchvision 0.8.2+
  • tqdm
  • munch
  • packaging
  • tensorboard

To install the dependencies, run:

$ git clone https://github.com/YijinHuang/pytorch-classification.git
$ cd pytorch-classification
$ pip install -r requirements.txt

How to use

1. Use one of the following two methods to build your dataset:

  • Folder-form dataset:

Organize your images as follows:

├── your_data_dir
    ├── train
        ├── class1
            ├── image1.jpg
            ├── image2.jpg
            ├── ...
        ├── class2
            ├── image3.jpg
            ├── image4.jpg
            ├── ...
        ├── class3
        ├── ...
    ├── val
    ├── test

Here, val and test directory have the same structure of train. Then replace the value of 'data_path' in BASIC_CONFIG in configs/default.yaml with path to your_data_dir and keep 'data_index' as null.

  • Dict-form dataset:

Define a dict as follows:

your_data_dict = {
    'train': [
        ('path/to/image1', 0), # use int. to represent the class of images (start from 0)
        ('path/to/image2', 0),
        ('path/to/image3', 1),
        ('path/to/image4', 2),
        ...
    ],
    'test': [
        ('path/to/image5', 0),
        ...
    ],
    'val': [
        ('path/to/image6', 0),
        ...
    ]
}

Then use pickle to save it:

import pickle
pickle.dump(your_data_dict, open('path/to/pickle/file', 'wb'))

Finally, replace the value of 'data_index' in BASIC_CONFIG in configs/default.yaml with 'path/to/pickle/file' and set 'data_path' as null.

2. Update your training configurations and hyperparameters in configs/default.yaml.

3. Run to train:

$ CUDA_VISIBLE_DEVICES=x python main.py

Optional arguments:

-c yaml_file      Specify the config file (default: configs/default.yaml)
-o                Overwrite save_path and log_path without warning
-p                Print configs before training

4. Monitor your training progress in website 127.0.0.1:6006 by running:

$ tensorborad --logdir=/path/to/your/log --port=6006

Tips to use tensorboard on a remote server

You might also like...
Vector Neurons: A General Framework for SO(3)-Equivariant Networks
Vector Neurons: A General Framework for SO(3)-Equivariant Networks

Vector Neurons: A General Framework for SO(3)-Equivariant Networks Created by Congyue Deng, Or Litany, Yueqi Duan, Adrien Poulenard, Andrea Tagliasacc

General Virtual Sketching Framework for Vector Line Art (SIGGRAPH 2021)
General Virtual Sketching Framework for Vector Line Art (SIGGRAPH 2021)

General Virtual Sketching Framework for Vector Line Art - SIGGRAPH 2021 Paper | Project Page Outline Dependencies Testing with Trained Weights Trainin

sssegmentation is a general framework for our research on strongly supervised semantic segmentation.

sssegmentation is a general framework for our research on strongly supervised semantic segmentation.

ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representation from common sense knowledge graphs.
ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representation from common sense knowledge graphs.

ZSL-KG is a general-purpose zero-shot learning framework with a novel transformer graph convolutional network (TrGCN) to learn class representa

General purpose GPU compute framework for cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends)
General purpose GPU compute framework for cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends)

General purpose GPU compute framework for cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.

 (Py)TOD: Tensor-based Outlier Detection, A General GPU-Accelerated Framework
(Py)TOD: Tensor-based Outlier Detection, A General GPU-Accelerated Framework

(Py)TOD: Tensor-based Outlier Detection, A General GPU-Accelerated Framework Background: Outlier detection (OD) is a key data mining task for identify

g2o: A General Framework for Graph Optimization

g2o - General Graph Optimization Linux: Windows: g2o is an open-source C++ framework for optimizing graph-based nonlinear error functions. g2o has bee

A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

A general python framework for single object tracking in LiDAR point clouds, based on PyTorch Lightning.
A general python framework for single object tracking in LiDAR point clouds, based on PyTorch Lightning.

Open3DSOT A general python framework for single object tracking in LiDAR point clouds, based on PyTorch Lightning. The official code release of BAT an

Comments
  • 关于多卡训练无法复现的疑问

    关于多卡训练无法复现的疑问

    您好,我是北航的一名研究生,非常感谢您在eyepacs上的调参训练结果。

    根据您的环境要求,我配置了相同版本的环境。单卡训练时,我发现实验结果是可以复现的。但是我在多卡训练时遇到了一些问题,根据您的设置,random_seed=1,cudnn_deterministic=true,但是实验结果无法复现。可能我错误使用了您的代码,但我没能找到具体的原因,非常抱歉打扰您,能请您帮忙分析一下吗,十分感谢!

    祝您安好!

    opened by LPudding 4
  • 关于未能复现您Resnet50在Eyepacs上的结果的一些疑问。

    关于未能复现您Resnet50在Eyepacs上的结果的一些疑问。

    image

    您好,我是电子科大的一名研究生,最近也在做糖尿病视网膜病变分级的研究,很兴奋看到您在Resnet50上通过调参达到很好的效果,给后续研究者一个非常高的起点,非常感谢你。

    可是在复现您代码的时候遇到了一些问题,结果如上图,那是训练的过程图。 我按照您的数据预处理方法,运行crop.py对图像进行裁切。 配置也是按照您的eyepacs配置的,仅仅改了路径。 唯一的不同点在于我的验证集是从训练集里面划分的,我的训练集,验证集,测试集 分别是 28090 7027 53570,但这个应该不影响。

    疑问:为什么训练过程中的Accuracy会这么低呢? 验证集的kappa也并不高。 我自己使用普通Resnet50,训练集Acc大概90% ,验证集Acc大概84% , kappa能有77%左右。 可能是我使用对您的代码使用的不对,但是我没找到具体原因,所以冒昧打扰您,请您帮忙分析一下,非常感谢您啦。
    祝您安好!

    opened by zeng-su123 4
  • 关于您代码中优化器的一点小疑问。

    关于您代码中优化器的一点小疑问。

    您好! 又来向您请教问题了,最近又在您的代码上调参数,发现了一件很奇怪的现象。您默认使用的是SGD+nesterov方法,看您的代码也写了ADAM优化器,不知道为什么我把优化器换成ADAM之后,效果非常差,直接无法正常工作。 kappa指标一直为0,acc也保持不变,想来全预测为类别0了,如图所示,请问您碰到了这个情况吗?

    微信图片_20220613154349 祝您安好!

    opened by zeng-su123 2
  • Bump protobuf from 3.19.0 to 3.19.5

    Bump protobuf from 3.19.0 to 3.19.5

    Bumps protobuf from 3.19.0 to 3.19.5.

    Release notes

    Sourced from protobuf's releases.

    Protocol Buffers v3.19.5

    C++

    Protocol Buffers v3.19.4

    Python

    • Make libprotobuf symbols local on OSX to fix issue #9395 (#9435)

    Ruby

    • Fixed a data loss bug that could occur when the number of optional fields in a message is an exact multiple of 32. (#9440).

    PHP

    • Fixed a data loss bug that could occur when the number of optional fields in a message is an exact multiple of 32. (#9440).

    Protocol Buffers v3.19.3

    Python

    • Fix missing Windows wheel for Python 3.10 on PyPI

    Protocol Buffers v3.19.2

    Java

    Protocol Buffers v3.19.1

    Bazel

    • Ensure that release archives contain everything needed for Bazel (#9131)
    • Align dependency handling with Bazel best practices (#9165)

    JavaScript

    • Fix ReferenceError: window is not defined when getting the global object (#9156)

    Ruby

    • Fix memory leak in MessageClass.encode (#9150)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
Owner
Eugene
Eugene
General Multi-label Image Classification with Transformers

General Multi-label Image Classification with Transformers Jack Lanchantin, Tianlu Wang, Vicente Ordóñez Román, Yanjun Qi Conference on Computer Visio

QData 154 Dec 21, 2022
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 6.9k Jan 4, 2023
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 5.7k Feb 12, 2021
Implementation of Uniformer, a simple attention and 3d convolutional net that achieved SOTA in a number of video classification tasks

Uniformer - Pytorch Implementation of Uniformer, a simple attention and 3d convolutional net that achieved SOTA in a number of video classification ta

Phil Wang 90 Nov 24, 2022
This project uses ViT to perform image classification tasks on DATA set CIFAR10.

Vision-Transformer-Multiprocess-DistributedDataParallel-Apex Introduction This project uses ViT to perform image classification tasks on DATA set CIFA

Kaicheng Yang 3 Jun 3, 2022
Implementation of paper "DeepTag: A General Framework for Fiducial Marker Design and Detection"

Implementation of paper DeepTag: A General Framework for Fiducial Marker Design and Detection. Project page: https://herohuyongtao.github.io/research/

Yongtao Hu 46 Dec 12, 2022
Easy Parallel Library (EPL) is a general and efficient deep learning framework for distributed model training.

English | 简体中文 Easy Parallel Library Overview Easy Parallel Library (EPL) is a general and efficient library for distributed model training. Usability

Alibaba 185 Dec 21, 2022
Implement face detection, and age and gender classification, and emotion classification.

YOLO Keras Face Detection Implement Face detection, and Age and Gender Classification, and Emotion Classification. (image from wider face dataset) Ove

Chloe 10 Nov 14, 2022
(CVPR2021) ClassSR: A General Framework to Accelerate Super-Resolution Networks by Data Characteristic

ClassSR (CVPR2021) ClassSR: A General Framework to Accelerate Super-Resolution Networks by Data Characteristic Paper Authors: Xiangtao Kong, Hengyuan

Xiangtao Kong 308 Jan 5, 2023