In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Tensorboard and Transforms in Pytorch. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Code directly:
from PIL import Imagefrom torch.utils.tensorboard import SummaryWriterfrom torchvision import transformsimport osroot_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]#Load img_path path img_path = os.path.join(img_dir, img_path)#Open img in PIL format img = Image.open (img_path)#Create concrete SummaryWriterwriter = SummaryWriter("logs")#Create concrete ToTensor methods to_tensor = transforms.ToTensor()#Convert img from PIL format to Tensor format tensor_img = to_tensor(img)#use writer.add_image method writer.add_image("tensor_img", tensor_img)writer.close()
Code run Result:
Open tensorboard on command line:
But before opening tensorboard, open the correct position, otherwise it will report an error. For example, in this program, you need to find the directory of logs.
Results displayed in the browser:
Thank you for reading this article carefully. I hope that Xiaobian's article "How to use Tensorboard and Transforms in Pytorch" will be helpful to everyone. At the same time, I hope everyone will support you more, pay attention to the industry information channel, and more relevant knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.