-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabels2upload_fromCNN.m
55 lines (42 loc) · 1.89 KB
/
labels2upload_fromCNN.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
T = readtable('\\vortex\share\nes-lter\Stingray\NESLTER_EN657_annotations.csv');
ii = find(strcmp('Jonathan_unlabeled', T.label));
% p = '\\vortex\share\nes-lter\Stingray\NESLTER_EN657_ROI\torun\';
% f = dir([p '/**/*.png']);
% n = regexprep({f.name}', '.png', '');
% [ia,ib] = ismember(T.roi_id(ii),n);
% if sum(ia) ~= length(ii)
% disp('missing some ROIs')
% keyboard
% end
% for cc = 1:length(ii)
% movefile([f(ib(cc)).folder filesep f(ib(cc)).name], [f(ib(cc)).folder filesep T.label{ii((cc))} filesep f(ib(cc)).name])
% end
p = '\\vortex\share\nes-lter\Stingray\CNN_output\v3\ISIIS_SG2105_10Aug2021\';
f1 = 'EN657_13Oct2020_000';
fname = [f1 '_img_results.json'];
jj = fileread([p fname]);
jj = jsondecode(jj);
jj.output_classes = jj.output_classes+1; %change from 0 base for matlab
[~,ib] = ismember(T.roi_id(ii),regexprep(jj.input_images, '.png', ''));
new_annotations = table;
new_annotations.roi_id = jj.input_images(ib(find(ib)));
new_annotations.label = jj.class_labels(jj.output_classes(ib(find(ib))));
f1 = 'EN657_13Oct2020_001';
fname = [f1 '_img_results.json'];
jj = fileread([p fname]);
jj = jsondecode(jj);
jj.output_classes = jj.output_classes+1; %change from 0 base for matlab
[~,ib] = ismember(T.roi_id(ii),regexprep(jj.input_images, '.png', ''));
new_annotations2 = table;
new_annotations2.roi_id = jj.input_images(ib(find(ib)));
new_annotations2.label = jj.class_labels(jj.output_classes(ib(find(ib))));
f1 = 'EN657_14Oct2020_001';
fname = [f1 '_img_results.json'];
jj = fileread([p fname]);
jj = jsondecode(jj);
jj.output_classes = jj.output_classes+1; %change from 0 base for matlab
[~,ib] = ismember(T.roi_id(ii),regexprep(jj.input_images, '.png', ''));
new_annotations3 = table;
new_annotations3.roi_id = jj.input_images(ib(find(ib)));
new_annotations3.label = jj.class_labels(jj.output_classes(ib(find(ib))));
new_annotations = [new_annotations; new_annotations2; new_annotations3];