Comments (7)
Suppose you have 3 gallery samples with ID 0,1,1
and 4 probe samples with ID 0,0,1,1
, then you need to
- Compute 3x4 pairwise distance matrix
D
, whereD[i, j]
= distance between gallery-i and probe-j - Create a gallery ID list
gids = [0,1,1]
- Create a probe ID list
pids = [0,0,1,1]
Then you can call cmc(D, gids, pids)
to get CMC.
from dgd_person_reid.
sorry I don't know
if I have the cuhk03 person id ,like : 000_1 ,000_2 , 001_1 , 001_2 , 002_1 , 002_2
000_1 ,000_2 is the same person ; 001_1 , 001_2 is the same person ; 002_1 , 002_2 is the same person
A network can compute the person is the same or not , output is true or false
how to know the CMC?
and the CMC is relationship with rank-1 , rank-2 ...... ?
thanks you
from dgd_person_reid.
@Phoebe-star Our network does not compute whether two persons are the same or not. It receives only one image as input, and outputs the feature vector. After getting the features of all the gallery and probe images, we can compute pairwise Euclidean distances. Based on which we can compute CMC.
A brief introduction of CMC can be found here.
from dgd_person_reid.
where can I find rank-m?
thanks
from dgd_person_reid.
@Phoebe-star CMC top-1 is rank-1. They are the same, literally.
from dgd_person_reid.
################################
import numpy as np
def _cmc_core(D, G, P):
m, n = D.shape
order = np.argsort(D, axis=0)
match = (G[order] == P)
return (match.sum(axis=1) * 1.0 / n).cumsum()
def cmc(distmat, glabels=None, plabels=None, ds=None, repeat=None):
"""Compute the Cumulative Match Characteristic (CMC)
This function assumes that gallery labels have no duplication. If there are
duplications, random downsampling will be performed on gallery labels, and
the computation will be repeated to get an average result.
Parameters
----------
distmat : numpy.ndarray
The distance matrix. distmat[i, j]
is the distance between i-th
gallery sample and j-th probe sample.
glabels : numpy.ndarray or None, optional
plabels : numpy.ndarray or None, optional
If None, then gallery and probe labels are assumed to have no
duplications. Otherwise, they represent the vector of gallery and probe
labels. Default is None.
ds : int or None, optional
If None, then no downsampling on gallery labels will be performed.
Otherwise, it represents the number of gallery labels to be randomly
selected. Default is None.
repeat : int or None, optional
If None, then the function will repeat the computation for 100 times
when downsampling is performed. Otherwise, it specifies the number of
repetition. Default is None.
Returns
-------
out : numpy.ndarray
The rank-1 to rank-m accuracy, where m is the number of (downsampled)
gallery labels.
"""
m, n = distmat.shape
if glabels is None and plabels is None:
glabels = np.arange(0, m)
plabels = np.arange(0, n)
if isinstance(glabels, list):
glabels = np.asarray(glabels)
if isinstance(plabels, list):
plabels = np.asarray(plabels)
ug = np.unique(glabels)
if ds is None:
ds = ug.size
if repeat is None:
if ds == ug.size and ug.size == len(glabels):
repeat = 1
else:
repeat = 100
ret = 0
for __ in xrange(repeat):
# Randomly select gallery labels
G = np.random.choice(ug, ds, replace=False)
# Select corresponding probe samples
p_inds = [i for i in xrange(len(plabels)) if plabels[i] in G]
P = plabels[p_inds]
# Randomly select one gallery sample per label selected
D = np.zeros((ds, P.size))
for i, g in enumerate(G):
samples = np.where(glabels == g)[0]
j = np.random.choice(samples)
D[i, :] = distmat[j, p_inds]
# Compute CMC
ret += _cmc_core(D, G, P)
return ret / repeat
gids = [0,1,1]
pids = [0,0,1,1]
D =np.matrix("0.8 0.9 0.3 0.5;0.3 0.5 0.6 0.1;0.9 0.1 0.1 0.1")
print ( cmc(D, gids, pids) )
###################################
I run the cmc.py code
and the result is [ 0.52 1. ] [ from the code print ( cmc(D, gids, pids) ) ]
what dose it mean?
thanks thanks
from dgd_person_reid.
It means the top-1 accuracy is 52% and the top-2 accuracy is already 100%.
from dgd_person_reid.
Related Issues (20)
- I use your model but get better results,why? HOT 5
- Hi,can convert_lmdb_to_numpy.py num*27*37*96 lmdb into matlab? HOT 2
- could you please provide the file `external/exp/db/cuhk01/train.txt`? HOT 2
- Questions about data preprocessing and how to choose test set HOT 11
- about the inception layer HOT 2
- The difference of jstl_dgd_inference.caffemodel and jstl_dgd.caffemodel? HOT 6
- My Python implementation performs much worse than the paper HOT 3
- where is the guideddropout layer?? HOT 2
- error: invalid conversion from โconst void*โ to โvoid*โ [-fpermissive] HOT 21
- Support for Shinpuhkan dataset
- JSTL
- ./merge_dbs.sh error HOT 1
- Training a model using the mixed dataset with JSTL - extactly as mentioned - But the result is too bad. The loss is not decreasing as 'archived' HOT 7
- change gpu id
- change batch_size value
- The last experiment didn't pass
- How can I run the code without Shinpuhkan dataset
- Could you please provide pretrained weight
- CMC calculation 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 dgd_person_reid.