Alex Hortua commited on
Commit
a39b066
Β·
1 Parent(s): ebf4f46

We dont need to add models

Browse files
Files changed (2) hide show
  1. .gitignore +2 -1
  2. README.md +115 -0
.gitignore CHANGED
@@ -4,4 +4,5 @@
4
  venv/
5
  /datasets/annotations/*
6
  /datasets/images/*
7
- src/__pycache__/
 
 
4
  venv/
5
  /datasets/annotations/*
6
  /datasets/images/*
7
+ src/__pycache__/
8
+ models/lego
README.md CHANGED
@@ -11,3 +11,118 @@ short_description: Using RCNN and Fully connected to detect Planes in objects
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+
16
+
17
+
18
+ # LEGO Object Detection using Faster R-CNN
19
+
20
+ ![Faster R-CNN](https://upload.wikimedia.org/wikipedia/commons/4/4b/Faster_R-CNN.png)
21
+
22
+ This project trains a **Faster R-CNN** model with a **ResNet-50 backbone** to detect LEGO objects using a custom dataset.
23
+
24
+ ---
25
+
26
+ ## **Project Structure**
27
+ ```yaml
28
+ lego_detection/
29
+ │── models/ # Trained models
30
+ β”‚ β”œβ”€β”€ lego_fasterrcnn.pth # Saved model
31
+ β”‚
32
+ │── datasets/ # Dataset folder
33
+ β”‚ β”œβ”€β”€ images/ # Training images
34
+ β”‚ β”œβ”€β”€ annotations/ # Corresponding XML annotations
35
+ β”‚
36
+ │── src/ # Source code
37
+ β”‚ β”œβ”€β”€ dataset.py # Dataset class (LegoDataset)
38
+ β”‚ β”œβ”€β”€ train.py # Training script
39
+ β”‚ β”œβ”€β”€ evaluate.py # mAP Calculation
40
+ β”‚ β”œβ”€β”€ utils.py # IoU, AP calculation functions
41
+ β”‚
42
+ │── config.yaml # Hyperparameters & settings
43
+ │── README.md # Project documentation
44
+ ```
45
+
46
+ ---
47
+
48
+ ## ⚑ **Setup Instructions**
49
+ ### **1️⃣ Install Dependencies**
50
+ ```bash
51
+ pip install -r requirements.txt
52
+ ```
53
+
54
+ ### **2️⃣ Update Configuration**
55
+ Modify **`config.yaml`** to adjust **hyperparameters, dataset paths, and model settings**.
56
+
57
+ ---
58
+
59
+ ## πŸš€ **Training the Model**
60
+ Run the following command to start training:
61
+ ```bash
62
+ python src/train.py
63
+ ```
64
+ This script will:
65
+ βœ… Train Faster R-CNN with **LegoDataset**
66
+ βœ… Log training **loss & mAP**
67
+ βœ… Save the trained model in `models/lego_fasterrcnn.pth`
68
+
69
+ ---
70
+
71
+ ## πŸ“Š **Monitoring Training Progress**
72
+ Use the Jupyter Notebook to **visualize loss & mAP over epochs**:
73
+ ```bash
74
+ jupyter notebook notebooks/training_visualization.ipynb
75
+ ```
76
+
77
+ ---
78
+
79
+ ## πŸ› οΈ **Hyperparameters (`config.yaml`)**
80
+ Modify the **`config.yaml`** file to fine-tune the model:
81
+ ```yaml
82
+ model:
83
+ backbone: resnet50
84
+ num_classes: 2
85
+ pretrained: true
86
+ learning_rate: 0.0001
87
+ epochs: 5
88
+ batch_size: 8
89
+ optimizer: adam
90
+
91
+ dataset:
92
+ image_dir: datasets/images
93
+ annotation_dir: datasets/annotations
94
+ train_split: 0.8
95
+ val_split: 0.2
96
+
97
+ evaluation:
98
+ iou_threshold: 0.5
99
+ ```
100
+
101
+ ---
102
+
103
+ ## πŸ“‘ **Evaluating the Model**
104
+ Once training is complete, evaluate performance using:
105
+ ```bash
106
+ python src/evaluate.py
107
+ ```
108
+
109
+ ---
110
+
111
+ ## πŸ’‘ **Troubleshooting & Tips**
112
+ ### ❓ **Training Takes Too Long?**
113
+ - Reduce `epochs` in `config.yaml`
114
+ - Use a **smaller dataset** for testing
115
+
116
+ ### ❓ **mAP is too low?**
117
+ - Increase `epochs`
118
+ - Check dataset annotations
119
+ - Tune learning rate
120
+
121
+ ---
122
+
123
+ ## πŸ† **Contributors**
124
+ - πŸ‘€ **Alex** - Machine Learning Engineer
125
+
126
+ πŸ“§ **Contact**: [Your Email]
127
+
128
+ πŸš€ **Happy Training!**