Skip to main content

A comprehensive OCR and computer vision model library with support for SVTRV2, YOLO, EfficientNet, PPLCNet, and more.

Project description

MemoLib

A computer vision model library built on PyTorch, providing a unified interface for object detection, image segmentation, image classification, text recognition, and anomaly detection.

Model Status

Category Model Status
Detection YOLOv5, YOLOv8, YOLO11, YOLO26 Stable
Detection RF-DETR Stable
Segmentation YOLO Segment (v8, 11, 26) Stable
Segmentation DINO UperNet Stable
Classification PPLCNet (x0.25 โ€“ x1.0) Stable
Classification YOLO Classification (v8, 11, 26) Stable
Classification EfficientNet (B0โ€“B7, V2S/M/L/XL) Stable
Recognition SVTR2 Stable
Anomaly Detection Dinomaly2 โš  Not fully tested
Anomaly Detection INP Former ๐Ÿ”ง Ongoing

Unified Interface

All models share a consistent API:

model.LoadWeight(path)        # Load pretrained or custom weights
model.Train(callbacks)        # Start training
model.Predict(image)          # Single inference
model.BatchPredict(images)    # Batch inference
model.Export(path, format)    # Export to ONNX / OpenVINO / TensorRT
model.StopTraining()          # Stop training gracefully

Installation

pip install memolib

Optional dependencies

# For YOLO models
pip install memolib[yolo]

# For PPLCNet models
pip install memolib[pplcnet]

# For development
pip install memolib[dev]

Quick Start

Object Detection โ€” YOLO

from MemoLib.Model.YOLO import Yolo
from MemoLib.Model.BaseModel.eDetectionModel import eYoloDetectionModel

model = Yolo()
model.cfg.Architecture = eYoloDetectionModel.Yolo11n
model.cfg.DatasetPath  = "path/to/dataset"
model.Train(callbacks=lambda level, msg: print(f"[{level}] {msg}"))

Classification โ€” PPLCNet

from MemoLib.Model.PPLCNet import PPLCNet
from MemoLib.Model.BaseModel.eClassificationModel import ePPLCNetModel

model = PPLCNet()
model.cfg.Architecture = ePPLCNetModel.PPLCNetx50
model.cfg.DatasetPath  = "path/to/dataset"
model.Train()

Model Export

from MemoLib.Model.BaseModel.eModelBase import eModelExportType

model.Export("weights/best.pt", eModelExportType.ONNX)
model.Export("weights/best.pt", eModelExportType.OpenVINO)
model.Export("weights/best.pt", eModelExportType.TensorRT)

Project Structure

MemoLib/
โ””โ”€โ”€ Model/
    โ”œโ”€โ”€ BaseModel/       # Abstract interface (IModel), enums, export types
    โ”œโ”€โ”€ YOLO/            # YOLO detection, segmentation, classification
    โ”œโ”€โ”€ RFDETR/          # RF-DETR detection    
    โ”œโ”€โ”€ DinoUperNet/     # DINO + UperNet semantic segmentation  
    โ”œโ”€โ”€ Efficientnet/    # EfficientNet classification 
    โ”œโ”€โ”€ PPLCNet/         # PPLCNet lightweight classification
    โ”œโ”€โ”€ SVTRV2/          # SVTR2 text recognition  
    โ””โ”€โ”€ Anomaly/         # Dinomaly2, INP Former  

Dataset Format

Classification โ€” YOLO / EfficientNet / PPLCNet

ImageFolder structure (same as torchvision ImageFolder):

dataset/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ cat/
โ”‚   โ”‚   โ”œโ”€โ”€ img001.jpg
โ”‚   โ”‚   โ””โ”€โ”€ img002.jpg
โ”‚   โ””โ”€โ”€ dog/
โ”‚       โ”œโ”€โ”€ img003.jpg
โ”‚       โ””โ”€โ”€ img004.jpg
โ””โ”€โ”€ val/
    โ”œโ”€โ”€ cat/
    โ””โ”€โ”€ dog/

Detection โ€” YOLO (detect / segment)

YOLO label format. data.yaml is auto-generated if missing.

dataset/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ”‚   โ”œโ”€โ”€ img001.jpg
โ”‚   โ””โ”€โ”€ labels/
โ”‚       โ”œโ”€โ”€ img001.txt        # <class> <x_c> <y_c> <w> <h>  (normalized 0-1)
โ”œโ”€โ”€ val/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ””โ”€โ”€ labels/
โ””โ”€โ”€ data.yaml

data.yaml:

path: /path/to/dataset
nc: 2
names: [cat, dog]
train: train/images
val:   val/images

For segmentation, the label format uses polygon points:

# <class> <x1> <y1> <x2> <y2> ... <xn> <yn>  (normalized 0-1)
0 0.1 0.2 0.3 0.4 0.5 0.6

Detection โ€” RF-DETR

Supports two formats. Auto-detected from directory structure.

COCO format (recommended โ€” exported directly from Roboflow/CVAT):

dataset/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ img001.jpg
โ”‚   โ””โ”€โ”€ _annotations.coco.json
โ””โ”€โ”€ val/
    โ”œโ”€โ”€ img002.jpg
    โ””โ”€โ”€ _annotations.coco.json

YOLO format (same structure as YOLO detection above):

dataset/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ””โ”€โ”€ labels/
โ”œโ”€โ”€ val/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ””โ”€โ”€ labels/
โ””โ”€โ”€ data.yaml

Semantic Segmentation โ€” DinoUperNet

Mask images must be single-channel PNG where each pixel value = class index.

dataset/
โ”œโ”€โ”€ train/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ”‚   โ”œโ”€โ”€ img001.jpg
โ”‚   โ””โ”€โ”€ masks/
โ”‚       โ”œโ”€โ”€ img001.png        # pixel value = class index (0, 1, 2, ...)
โ”œโ”€โ”€ val/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ””โ”€โ”€ masks/

ReduceZeroLabel: if True, pixel value 0 is treated as background/unlabeled (ignored in loss), and class indices shift by -1. Use this for datasets like ADE20K where class 0 = unlabeled.


Requirements

  • Python 3.9+
  • PyTorch 2.x (CUDA 12.x recommended)
  • See requirements.txt for full dependency list

License

MIT License

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

memolib-1.3.21.tar.gz (813.5 kB view details)

Uploaded Source

Built Distribution

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

memolib-1.3.21-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file memolib-1.3.21.tar.gz.

File metadata

  • Download URL: memolib-1.3.21.tar.gz
  • Upload date:
  • Size: 813.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for memolib-1.3.21.tar.gz
Algorithm Hash digest
SHA256 6a6c49b84f58bb00f6c5100836f977552d915b79cb09620c21f0c85554c6243c
MD5 e5a8dbb85d596f5cb65e9fcf90e8f0ab
BLAKE2b-256 80da86308247d60cc4af86e131efae5c792150b577341a56908b35569c0af560

See more details on using hashes here.

File details

Details for the file memolib-1.3.21-py3-none-any.whl.

File metadata

  • Download URL: memolib-1.3.21-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for memolib-1.3.21-py3-none-any.whl
Algorithm Hash digest
SHA256 10ed1193a46047db4be13dfe8e5eb3d2460963b8d4d4bfecb56fea68ee0d34a6
MD5 c82827c9e3da84313d1a2eb5cca2ad40
BLAKE2b-256 0c067da0095e08fb05a1c58498cad11499a0dfc325ffb284ecb1def573635321

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