一、運行train程序
運行程序的命令行:
記得先轉(zhuǎn)到當(dāng)前目錄下
再執(zhí)行如下命令行:
注意端口名稱與自己分配的端口
CUDA_VISIBLE_DEVICES=0 python train.py --dataroot ./datasets/cell3 --name?cell3_spcyclegan --model cycle_lo_seg --no_dropout --which_model_netG resnet_9blocks --display_id 2 --display_port 8097 --input_nc 1 --output_nc 1 --phase train --identity 0 >log_file/cell3.out?
開啟visdom的鏈接如下:
python -m visdom.server
在后臺跑程序的代碼如下:
CUDA_VISIBLE_DEVICES=0 nohup python train.py --dataroot ./datasets/cell3 --name?cell3_spcyclegan --model cycle_lo_seg --no_dropout --which_model_netG resnet_9blocks --display_id 2 --display_port 8097 --input_nc 1 --output_nc 1 --phase train --identity 0 >log_file/cell3.out &
二、進(jìn)行sequence的label
1、groundtruth label
1、導(dǎo)入15張圖,imageJ? import the image sequence,并且記得勾上轉(zhuǎn)成8bit。
2、選擇1024*1024*15 dimension,最右側(cè)的滾動條可以選擇圖像序號。
3、label的時候記得勾上3D。
4、注意paint over這里選擇 all visibel labels
5、記得用brush的時候清除label的時候把3D取消掉。
其實這樣來回變動著標(biāo)記真的蠻快的。一個小時就標(biāo)記好了15張圖片。
2、color coding
1、把圖像轉(zhuǎn)成png形式,我是把圖像分成slices,然后逐一存成png格式的。
2、改python文件里的維度。
3、丟進(jìn)linux服務(wù)器。
3、overlay the image
matlab進(jìn)行圖像疊加的方法:
參考網(wǎng)址:
https://blog.csdn.net/wzz110011/article/details/78174003
我是用tif格式進(jìn)行疊加的,采用的代碼如下,是用matlab寫的:
%add images
close;
clear all;
clc;
A1 = imread('image00015.tif');
A2 = imread('z0015.tif');
K = imlincomb(0.5,A1,0.5,A2);
imwrite(K,'c0015.tif')
4、組成4幅圖
把4幅圖合在一起:
哪四幅圖?分別是:原圖,灰色的分割圖,彩色的分割圖,以及彩色的疊加圖。
遇到問題:灰色的分割圖不能正常顯示
解決辦法:
imagesc(a2,[0,4]);% four is the max value in a2
colormap(gray);
遇到問題:合在一起有空隙
考慮圖像拼接。圖像拼接不行。
這篇文章里講了如何消除空白區(qū)域。
https://blog.csdn.net/shanchuan2012/article/details/53980288
5、合成視頻
參考自己之前的文章:Windows系統(tǒng)下安裝FFmpeg并進(jìn)行照片合成視頻
ffmpeg -loop 1 -f image2 -i d:/video2/c%04d.tif -vcodec libx264 -r 3 -t 5 test.mp4
3是幀數(shù),5是秒數(shù),乘起來就是總照片數(shù)目。
三、運行test的程序
原來的命令行:
CUDA_VISIBLE_DEVICES=2 python test.py --dataroot ./datasets/biospy --name biospy_spcyclegan --model test_seg --phase test --which_model_netG resnet_9blocks --no_dropout --display_id 0 --dataset_mode single --which_direction AtoB --which_epoch 200 --loadSize 256 --fineSize 256 --how_many 1280
實際的命令行:
CUDA_VISIBLE_DEVICES=0 python test.py --dataroot ./datasets/cell3 --name cell3_spcyclegan --model test_seg --phase test --which_model_netG resnet_9blocks --no_dropout --display_id 0 --dataset_mode single --which_direction AtoB --which_epoch 200 --loadSize 1024 --fineSize 256 --how_many 5
我需要查看這些參數(shù)的具體用途:
how many? ?-how many test images to run
self.parser.add_argument('--loadSize', type=int, default=286, help='scale images to this size')
self.parser.add_argument('--fineSize', type=int, default=256, help='then crop to this size')
注意:finesize如果改成1024,會出現(xiàn)out of memory的問題。
所以你需要怎么做?
遇到問題1:img_path不大對
img_path = model.get_image_paths()
model = create_model(opt)
在cycle_lo_seg_model中我找到了對應(yīng)代碼
def get_image_paths(self):
? ? ? ? return self.image_paths
更詳細(xì)的內(nèi)容在set_input這個函數(shù)里。
self.image_paths = input['A_paths' if AtoB else 'B_paths']
那么其中的A_path和B_path又分別是什么呢?
重點是找到set_input函數(shù)的括號里的input.
遇到問題2:只能處理256*256大小的圖像
解決辦法:1024*1024大小的圖像可以拆分成4*4個256*256大小的圖像,然后拼接。