ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.87k stars 16.38k forks source link

YOLOv5m/l-seg, which layer(s) should I take for feature extraction (object tracking) ? #10598

Closed danwanban closed 1 year ago

danwanban commented 1 year ago

Search before asking

Question

Hi,

I am using Yolov5m-seg/Yolov5l-seg (later on converted to tensorrt on Jetson using tensorrtx repo).

I would like to take the output of a layer(s) as feature map per object, to be used as the input for a tracking module.

Which layer(s) should I use ? (preferably smallest in size and latest as possible in the flow) ?

Thanks for the help ! your work is awesome, really appreciate this repo.

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @danwanban, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

AyushExel commented 1 year ago

@mikel-brostrom is the expert here if you're looking for advice on tracking research. But if you just want to use an existing tracker, you can use this repo which is actively maintained by Mike https://github.com/mikel-brostrom/Yolov5_StrongSORT_OSNet

mikel-brostrom commented 1 year ago

Glad to help here @AyushExel. I would not recommend to use Yolov5 features for tracking. This is because the way in which Yolov5 is trained is not meant to learn detailed discriminative features.

An example: the shoe region of a detected person could give away that the person to its right isn't the same person in the case that one of the would be wearing sandals and the other one sneakers. The current loss functions is not meant to separate these instances in embedding space as much as possible. This is the basis for successful object re-identification, specially if you rely mostly on appearance descriptors and less on motion information.

If you still want to use Yolov5 features I would extract features from the deepest C3 module (20 x 20 x 1024) as this combines scaled high level features with low level features. You could also train a Yolov5 architecture with triplet loss instead of the current compound loss for the specific task of ReID.

rukshankr commented 1 year ago

@mikel-brostrom @AyushExel where can I find resources on how to extract features from YOLOv5? Newbie here, and I couldn't find a guide for that anywhere. Appreciate it if you could help

github-actions[bot] commented 1 year ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

danwanban commented 1 year ago

(Apologies for the long delay) @mikel-brostrom - Thanks for the reply. A followup q:

What are your thoughts on this ?

Thanks for all the help !