Comments (12)
The core part of the metric code is from open-reid.
Here gallery_ids
has shape [num_gallery]
, indices
has shape [num_query, num_gallery]
, thus gallery_ids[indices]
has shape [num_query, num_gallery]
. Each row of gallery_ids[indices]
is for a query, containing the sorted gallery ids.
query_ids
has shape [num_query]
, thus query_ids[:, np.newaxis]
has shape [num_query, 1]
.
matches = (gallery_ids[indices] == query_ids[:, np.newaxis])
has shape [num_query, num_gallery]
. Each row of matches
contains True
and False
values, where True
means same id as query.
The part confusing you may be this gallery_ids[indices]
. May the following example helps:
from __future__ import print_function
import numpy as np
gallery_ids = np.array([5, 8, 12, 7, 3])
indices = np.array([[0, 1, 3, 4, 2],
[1, 3, 0, 2, 4],
[1, 0, 3, 4, 2]])
print(gallery_ids[indices])
The result is
[[ 5 8 7 3 12]
[ 8 7 5 12 3]
[ 8 5 7 3 12]]
from alignedreid-re-production-pytorch.
Thank you for taking time to solve my problem, now I understand your meaning but when I run the following code, the matches always return false.
`
from future import print_function
import numpy as np
gallery_ids = np.array([1, 2, 4, 3, 1])
query_ids = np.array([1, 2, 4, 5, 1])
indices = np.array([[0, 1, 3, 4, 2],
[1, 3, 0, 2, 4],
[1, 0, 3, 4, 2]])
matches = (gallery_ids[indices] == query_ids[:, np.newaxis])
print(matches)
`
the result is only a False. Is this problem caused by my Numpy Version or somgthing else is wrong.thank you!
from alignedreid-re-production-pytorch.
I made a mistake in the previous answer. I have updated it now. This line gallery_ids = np.array([5, 8, 12, 7, 3])
is updated.
from alignedreid-re-production-pytorch.
Ok I have noticed your error and that's all right. But I found another problem as commented just now ,could you explian this problem for me? Thank you very much.
from alignedreid-re-production-pytorch.
Ok. so I should remove the [:, np.newaxis] behind the query_ids?but the code doesn't remove it.
from alignedreid-re-production-pytorch.
I gave a wrong example in which the dimension of indices
is not consistent with [num_query, num_gallery]
.
The following one should be practical:
from __future__ import print_function
import numpy as np
gallery_ids = np.array([1, 2, 4, 3, 1])
query_ids = np.array([1, 2, 4])
indices = np.array([[0, 1, 3, 4, 2],
[1, 3, 0, 2, 4],
[1, 0, 3, 4, 2]])
print(gallery_ids[indices])
print(gallery_ids[indices] == query_ids[:, np.newaxis])
It outputs:
[[1 2 3 1 4]
[2 3 1 4 1]
[2 1 3 1 4]]
[[ True False False True False]
[ True False False False False]
[False False False False True]]
from alignedreid-re-production-pytorch.
Thank you very much! I understand this problem!
from alignedreid-re-production-pytorch.
You're welcome. The high dimension data, argsort
, indexing, etc also confuse me at times.
from alignedreid-re-production-pytorch.
Sorry to disturb you again but I am not confused with the code
delta = 1. / (len(index) * repeat)
and what the delta stands for?for the Market1501 dataset the value of delta always equals to 1,so why add delta in the code below
ret[i, k - j] += delta
thank you!
from alignedreid-re-production-pytorch.
delta
is for the option first_match_break
. When analyzing line delta = 1. / (len(index) * repeat)
, you can just consider repeat == 1
, and it becomes delta = 1. / len(index)
. The * repeat
here is just a way of implementing averaging over repeats.
- If
first_match_break
isTrue
, the resulting CMC curve for a query is a step function turning from0
to1
at the point where the first valid match in gallery list appears. - If
first_match_break
isFalse
, the resulting CMC curve for a query is a staircase function going up bydelta
wherever a valid match in gallery list appears. This function finally goes up to1
. Thedelta
for a query is1 / num-of-valid-match
.
In the case of Market1501, first_match_break == True
, thus delta
is not used. The following three lines instead of ret[k - j] += delta
are executed.
if first_match_break:
ret[k - j] += 1
break
from alignedreid-re-production-pytorch.
Hello houjing, now I am reproducing your code on the cuhk03 dataset, now I understand the new protocol which split the training set and testing set which consist of 767 identities and 700 identities respectively. But I want to use the papers protocol which split the dataset once for training and testing, and the gallery includes 200 identities. I have noticed that you use the re_ranking_train_test_split.pkl to produce the partition file. So I wonder if I want to produce the paper's protocol,how or where you get this .pkl file so that I can imitate to get a new .pkl file, for example if there is a script to produce it. thank you!
from alignedreid-re-production-pytorch.
Sorry, I do not have this 1267/200 train/test split file.
To generate a train_test_partition_file
for this function, you have to know the structure of this .pkl
file. It is a dictionary (denoted by train_test_partition
in the following) having two keys detected
and labeled
. The following takes the detected
subset as an example. train_test_partition['detected']
is a dictionary with keys train_im_names
, query_im_names
and gallery_im_names
.
If you want to generate a 1267/200 train/test split file, train_test_partition['detected']['train_im_names']
should contain image names of the 1267 ids and train_test_partition['detected']['query_im_names']
+ train_test_partition['detected']['gallery_im_names']
should contain image names of the rest 200 ids. Which 1267 ids to select as training ids, and how the test set is split into query and gallery sets are up to you.
from alignedreid-re-production-pytorch.
Related Issues (20)
- top-k结果可视化 HOT 2
- CUHK03和DUKE上的识别率 HOT 1
- How to inference my own test set
- Keys not found in source state_dict HOT 1
- Global Feature Extraction HOT 1
- Local feature dimensions
- About performance on market1501 for global learning and mutual learning
- Is it generalised
- TypeError: __init__() got an unexpected keyword argument 'log_dir'
- AssertionError HOT 3
- 请问论文中的Resnet50-Xception结构是不是没有实现? HOT 1
- 论文复现的参数问题
- how to use the test data to draw picture just like roc missrate cmc?
- How to use without GPU? HOT 2
- could you send me a partitions.pkl about market1501 HOT 1
- 为啥用你提供的weight测得market也只有88.78的top1呢 HOT 1
- how to infer some images or videos
- RuntimeError: cannot perform reduction function min on tensor with no elements because the operation does not have an identity
- Poor performnace when reproducing evaluation on market1501 HOT 2
- would you help me to fix this error?
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 alignedreid-re-production-pytorch.