Pytorch中的Tensorboard與Transforms搭配使用
這章是結(jié)合之前學(xué)習(xí)的Tensforboard與Transforms的一個(gè)練習(xí)。
直接上代碼:
from PIL import Image from torch.utils.tensorboard import SummaryWriter from torchvision import transforms import os root_path = "D:\\data\\basic\\Image" lable_path = "aligned" img_dir = os.path.join(root_path, lable_path) img_list = os.listdir(img_dir) img_path = img_list[0] # 加載img_path路徑 img_path = os.path.join(img_dir, img_path) # 將img以PIL格式打開 img = Image.open(img_path) # 創(chuàng)建具體的SummaryWriter writer = SummaryWriter("logs") # 創(chuàng)建具體的ToTensor方法 to_tensor = transforms.ToTensor() # 將img以PIL格式轉(zhuǎn)化成Tensor格式 tensor_img = to_tensor(img) # 使用writer.add_image方法 writer.add_image("tensor_img", tensor_img) writer.close()
代碼run結(jié)果:
在命令行打開tensorboard:
但是在打開tensorboard
之前,要打開正確的位置,不然會(huì)報(bào)錯(cuò),以此程序?yàn)槔枰谡业絣ogs的目錄。
在瀏覽器顯示的結(jié)果:
到此這篇關(guān)于Pytorch
中的Tensorboard
與Transforms
搭配使用的文章就介紹到這了,更多相關(guān)Tensorboard與Transforms搭配使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- pytorch使用tensorboardX進(jìn)行l(wèi)oss可視化實(shí)例
- Pytorch中TensorBoard及torchsummary的使用詳解
- 在Pytorch中簡(jiǎn)單使用tensorboard
- 教你如何在Pytorch中使用TensorBoard
- pytorch下tensorboard的使用程序示例
- Pytorch用Tensorboard來觀察數(shù)據(jù)
- PyTorch?可視化工具TensorBoard和Visdom
- python神經(jīng)網(wǎng)絡(luò)Pytorch中Tensorboard函數(shù)使用
- Pytorch中使用TensorBoard詳情
相關(guān)文章
python實(shí)現(xiàn)二維碼掃碼自動(dòng)登錄淘寶
最近做項(xiàng)目,需要用到自動(dòng)登錄淘寶,正好在學(xué)習(xí)python,整網(wǎng)絡(luò)爬蟲,所以就嘗試著寫一個(gè)腳本,自動(dòng)解決。有相同需求的小伙伴可以參考下2016-12-12Python3實(shí)現(xiàn)獲取圖片文字里中文的方法分析
這篇文章主要介紹了Python3實(shí)現(xiàn)獲取圖片文字里中文的方法,結(jié)合實(shí)例形式分析了Python基于文字識(shí)別引擎tesseract-ocr針對(duì)圖片里中文識(shí)別的相關(guān)操作技巧與操作注意事項(xiàng),需要的朋友可以參考下2018-12-12

python實(shí)現(xiàn)將漢字轉(zhuǎn)換成漢語拼音的庫

Python eval的常見錯(cuò)誤封裝及利用原理詳解

詳解Python調(diào)用華為API實(shí)現(xiàn)圖像標(biāo)簽

對(duì)python中l(wèi)ist的拷貝與numpy的array的拷貝詳解

python中not not x 與bool(x) 的區(qū)別