Zurück zum Ranking

lxztju/pytorch_classification

Jupyter Notebook

利用pytorch实现图像分类的一个完整的代码,训练,预测,TTA,模型融合,模型部署,cnn提取特征,svm或者随机森林等进行分类,模型蒸馏,一个完整的代码

pytorchimage-classificationdeploymentsvmknncnnlabel-smoothingdensenetresnextresnetflaskrandom-forest
Sterne-Wachstum
Sterne
1.5k
Forks
343
Wochenwachstum
Issues
40
5001k
Apr. 2020Mai 2022Juni 2024Juli 2026
README

简介

基于torchision实现的pytorch图像分类功能。

近期更新

  • 2022.11.05更新

    • 新添加tensorrt c++的推理方案
  • 2022.10.29更新,进行代码重构,基本的功能基本一致。

    • 支持pytorch ddp的训练
    • 支持c++ libtorch的模型推理
    • 支持script脚本一键运行
    • 添加日志模块

习惯之前版本的请看v1版本的代码:V1版本

主要功能:

利用pytorch实现图像分类,基于torchision可以扩展使用densenet,resnext,mobilenet,efficientnet,swin transformer等图像分类网络

如果有用欢迎star

实现功能

  • 基础功能利用pytorch实现图像分类
  • 包含带有warmup的cosine学习率调整
  • warmup的step学习率优调整
  • 多模型融合预测,加权与投票融合
  • 利用flask + redis实现模型云端api部署(tag v1)
  • c++ libtorch的模型部署
  • 使用tta测试时增强进行预测(tag v1)
  • 添加label smooth的pytorch实现(标签平滑)(tag v1)
  • 添加使用cnn提取特征,并使用SVM,RF,MLP,KNN等分类器进行分类(tag v1)。
  • 可视化特征层

运行环境

  • python3.7
  • pytorch 1.8.1
  • torchvision 0.9.1
  • opencv(libtorch cpp推理使用, 版本3.4.6)(可选)
  • libtorch cpp推理使用(可选)

快速开始

数据集形式

数据集的组织形式,参考sample_files/imgs/listfile.txt

训练 测试

修改run.sh中的参数,直接运行run.sh即可运行

主要修改的参数:

OUTPUT_PATH 模型保存和log文件的路径

TRAIN_LIST 训练数据集的list文件
VAL_LIST  测试集合的list文件
model_name 默认是resnet50
lr 学习率
epochs 训练总的epoch
batch-size  batch的大小
j dataloader的num_workers的大小
num_classes 类别数

libtorch inference

代码存储在cpp_inference文件夹中。

  1. 利用cpp_inference/traced_model/trace_model.py将训练好的模型导出。

  2. 编译所需的opencv和libtorch代码到cpp_inference/third_party_library

  3. 编译

sh compile.sh
  1. 可执行文件测试
./bin/imgCls imgpath
Ähnliche Repositories
AUTOMATIC1111/stable-diffusion-webui

Stable Diffusion web UI

PythonPyPIGNU Affero General Public License v3.0deep-learningdiffusion
164.3k30.4k
huggingface/transformers

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

PythonPyPIApache License 2.0nlpnatural-language-processing
huggingface.co/transformers
162.8k34k
Comfy-Org/ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.

PythonPyPIGNU General Public License v3.0stable-diffusionpytorch
comfy.org
121.7k14.3k
rasbt/LLMs-from-scratch

Implement a ChatGPT-like LLM in PyTorch from scratch, step by step

Jupyter NotebookOthergptlarge-language-models
amzn.to/4fqvn0D
99.5k15.3k
vllm-project/vllm

A high-throughput and memory-efficient inference and serving engine for LLMs

PythonPyPIApache License 2.0gptllm
vllm.ai
86.8k19.7k
comfyanonymous/ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.

PythonPyPIGNU General Public License v3.0stable-diffusionpytorch
comfy.org
70.2k7.6k
labmlai/annotated_deep_learning_paper_implementations

🧑‍🏫 60+ Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, sophia, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠

PythonPyPIMIT Licensedeep-learningdeep-learning-tutorial
nn.labml.ai
67.2k6.7k
keras-team/keras

Deep Learning for humans

PythonPyPIApache License 2.0deep-learningtensorflow
keras.io
64.2k19.7k
CorentinJ/Real-Time-Voice-Cloning

Clone a voice in 5 seconds to generate arbitrary speech in real-time

PythonPyPIOtherdeep-learningpytorch
60k9.4k
ultralytics/ultralytics

Ultralytics YOLO26, YOLO11, YOLOv8 — object detection, instance segmentation, semantic segmentation, image classification, pose estimation, object tracking

PythonPyPIGNU Affero General Public License v3.0ultralyticsyolov8
platform.ultralytics.com
59.7k11.4k
ultralytics/yolov5

Ultralytics YOLOv5 in PyTorch for object detection, instance segmentation, classification, training, and export.

PythonPyPIGNU Affero General Public License v3.0yolov5object-detection
docs.ultralytics.com/yolov5/
57.7k17.5k
GokuMohandas/Made-With-ML

Learn how to develop, deploy and iterate on production-grade ML applications.

Jupyter NotebookMIT Licensemachine-learningdeep-learning
madewithml.com
48.8k7.7k