How xuanhuy10/dacn3 works
Project Type & Purpose
• This is a compact, Python-based computer‐vision classification tool for Vietnamese banknotes. It uses a small CNN model converted to ONNX and OpenCV DNN for inference. The codebase provides:
• A local CLI/classification entry point (main.py)
• An inference server (ocr_server.py)
• A Raspberry Pi client (raspberrypi_client.py)
• Utilities for preprocessing & model loading (utils.py)
• A test harness (ocr_test.py)
High-Level Architecture & Components
a. Model Storage
– classifier.onnx: pre-trained ONNX model file
b. Inference Engine & Library Layer
– utils.py: loads the ONNX model via OpenCV DNN, applies image preprocessing, postprocesses predictions
c. Server Layer
– ocr_server.py: exposes an HTTP (or lightweight RPC) endpoint; accepts image payloads, invokes utils → returns classification results
d. Client Layer
– raspberrypi_client.py: captures images on the Pi (via camera or file), sends requests to the OCR server, displays or logs results
e. Local CLI
– main.py: stand-alone script to classify images locally without network, invoking the same utils module
f. Test Layer
– ocr_test.py: validates end-to-end functionality of server + client + utils
Relationships & Data Flow
1. (Optional) Training Notebook → classifier.onnx (outside production scope)
2. Client (Raspberry Pi) or CLI → sends image data → OCR Server
3. OCR Server → calls utils.load_model() → utils.preprocess(image) → utils.infer() → utils.postprocess()
4. OCR Server → returns label/confidence → Client or CLI displays result
Architectural Patterns & Principles
• Modular Separation: inference logic (utils) is decoupled from transport (server vs CLI)
• Service-Oriented: OCR server acts as a microservice
• Single Responsibility: each script has a clear, narrow focus
• Model Abstraction: using ONNX for portability across platforms (desktop, Raspberry Pi)