Metadata-Version: 2.4
Name: memolib
Version: 1.1.19
Summary: A comprehensive OCR and computer vision model library with support for SVTRV2, YOLO, EfficientNet, PPLCNet, and more.
Author-email: MemoLib Team <nghiakthp2401@gmail.com>
License-Expression: MIT
Keywords: ocr,computer-vision,deep-learning,yolo,svtr,recognition,detection,segmentation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: torch>=2.8.0
Requires-Dist: torchvision>=0.23.0
Requires-Dist: numpy>=2.4.0
Requires-Dist: opencv-python>=4.13.0
Requires-Dist: pillow>=12.2.0
Requires-Dist: matplotlib>=3.10.0
Requires-Dist: scipy>=1.17.1
Requires-Dist: scikit-learn>=1.8.0
Requires-Dist: albumentations>=2.0.0
Requires-Dist: lmdb>=2.2.0
Requires-Dist: polars>=1.40.1
Requires-Dist: onnx>=1.21.0
Requires-Dist: onnxruntime-gpu>=1.26.0
Requires-Dist: onnxslim>=0.1.93
Requires-Dist: openvino>=2026.1.0
Requires-Dist: tensorrt>=10.14.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: tqdm>=4.67.0
Requires-Dist: rfdetr>=1.6.5
Requires-Dist: pytorch-lightning>=2.6.4
Requires-Dist: torchmetrics>=1.9.0
Requires-Dist: accelerate>=1.13.0
Requires-Dist: transformers>=5.9.0
Requires-Dist: safetensors>=0.7.0
Requires-Dist: peft>=0.19.1
Requires-Dist: huggingface_hub>=1.15.0
Requires-Dist: supervision>=0.27.0
Requires-Dist: pycocotools>=2.0.11
Provides-Extra: yolo
Requires-Dist: ultralytics>=8.4.0; extra == "yolo"
Provides-Extra: pplcnet
Requires-Dist: pplcnet>=1.0.0; extra == "pplcnet"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# 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 | ⚠ Not fully tested |
| Segmentation | YOLO Segment (v8, 11, 26) | Stable |
| Segmentation | DINO UperNet | ⚠ Not fully tested |
| Classification | PPLCNet (x0.25 – x1.0) | Stable |
| Classification | YOLO Classification (v8, 11, 26) | Stable |
| Classification | EfficientNet (B0–B7, V2S/M/L/XL) | ⚠ Not fully tested |
| Recognition | SVTR2 | 🔧 Ongoing |
| Anomaly Detection | Dinomaly2 | 🔧 Ongoing |
| Anomaly Detection | INP Former | 🔧 Ongoing |

## Unified Interface

All models share a consistent API:

```python
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

```bash
pip install memolib
```

### Optional dependencies

```bash
# 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

```python
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

```python
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

```python
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  [not fully tested]
    ├── DinoUperNet/     # DINO + UperNet semantic segmentation  [not fully tested]
    ├── Efficientnet/    # EfficientNet classification  [not fully tested]
    ├── PPLCNet/         # PPLCNet lightweight classification
    ├── SVTRV2/          # SVTR2 text recognition  [ongoing]
    └── Anomaly/         # Dinomaly2, INP Former  [ongoing]
```

## Requirements

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

## License

MIT License
