Rename Readme.md to README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π **DETR + Keypoint Estimation (COCO Subset)**
|
| 2 |
+
Author: [@Koushik](https://huggingface.co/Koushim)
|
| 3 |
+
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
### π§ Model Overview
|
| 7 |
+
|
| 8 |
+
This project combines:
|
| 9 |
+
|
| 10 |
+
* π€ [facebook/detr-resnet-50](https://huggingface.co/facebook/detr-resnet-50) (object detector)
|
| 11 |
+
* π§± Custom PyTorch keypoint head
|
| 12 |
+
* π Trained on 500-person subset of [COCO 2017 Keypoints](https://cocodataset.org/#keypoints-2020)
|
| 13 |
+
|
| 14 |
+
The system detects people using DETR, then predicts 17 COCO-style keypoints (top-down) using heatmap regression.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
### π Files Included
|
| 19 |
+
|
| 20 |
+
| File | Description |
|
| 21 |
+
| ------------------------------- | ------------------------------------------ |
|
| 22 |
+
| `pytorch_model.bin` | Trained PyTorch model weights |
|
| 23 |
+
| `05_detr_pose_coco_colab.ipynb` | Full Colab notebook (training + inference) |
|
| 24 |
+
| `config.json` | Basic model metadata |
|
| 25 |
+
| `README.md` | Project description |
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
### π Dataset
|
| 30 |
+
|
| 31 |
+
* **Subset**: 500 images from COCO val2017 with visible persons
|
| 32 |
+
* **Annotations**: 17 keypoints per person
|
| 33 |
+
* **Source**: [COCO Keypoints](https://cocodataset.org/#keypoints-2020)
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
### ποΈ Architecture
|
| 38 |
+
|
| 39 |
+
```text
|
| 40 |
+
[ Input Image ]
|
| 41 |
+
β
|
| 42 |
+
βΌ
|
| 43 |
+
[ DETR (Person BBox) ]
|
| 44 |
+
β
|
| 45 |
+
βΌ
|
| 46 |
+
[ Crop + Resize (256Γ256) ]
|
| 47 |
+
β
|
| 48 |
+
βΌ
|
| 49 |
+
[ CNN Keypoint Head ]
|
| 50 |
+
β
|
| 51 |
+
βΌ
|
| 52 |
+
[ 17 Heatmaps (Keypoints) ]
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
### π Quick Start
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import torch
|
| 61 |
+
from model import KeypointHead
|
| 62 |
+
|
| 63 |
+
model = KeypointHead()
|
| 64 |
+
model.load_state_dict(torch.load('pytorch_model.bin'))
|
| 65 |
+
model.eval()
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
---
|
| 69 |
+
|
| 70 |
+
### π§ͺ Inference Demo
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
from PIL import Image
|
| 74 |
+
import cv2, numpy as np
|
| 75 |
+
from transformers import DetrImageProcessor, DetrForObjectDetection
|
| 76 |
+
|
| 77 |
+
img = Image.open('sample.jpg')
|
| 78 |
+
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 79 |
+
detector = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
|
| 80 |
+
|
| 81 |
+
inputs = processor(images=img, return_tensors="pt")
|
| 82 |
+
outputs = detector(**inputs)
|
| 83 |
+
results = processor.post_process_object_detection(outputs, target_sizes=[img.size[::-1]], threshold=0.8)[0]
|
| 84 |
+
|
| 85 |
+
# Use results['boxes'][0] to crop person
|
| 86 |
+
# Feed crop into model(img) to get 17 heatmaps
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
### π§ Training (optional)
|
| 92 |
+
|
| 93 |
+
To fine-tune on your own dataset:
|
| 94 |
+
|
| 95 |
+
* Convert your data to COCO format
|
| 96 |
+
* Use the notebook provided (`05_detr_pose_coco_colab.ipynb`)
|
| 97 |
+
* Change paths and re-train
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
### β¨ Credit
|
| 102 |
+
|
| 103 |
+
* [Hugging Face Transformers](https://github.com/huggingface/transformers)
|
| 104 |
+
* [COCO Dataset](https://cocodataset.org/)
|
| 105 |
+
* [facebook/detr](https://huggingface.co/facebook/detr-resnet-50)
|
| 106 |
+
|
Readme.md
DELETED
|
File without changes
|