超分网络记录

(1)虚拟环境创建:conda create -n SuperResolution python=3.7

(2)安装相应包:conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia ## --channel https://pypi.tuna.tsinghua.edu.cn/simple

          pip install tqdm -i https://pypi.tuna.tsinghua.edu.cn/simple

          pip install imgaug -i https://pypi.tuna.tsinghua.edu.cn/simple

          conda install -c conda-forge tensorboardx

          pip install -i https://pypi.tuna.tsinghua.edu.cn/simple "/home/fang/Packages/md-1.3.2.62439.Cuda114-py3-none-linux_x86_64.whl"

           pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple

(2.1)遇到问题:安装torch后,训练过程中发现用不起cuda,torch.cuda.is_available()返回False。

       1)尝试1:发现CUDA相关路径没有添加到环境变量,遂vim ~/.bashrc 命令添加,保存并退出命令【ESC停止编辑模型,:wq+enter,保存并退出】,source ~/.bashrc更新,echo $CUDA_HOME等命令检查。结果还是不行

        2)尝试2:在终端查看nvcc -V的版本,发现CUDA版本是11.6,我之前通过nvidia-smi看到的CUDA版本是12.4,所以pythorch安装的时候,就装成12.4了。重新安装11.6后的pytorch,这个问题就解决啦!安装命令:conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia

 

 

模型训练命令(全是2D网络结构):

(1)Diffusion:CUDA_VISIBLE_DEVICES=2,3,4 python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/Image-Super-Resolution-via-Iterative-Refinement_modify/sr.py" -c "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/Image-Super-Resolution-via-Iterative-Refinement_modify/config/sr_ddpm_240724.json"
(2)ESDR:CUDA_VISIBLE_DEVICES=1,4,5 python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/vsr_train.py" -i "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/Config/config_src_3D.py"
(3)ESDR:CUDA_VISIBLE_DEVICES=2 python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/vsr_train.py" -i "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/Config/config_src.py"
(4)unet:CUDA_VISIBLE_DEVICES=1,4 python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/vsr_train_unet.py" -i "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/Config/config_unet_3D.py"
 
EDSR和unet均采用L1 loss作为损失函数,且均去除Batch normalization【是在mini dataset上进行均值方差归一化,而不是在train dataset上做,所以做了BN反而加入噪声,对生成模型反而不友好,如超分、去噪、图像生成、图像压缩这样的模型】

Enhanced Deep Residual Networks for Single Image Super-Resolution

 

模型测试: 

DDPM:python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/Image-Super-Resolution-via-Iterative-Refinement_modify/infer.py" -c "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/Image-Super-Resolution-via-Iterative-Refinement_modify/config/sr_ddpm_240910_infer.json"

 

EDSR/U-Net: python "/data1/wangfang_data/SichuanPeople/1_KneeDatabase/0_code/EDSR-PyTorch/src/vsr_test_unet.py" 【EDSR一样的流程, 修改参数即可】

大庆设置:

parser.add_argument('-i', '--input', type=str, default="/data/qingzhou/scrm_denoise/valid_test_3d.csv", help='input folder/file for intensity images')

parser.add_argument('-m', '--model', type=str, default="/data/qingzhou/scrm_denoise/", help='model root folder')
parser.add_argument('-o', '--output', type=str, default="/data/qingzhou/scrm_denoise/valid_data", help='output folder for segmentation')
parser.add_argument('-n', '--sr_name', default='sr_edsr_r32f256_norm_reg.nii.gz', help='the name of the sr result to be saved')
parser.add_argument('-g', '--gpu_id', default='1', help='the gpu id to run model')
parser.add_argument('--save_image', help='whether to save original image', action="store_true")
args = parser.parse_args()

 EDSR 3D 

parser.add_argument('-i', '--input', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/5_DiffusionData/test_set_240819_EDSR_3D.csv", help='input folder/file for intensity images')
parser.add_argument('-m', '--model', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/6_EDSR/", help='model root folder')
parser.add_argument('-o', '--output', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/6_EDSR/EDSR3D_TestData/", help='output folder for segmentation')
parser.add_argument('-n', '--sr_name', default='esr_r32f256_norm_reg_3D.nii.gz', help='the name of the sr result to be saved')
parser.add_argument('-g', '--gpu_id', default='5', help='the gpu id to run model')
parser.add_argument('--save_image', help='whether to save original image', action="store_true")
args = parser.parse_args()

 U-Net

parser.add_argument('-i', '--input', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/5_DiffusionData/test_set_240819_EDSR_2D.csv", help='input folder/file for intensity images')
parser.add_argument('-m', '--model', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/7_unet/", help='model root folder')
parser.add_argument('-o', '--output', type=str, default="/data1/wangfang_data/SichuanPeople/1_KneeDatabase/7_unet/UNet_TestData/", help='output folder for segmentation')
parser.add_argument('-n', '--sr_name', default='unet_2D.nii.gz', help='the name of the sr result to be saved')
parser.add_argument('-g', '--gpu_id', default='5', help='the gpu id to run model')
parser.add_argument('--save_image', help='whether to save original image', action="store_true")
args = parser.parse_args() 

posted @ 2024-07-26 19:10  王姑娘呀~  阅读(14)  评论(0)    收藏  举报