我确实按照昨天想的把图片resize成了1000*1000大小 bounding box也重新计算了。
以下是修改以后的matlab代码。
%% ==================================================================%
% OPEN AND VIEW PNG FORMAT DDSM IMAGES WITH THEIR ANNOTATIONS
% -ope---(MAIN FILE)----
% ===================================================================%
% Author - Anmol Sharma (Undergraduate Engineering Student)
% Affiliation - DAV Institute of Engineering & Technology
% Supervisers - Dr. Jayasree Chakraborty* and Dr. Abhishek Midya#
% *Research Fellow, Memorial Sloan Kettering Cancer Center
% #Assistant Professor, NIT Silchar
% Description - The code is used to view the PNG format DDSM images
% created using the openDDSMLJPEG1AndConvertToPNG.m
% script. This script opens the PNG file, and then also
% opens the corresponding OVERLAY file to get the boundary
% information of the mass present in that particular
% mammogram.
% License - Copyright (C) 2015 Anmol Sharma
%
% This program is free software: you can redistribute it
% and/or modify it under the terms of the GNU General
% Public License as published by the Free Software
% Foundation, either version 2 of the License, or (at
% your option) any later version.
%
% This program is distributed in the hope that it will
% be useful, but WITHOUT ANY WARRANTY; without even the
% implied warranty of MERCHANTABILITY or FITNESS FOR A
% PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General
% Public License along with this programmax_y. If not,
% see <http://www.gnu.org/licenses/>.
%===================================================================%
clear all
clc
%% SET THESE PATHS FIRST!
% Needed to load PNG files
directoryOfDDSMPNG = 'D:\cancers_jpg_test\';
directoryOfDDSMPNG_new = 'D:\cancers_jpg_test_new\';
disp(directoryOfDDSMPNG)
% Needed to load OVERLAY FIles
directoryOfDDSM = 'D:\OVERLAY_CC_test\';
imageOutputFileFormat = '*.jpg'; % Notice the STAR dot. Can be *.tif, *.jpg...
filenames = dir(strcat([directoryOfDDSMPNG, imageOutputFileFormat]));
disp(filenames)
for i = 1:length(filenames)
disp( filenames(i).name((1:(length(filenames(i).name) - 5))))
overlayName = strcat([directoryOfDDSM, filenames(i).name((1:(length(filenames(i).name) - 4))), '.OVERLAY']);
jpgName_new = strcat([directoryOfDDSMPNG_new, filenames(i).name((1:(length(filenames(i).name) - 4))), '.jpg']);
JPGName = strcat([filenames(i).name((1:(length(filenames(i).name) - 4))), '.jpg']);
[num]=count_overlay(overlayName)
for j = 1:num
[bnd_c,bnd_r] = readBoundary(overlayName, j);
%bnd_c²¡ÔîÇøÓòµÄËùÓкá×ø±ê£¬bnd_r²¡ÔîÇøÓòµÄËùÓÐÁÐ×ø±ê
% disp(bnd_c)
min_x=min(bnd_c)
max_x=max(bnd_c)
width=max_x-min_x
min_y=min(bnd_r)
max_y=max(bnd_r)
height=max_y-min_y
left_x=min_x
left_y=min_y
image = imread(strcat(directoryOfDDSMPNG, filenames(i).name));
[heightOfImage, widthOfImage] = size(image);
B = imresize(image,[1000 1000])
[heightOfImage1, widthOfImage1] = size(B)
% temp_mask = poly2mask(bnd_c,bnd_r, 1000,1000);
imshow(B,[])
% PATH=
imwrite(B,jpgName_new)
hold on
scale_w=1000/widthOfImage
scale_y=1000/heightOfImage
A = [left_x*scale_w,left_y*scale_y,width*scale_w,height*scale_y]
write(JPGName,A)
% rectangle('Position',A)
rectangle('Position',A,'EdgeColor','r')
plot(bnd_c*scale_w, bnd_r*scale_y, '-r');
pause;
close all;
end
end
我真的很想哭,看到结果和昨天一样,我真的想打人了。我又不知道能和谁去讨论,只能自己在这里写。
我不知道我到底哪里出了问题
1.数据量少?
2.数据问题?—解决办法:
之后就报错,这个错误我在以前遇到过,应该是版本问题不匹配,后来我也忘了怎么解决的了,不过我现在想要用我的代码跑一遍肺炎的数据集。
实验室要关门了。。。
如果这个结果可以跑通就证明我的代码没有问题,还是数据的问题!!!
如果这个跑不通,就证明我的代码有问题!!
下面的这个bug是用原来的author的codes work的,可能是因为version的问题,不过后来我似乎solve了。。。我实在想不起来我怎么做到的了,,好像以前的blog中record了。。
Traceback (most recent call last):
File “train.py”, line 511, in
main()
File “train.py”, line 496, in main
callbacks=callbacks,
File “/home/ld/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py”, line 91, in wrapper
return func(*args, **kwargs)
File “/home/ld/anaconda3/lib/python3.6/site-packages/keras/engine/training.py”, line 1418, in fit_generator
initial_epoch=initial_epoch)
File “/home/ld/anaconda3/lib/python3.6/site-packages/keras/engine/training_generator.py”, line 251, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File “/home/ld/anaconda3/lib/python3.6/site-packages/keras/callbacks.py”, line 79, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File “keras-retinanet/keras_retinanet/callbacks/common.py”, line 31, in on_epoch_end
self.callback.on_epoch_end(epoch, logs=logs)
File “keras-retinanet/keras_retinanet/callbacks/eval_rsna.py”, line 72, in on_epoch_end
self.model,
File “keras-retinanet/keras_retinanet/utils/eval_rsna.py”, line 360, in evaluate
annotations = all_annotations[i][label]
IndexError: index 0 is out of bounds for axis 0 with size 0
好难过真的心都碎了真的
觉得自己一个人一直扛着所有的事情,就连心里想说的,也不可以和bf说,似乎我们不是一个世界,我也不想过多打扰他的世界,他的世界太过于简单。
我只能沉迷于代码中,其实?
也算是好事吧,否则我一天胡思乱想的,抗住这个压力还蛮好的,我说实话还蛮享受现在的日子的。
回去就想睡觉,看一会《how to change your mind》然后明天又是活力满满的一天~~~~
加油