美文网首页
2019-02-28

2019-02-28

作者: 幽并游侠儿_1425 | 来源:发表于2019-03-05 03:21 被阅读1次

    一、运行train程序

    运行程序的命令行:

    记得先转到当前目录下

    再执行如下命令行:

    注意端口名称与自己分配的端口

    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 &

    二、进行sequence的label

    1、groundtruth label

    1、导入15张图,imageJ  import the image sequence,并且记得勾上转成8bit。

    2、选择1024*1024*15 dimension,最右侧的滚动条可以选择图像序号。

    3、label的时候记得勾上3D。

    4、注意paint over这里选择 all visibel labels

    5、记得用brush的时候清除label的时候把3D取消掉。

    其实这样来回变动着标记真的蛮快的。一个小时就标记好了15张图片。

    2、color coding

    1、把图像转成png形式,我是把图像分成slices,然后逐一存成png格式的。

    2、改python文件里的维度。

    3、丢进linux服务器。

    3、overlay the image

    matlab进行图像叠加的方法:

    参考网址:

    https://blog.csdn.net/wzz110011/article/details/78174003

    我是用tif格式进行叠加的,采用的代码如下,是用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);

    遇到问题:合在一起有空隙

    考虑图像拼接。图像拼接不行。

    这篇文章里讲了如何消除空白区域。

    https://blog.csdn.net/shanchuan2012/article/details/53980288

    5、合成视频

    参考自己之前的文章:Windows系统下安装FFmpeg并进行照片合成视频

    ffmpeg -loop 1 -f image2 -i d:/video2/c%04d.tif -vcodec libx264 -r 3 -t 5 test.mp4

    3是帧数,5是秒数,乘起来就是总照片数目。

    三、运行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

    我需要查看这些参数的具体用途:

    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,会出现out of memory的问题。

    所以你需要怎么做?

    遇到问题1:img_path不大对

    img_path = model.get_image_paths()

    model = create_model(opt)

    在cycle_lo_seg_model中我找到了对应代码

    def get_image_paths(self):

            return self.image_paths

    更详细的内容在set_input这个函数里。

    self.image_paths = input['A_paths' if AtoB else 'B_paths']

    那么其中的A_path和B_path又分别是什么呢?

    重点是找到set_input函数的括号里的input.

    遇到问题2:只能处理256*256大小的图像

    解决办法:1024*1024大小的图像可以拆分成4*4个256*256大小的图像,然后拼接。

    相关文章

      网友评论

          本文标题:2019-02-28

          本文链接:https://www.haomeiwen.com/subject/snohuqtx.html