Undefined variable "testsets" or class "testsets"

I want to change the dataset from 'cuhk03.mat' to 'cuhk03_detected_lomo.mat',when i run the same program,there has an erro shows
% >> prepare_imdb
Undefined variable "testsets" or class "testsets"
wrong in prepare_imdb (line 14)
test = testsets{testsets_num,1};
But there has no error when i use the 'cuhk03.mat'(the‘cuhk03_detected_lomo.mat' is a dataset which has been processed with LOMO characteristics).The complete code is as follows:
% clear;
%you can download this file. It contains data.
load('..\cuhk03-prepare-eval/cuhk03_detected_lomo.mat');
imdb.meta.sets = ['train','test'];
count = 0;
label = 0;
%choose a split
testsets_num = 6; %cuhk03 has 20 different splits, and this value can be 1 ~ 20.
p = sprintf('./split%d_256_1/',testsets_num);
if(~exist(p,'dir'))
mkdir(p);
end
test = testsets{testsets_num,1};
cc = [];
for k=1:numel(detected) %camera
im = detected{k,1};
for i = 1:size(im,1) %identity
A = find(test(:,1) == k);
B = find(test(:,2) == i);
C = intersect(A,B);
if(~isempty(C))
continue;
end
label = label+1;
temp = 0;
for j=1:10 %image
file = im{i,j};
url = sprintf('F:/2016_person_re-ID-master/2016_person_re-ID-master/cuhk03-prepare-eval/split%d_256/%d_%d_%d_1.jpg',testsets_num,k,i,j);
if(~isempty(file))
disp(url);
imwrite(imresize(file,[256,256]),url);
temp = temp + 1;
count = count + 1;
%disp(count);
imdb.images.data(count) = cellstr(url);
imdb.images.label(count) = label;
end
end
cc = [cc;temp];
end
end
imdb.images.set = ones(1,count);
imdb.images.set(:,randi(count,[round(0.1*count),1])) = 2;
list = find(imdb.images.set==2);
for i=1:numel(list)
if cc(imdb.images.label(list(i)))<9
imdb.images.set(list(i))=1;
end
end
save(sprintf('cuhk_data_256_split%d_1.mat',testsets_num),'imdb','-v7.3');

Respuestas (2)

Walter Roberson
Walter Roberson el 28 de Oct. de 2018

1 voto

You are doing load() with no output arguments. That causes variables to be created in the current workspace. Your code then relies upon variables with those particular names existing. But what happens if what you load() has different variable names, or structures the information differently, or perhaps does not contain the information at all?

5 comentarios

mengqiu ren
mengqiu ren el 28 de Oct. de 2018
I generally understand what you mean, can you tell me how to do it?
Show us
whos -file cuhk03.mat
whos -file cuhk03_detected_lomo.mat
I suspect that the processed file does not contain the information you need.
mengqiu ren
mengqiu ren el 28 de Oct. de 2018
Oh!I made a mistake,it is not the 'cuhk03.mat',it is'cuhk_data_256_split6.mat' generated in 'prepare_imd.m'. https://github.com/layumi/2016_person_re-ID/blob/master/cuhk03-prepare-eval/prepare_imdb.m And it is so big that i can not attach it with the paper clip icon. and the cuhk03_detected_lomo.mat is on http://www.cbsr.ia.ac.cn/users/scliao/projects/lomo_xqda/#references
Walter Roberson
Walter Roberson el 28 de Oct. de 2018
Sorry, I do not offer assistance for biometrics.
mengqiu ren
mengqiu ren el 29 de Oct. de 2018
Thank you. I'll try something else

Iniciar sesión para comentar.

madhan ravi
madhan ravi el 28 de Oct. de 2018

0 votos

You didn’t define testsets

7 comentarios

mengqiu ren
mengqiu ren el 29 de Oct. de 2018
But why it go wrong when i just change the dataset? Can you tell me how to do it
Walter Roberson
Walter Roberson el 29 de Oct. de 2018
Your datasets do not contain the expected variable names.
madhan ravi
madhan ravi el 29 de Oct. de 2018
I’ll illustrate with an example ,
I have a .mat file named as Madhan.mat.
So I load the file in script say
load Madhan.mat
It contains variables a,b and c.
But instead I say
d.^2 in the next line.
What does MATLAB show me now in command window?
It says Undefined function or variable d.
Likewise it’s the same in your case so the so called testsets is not there in file .
But if you insist using testsets in the script you can rename the variable name as such .
datas = Madhan.mat
testsets = datas.a
Now what happens ? The variable name a is changed to testsets likewise you should do it for your case.
mengqiu ren
mengqiu ren el 29 de Oct. de 2018
I see what you mean,Thank you!
madhan ravi
madhan ravi el 29 de Oct. de 2018
Anytime
mengqiu ren
mengqiu ren el 30 de Oct. de 2018
It do not have the information which i need in the new .mat file . And the information in the two file have different format,so it can not result by the method of mandatory definition.I decide to change a method.
madhan ravi
madhan ravi el 30 de Oct. de 2018
Editada: madhan ravi el 30 de Oct. de 2018
yeah right atleast you found the answer for whats the causing the problem , your question here was "Undefined variable "testsets" or class "testsets""

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 28 de Oct. de 2018

Editada:

el 30 de Oct. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by