Skip to main content

A MobileNetV3-based classifier

Project description

jxb_mobilenetv3

基于 MobileNetV3-Small 的轻量级图像分类网络,支持快速训练、预测与结果可视化,适用于嵌入式或实时场景。


✨ 特性

  • ✅ 基于 MobileNetV3 Small 版本作为主干网络(backbone)
  • ✅ 支持一键训练,支持断点续训
  • ✅ 便捷的预测接口,支持批量推理与投票机制
  • ✅ 可生成训练过程的可视化图(准确率/损失等)
  • ✅ 支持使用预训练模型进行微调

🛠️ 安装方式

打包后使用 pip 安装:

pip install jxb_mobilenetv3-0.1.0-py3-none-any.whl

或在开发目录下安装:

pip install -e .

🚀 使用方法

导入模块

from jxb_mobilenetv3 import MobileNetV3Train, MobileNetV3Predictor

🔧 开始训练

MobileNetV3Train 是一个函数,传入参数后可立即开始训练。

MobileNetV3Train(
    data_root='data/',       # 数据集根目录
    epochs=50,               # 训练轮数
    batch_size=32,           # 每批大小
    lr=0.001,                # 学习率(可选)
    img_size=224             # 模型输入尺寸
)

训练结束后会自动保存模型权重,并生成训练过程的可视化图像(如 loss/accuracy 曲线)。


🔍 模型预测

MobileNetV3Predictor 是一个类,初始化后即可使用 predictvote_predict 进行推理。

# 加载训练好的模型
predictor = MobileNetV3Predictor('checkpoints/best.pt')  

# 批量预测:输入图片列表
result_matrix, id_to_class = predictor.predict(image_list)

# 其中 result_matrix 是二维数组,每行为 [class_id, confidence]
# id_to_class 是 {类别id: 类别名} 的映射字典

✅ 投票预测(适用于滑动缓存或多帧)

# 返回单个预测结果(基于投票机制)
result = predictor.vote_predict(image_list)

📦 目录结构示例

jxb_mobilenetv3/              # 顶级包名(建议作为顶层包名)
├── config/                   # 子包
├── __init__.py               # 顶级包的初始化文件,标识为包
├── src/                      # 源码子包
│   ├── __init__.py
│   ├── dataset.py
│   ├── mobilenet_v3.py
│   ├── predict.py
│   └── train.py
├── utils/                    # 工具子包
│   ├── __init__.py
│   └── utils.py

📘 依赖

  • numpy==1.23.5,
  • torch==2.1.0,
  • torchvision==0.16.0,
  • pyyaml==6.0,
  • pillow==10.4.0,
  • tqdm==4.66.5,
  • opencv-python==4.10.0.84,
  • seaborn==0.13.2,
  • matplotlib==3.7.5,
  • scikit-learn==1.3.2

🔖 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jxb-mobilenetv3-1.0.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jxb_mobilenetv3-1.0.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file jxb-mobilenetv3-1.0.0.tar.gz.

File metadata

  • Download URL: jxb-mobilenetv3-1.0.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for jxb-mobilenetv3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2c9712a9ca035df3042642b5d335991082f06fbec092ae223792c0ad1cd5a295
MD5 c67e7aaab98920c647e4d085efae359e
BLAKE2b-256 3676c1434221683c47d537dbaa251c725148b1f3656443f26d56ae26fa444f11

See more details on using hashes here.

File details

Details for the file jxb_mobilenetv3-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jxb_mobilenetv3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e3474121ed64116f78d162e8555fec94a4e879d11c77d23f2dc70d749cccd6
MD5 1f3dfd08640d5f949c0ae8af538e542a
BLAKE2b-256 206284dcbb1d54f7131967ffd6bf927f7bd61f38f22c25b2b6fc8df369f26bce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page