Comments (1)
It took a while, but I think I understood now. I write a few notes, if someone else stumbles upon the same issues, and close this issue.
Looking at the engine, e.g. the ImageSoftmaxEngine
during the training process in forward_backward() the loss is computed between the pids and the models prediction.
In this case the model prediction is a tensor of shape [(B,) num_classes]
containing an estimate of a certainty for every class. (This is not really a probability, because it wasn't passed through a Softmax, but the analogy holds.) Still, by passing it to the loss function, the last linear layer will learn to predict the class from the embeddings. And because during training there are no "real" embeddings to compute a loss against, it is important to predict the classes to be able to compare those to the targets.
During testing, we assume that our model predicts useful embeddings and therefore we can use them. Lets have a look at engine._evaluate, when calling _feature_extraction()
:
deep-person-reid/torchreid/engine/engine.py
Lines 379 to 385 in 566a56a
The same embedding generation model will predict the embeddings (qf
& gf
) for the query and gallery. Then we can validate, whether the embeddings for person X in the query are close to the embeddings for person X in the gallery. This is done by computing the distance between every embedding in the query to every embedding in the gallery. Smaller distances meaning that the embeddings are closer, and therefore it is more likely, that the same person is shown. If the embeddings for each individual are close, and still far away from every other individual, the goal is reached.
Looking at the evaluation (here the python version of eval_market1501), we first obtain the indices which sort the distance matrix (smallest to highest).
deep-person-reid/torchreid/metrics/rank.py
Lines 107 to 108 in 566a56a
Therefore, with g_pids[indices]
we obtain the for every person id in the gallery a sorted list of the closest matching person ids from query. If we now take the first max_rank
values of the matches, which contain the most likely classes, we can check if those contain the correct target id.
So, Yes, it kind of makes sense to have different outputs. But in my opinion it would be better to always return the embeddings and a probability distribution (e.g. Softmax) of the certainty that this embedding relates to a specific class. Then there wouldn't have to be a difference between training and testing...
from deep-person-reid.
Related Issues (20)
- Computing extracted features distance
- Missing packages when trying to export models to ONNX from Docker container HOT 1
- can you write code for LSTM models ?? HOT 1
- can you tell me , why i am getting this kind of erros
- Error: all query identities do not appear in gallery
- torchreid
- Columns and DataType Not Explicitly Set on line 44 of export.py
- Train for non-person Re-Identification?
- URL link in this project is not available
- Using the cosine similarity between embeddings generated by OsNET-Ain doesn't provide good results, HELP !!
- Training error,CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling `cublasSgemm
- pretrained weights for "osnet_ain_x1_0" are broken
- 求助 How to export .pth files in model_zoo to onnx files?
- 对多个类别做reid, 是否可以放在一起训练
- 关于reid模型转rknn
- list index out of range
- mAP using osnet_x1_0 and resnet50 is weird HOT 1
- How to count the same person in different photos? HOT 2
- How to fine-tune a model with a custom dataset? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-person-reid.