日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unet项目解析(1): run_training.py

發布時間:2025/3/15 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unet项目解析(1): run_training.py 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目GitHub主頁:https://github.com/orobix/retina-unet

參考論文:Retina blood vessel segmentation with a convolution neural network (U-net)?Retina blood vessel segmentation with a convolution neural network (U-net)


1. run_training.py解析

import os, sys # os模塊中主要用于處理文件和目錄 import configparser # Python 3.6中 configparser全使用小寫#config file to read from config = configparser.RawConfigParser() config.readfp(open(r'./configuration.txt')) # 建議使用 config.read('configuration.txt') #'configuration.txt'的內容見下面 #=========================================== #name of the experiment name_experiment = config.get('experiment name', 'name') nohup = config.getboolean('training settings', 'nohup') #std output on log file?run_GPU = '' if sys.platform == 'win32' else ' THEANO_FLAGS=device=gpu,floatX=float32 ' #是否用GPU進行訓練#create a folder for the results 創建文件夾用于保存結果 result_dir = name_experiment print ("\n 1. Create directory for the results (if not already existing)") if os.path.exists(result_dir):print ("Dir already existing") # 用于保存結果的test文件夾如果存在就沒有必要創建 elif sys.platform=='win32':os.system('mkdir ' + result_dir) else:os.system('mkdir -p ' +result_dir) # 需要時創建上層目錄,如目錄早已存在則不當作錯誤print ("copy the configuration file in the results folder") if sys.platform=='win32':os.system('copy configuration.txt .\\' +name_experiment+'\\'+name_experiment+'_configuration.txt') else:os.system('cp configuration.txt ./' +name_experiment+'/'+name_experiment+'_configuration.txt')# run the experiment if nohup: #作者采用不掛斷的方式運行命令print ("\n2. Run the training with nohup, no GPU ")os.system(' nohup python -u ./src/retinaNN_training.py > ' +'./'+name_experiment+'/'+name_experiment+'_training.nohup') #運行retina_training.py文件 else:print ("\n2. Run the training(no nohup), no GPU")os.system(' python ./src/retinaNN_training.py') # 采用掛起的形式運行命令

配置文件:configuration.txt (使用的是section-option方法,可以利用字符串匹配進行參數解析)

[data paths] #數據路徑 以及 訓練集 測試集的名字 path_local = ./DRIVE_datasets_training_testing/ #封裝好的訓練集圖像+金標準 和 測試集圖像+金標準 train_imgs_original = DRIVE_dataset_imgs_train.hdf5 #封裝好的訓練集圖像 train_groundTruth = DRIVE_dataset_groundTruth_train.hdf5 #封裝好的訓練集金標準 train_border_masks = DRIVE_dataset_borderMasks_train.hdf5sks #封裝好的訓練集掩膜test_imgs_original = DRIVE_dataset_imgs_test.hdf5 #封裝好的測試集圖像test_groundTruth = DRIVE_dataset_groundTruth_test.hdf5 #封裝好的測試集金標準test_border_masks = DRIVE_dataset_borderMasks_test.hdf5 #封裝好的測試集掩膜[experiment name]name = test[data attributes]# 作者的訓練集不多 所以作者采用了分塊進行訓練的方式,從圖像中裁剪的圖像塊大小為 patch_height*patch_widthpatch_height = 48 patch_width = 48[training settings]#number of total patches:N_subimgs = 190000#if patches are extracted only inside the field of view:inside_FOV = False#Number of training epochsN_epochs = 150batch_size = 32#if running with nohup #不掛斷地運行命令nohup = True[testing settings]#Choose the model to test: best==epoch with min loss, last==last epochbest_last = best#number of full images for the test (max 20)full_images_to_test = 20#How many original-groundTruth-prediction images are visualized in each imageN_group_visual = 1#Compute average in the prediction, improve results but require more patches to be predictedaverage_mode = True#Only if average_mode==True. Stride for patch extraction, lower value require more patches to be predictedstride_height = 5stride_width = 5#if running with nohupnohup = False

總結

以上是生活随笔為你收集整理的Unet项目解析(1): run_training.py的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。