Spaces:
Sleeping
Sleeping
Alex Hortua
commited on
Commit
Β·
a39b066
1
Parent(s):
ebf4f46
We dont need to add models
Browse files- .gitignore +2 -1
- 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 |
+

|
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!**
|