How niraj1742/anubhavai works
Main Architectural Layers
• Presentation Layer (Frontend)
• Streamlit Web UI (main.py)
• Browser client
• Application/Orchestration Layer (Controller)
• main.py + utils.py
• Receives image uploads, calls each analysis module, aggregates results
• Processing Modules (Backend Services)
1. Face Detection Engine (OpenCV + Haar Cascades)
2. Emotion Recognition Engine (PyTorch ResNet50 / DeepFace)
3. Background Removal Engine (U-2-Net model)
4. Scene Classification Engine (Places365 models)
• Data & Model Artifacts
• models/U-2-Net (weights, code, test data)
• models/places365 (prototxt, weights, Docker support)
• Saved Haar cascade XML under models/U-2-Net/saved_models
• Output
• JSON analysis report
Relationships and Data Flow
• User uploads an image via the Streamlit UI
• Streamlit Server (main.py) passes the image to the Controller (utils.py)
• Controller invokes each module in sequence or parallel:
b. Emotion Recognition (on each crop) → emotion labels + confidence
c. Background Removal → segmentation mask + transparent PNG
d. Scene Classification → scene category + confidence
• Controller collects module outputs into a unified JSON object
• Streamlit renders results: annotated image, masks, bar charts, report
Architectural Patterns & Design Principles
• Modular Pipeline: Each analysis task is encapsulated in its own Python module, making it easy to replace or extend
• Separation of Concerns: UI (Streamlit), orchestration (utils/main), and computation (models/) are clearly divided
• Plug-and-Play Models: weights and inference code live under models/, enabling model upgrades without touching orchestration
• Synchronous vs. Asynchronous: Although currently sequential, you could parallelize module calls if needed
Technologies & Frameworks
• Frontend: Python Streamlit
• Face Detection: OpenCV (cv2), Haar Cascades
• Emotion Recognition: PyTorch, TorchVision, DeepFace
• Background Removal: rembg wrapper around U-2-Net
• Scene Classification: Places365 models (Caffe prototxt, PyTorch conversion)
• Core Language: Python 3.x
• Extras: NumPy, Pillow, scikit-learn, TensorFlow (DeepFace), Docker (only for Places365 demos)