How luler/image_classification works
Project Type and Purpose
• This is a full-stack image-classification web application.
• Purpose: let users create/manage categories and images, then run live image-recognition via Baidu’s PaddlePaddle “PP-Shitu” models.
File-Structure Analysis
• Top-level:
• config/nginx – Nginx reverse-proxy & static-file serving
• api/ + app.py + route.py – Flask application, defines REST endpoints (login, label, image, common)
• deploy/ – ML-inference component (model files, preprocess/postprocess, predictor wrappers)
• migrations/ + orator_database.py – relational DB schema and Orator ORM setup
• static/ – stored galleries & uploaded images
• tool/ – shared utilities (JWT, validation, logging)
• web/ – Ant Design Pro v5 React frontend (source in web/src, build output in web/dist)
• docker-compose.yml & Dockerfile – container definitions
README Insights
• Backend: Flask; Frontend: Ant Design Pro; ML: PP-Shitu
• Key features: category (label) management, category-image management, “recognition experience” UI
• Deploy via Docker Compose, Nginx serves at port 5566
a. Main Components
1. User’s Browser / Client (React SPA)
2. Nginx Reverse Proxy & Static Server
3. Frontend (Ant Design Pro React app)
4. Flask Backend
– Authentication (JWT via tool/jwt_tool.py)
– Label, Image, Login, Common APIs
– ORM (Orator → Relational DB)
– File storage (static/predict_images, static/gallery)
5. ML Inference Engine (“deploy” microservice or module)
– Preprocess, Predictor, Postprocess (deploy/python & deploy/utils)
– PaddlePaddle models (deploy/models/**/*.pdmodel, .pdiparams, configs)
6. Relational Database (MySQL/Postgres via Orator)
7. Optional: Logging subsystem
b. Relationships & Data Flows
• Browser → (HTTP/HTTPS) → Nginx
• Nginx → serves static files (React bundle) and proxies /api/* → Flask
• Flask → reads/writes metadata to DB
• Flask → saves/uploads raw images to disk storage
• Flask → invokes Inference Engine (in-process import or separate service) for classification
• Inference Engine → loads PaddlePaddle models from disk → returns predictions
• Flask → returns JSON results → Browser
c. Architectural Patterns & Principles
• MVC-style separation: React UI (View) ↔ Flask (Controller + Model)
• Modular services: distinct API modules, deploy/python for ML logic
• Containerized microservice approach: Nginx + Flask + Inference + DB
• Configuration-as-code: Docker Compose, Nginx conf.d, Orator config
d. Key Technologies & Frameworks
• Frontend: React, Ant Design Pro, UmiJS, Webpack
• Backend: Flask, Orator ORM, PyJWT, Orator migrations
• Inference: PaddlePaddle (PP-Shitu), custom preprocess/postprocess scripts
• Infrastructure: Docker, Docker Compose, Nginx