How ahmed23adel/cv_scene_recognition works
Project Type and Purpose
• This is a research‐style, command‐line Python application for computer‐vision‐based scene recognition.
• It implements two feature‐extraction methods (Tiny Image, Bag of Words with HOG + K-means) and two classifiers (Nearest Neighbor, linear SVM).
• It ingests a labeled dataset (data/train & data/test), runs a complete pipeline (feature extraction → classification → evaluation), and emits a static HTML results page.
File Structure Analysis
• Top‐level directories:
• code/ – orchestrators and modules:
◦ main.py: CLI entrypoint and overall pipeline controller
◦ helpers.py: I/O utilities (image loading, normalization, HOG computation)
◦ student.py: user‐implementable feature‐extraction and classification routines
◦ create_results_webpage.py: HTML generator for visualizing results
• data/ – structured dataset: per‐class subdirs under train/ and test/
• results_webpage/ – static output (index.html + thumbnails)
• requirements.txt, virtual environment (venv2/)
• No frontend/backend separation: it’s a single‐process batch pipeline.
• Key config/build files: requirements.txt for dependencies (numpy, scikit‐learn, scikit‐image).
README Insights
• Clearly lists three feature extractors and two classifiers.
• Describes a three‐step process: feature extraction → classification → evaluation (confusion matrix + HTML page).
• Illustrates usage via command‐line flags.
1. Dataset Storage
– “data/train” and “data/test” directories
2. Feature Extraction Module
– Tiny Image submodule
– Bag of Words submodule (HOG descriptor + K-means vocabulary builder)
3. Model Training Module
– Nearest Neighbor Trainer
– SVM Trainer (one-vs-all linear SVM)
4. Classification Module
– Applies chosen classifier to test features
5. Evaluation Module
– Confusion matrix builder
6. Results Webpage Generator
– HTML creation (create_results_webpage.py) → outputs results_webpage/index.html
7. Orchestrator (main.py)
– Parses CLI flags, calls student.py implementations and helpers.py utilities
– Dataset → Feature Extraction → Feature Vectors
– Feature Vectors → Model Training → Trained Models
– Test Feature Vectors + Trained Models → Classification → Predictions
– Predictions + Ground Truth → Evaluation → Confusion Matrix
– Confusion Matrix + Thumbnails → Webpage Generator → Static HTML
c. Architectural Patterns & Principles
– Pipeline pattern: sequential processing stages
– Modular separation: extraction, training, classification, evaluation, reporting
– Single‐process, procedural design with clearly decoupled modules
d. Key Technologies & Libraries
– Python 3.x
– NumPy for array ops
– scikit‐image or OpenCV for image I/O & HOG
– scikit‐learn for K-means, SVM, Nearest Neighbors
– Matplotlib or HTML templates for visualization