How pranaypr9/sih-cattle-breed-recognition works
Pashu Pehchaan is a web application for recognizing Indian cattle and buffalo breeds from uploaded images. A user selects a photo, the React app sends it to Flask, and the backend validates and stores a copy, runs breed inference, records the top predictions in PostgreSQL, and returns results for display. The backend also exposes health, breed-list, and prediction-history endpoints. A separate training workflow fine-tunes the classifier and produces weights and class labels. The graph follows shown calls and documented capabilities; some API endpoints have no sampled frontend consumer.
Main entry points: app.py Flask routes · App.jsx App workflow · db_models.py Breed and prediction records · model.py ResNet50 model
Components 15
Web interface
- App workflow
frontend/src/App.jsx - Image upload
frontend/src/components/ImageUpload.jsx - Result display
frontend/src/components/PredictionResult.jsx - Status header
frontend/src/components/Header.jsx - API client
frontend/src/api/api.js
Recognition API
- Flask routes
backend/app.py - Runtime config
backend/config.py
Breed classifier
- ResNet50 model
backend/ml/model.py - Image inference
backend/ml/predict.py - Breed labels
backend/ml/class_labels.json - Model training
backend/ml/train.py
Prediction data
- Uploaded images
backend/uploads - Breed and prediction records
backend/models/db_models.py
Other components
- Field user
- PostgreSQL
Connections 21
- Field user → Image upload: selects image
frontend/src/components/ImageUpload.jsx - Image upload → App workflow: sends selection
frontend/src/App.jsx - App workflow → API client: requests prediction
frontend/src/App.jsx - App workflow → API client: checks health
frontend/src/App.jsx - API client → Flask routes: posts image
frontend/src/api/api.js - Flask routes → App workflow: returns prediction
backend/app.py - App workflow → Result display: renders result
frontend/src/App.jsx - App workflow → Status header: renders status
frontend/src/App.jsx - Flask routes → Runtime config: loads settings
backend/app.py - Flask routes → ResNet50 model: loads model
backend/app.py - Flask routes → Breed labels: loads class labels
backend/app.py - Flask routes → Image inference: runs inference
backend/app.py - Image inference → ResNet50 model: executes model
backend/ml/predict.py - Flask routes → Uploaded images: saves image
backend/app.py - Flask routes → Breed and prediction records: records and queries
backend/app.py - Breed and prediction records → PostgreSQL: persists records
README.md - Model training → ResNet50 model: builds model
backend/ml/train.py - Model training → Breed labels: writes labels
backend/ml/train.py - Model training → ResNet50 model: saves weights
README.md - Flask routes → Breed and prediction records: lists breeds
backend/app.py - Flask routes → Breed and prediction records: lists history
backend/app.py