torch_test/test_tb.py

19 lines
537 B
Python
Raw Normal View History

2023-07-31 19:13:51 +08:00
from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Image
writer = SummaryWriter('logs')
# image_path = r"C:\Users\12642\Desktop\Picture\dataset\train\ants\0013035.jpg"
image_path = r"C:\Users\12642\Desktop\Picture\dataset\train\ants\6240338_93729615ec.jpg"
img_PIL = Image.open(image_path)
img_array = np.array(img_PIL)
print(type(img_array))
print(img_array.shape)
writer.add_image("train", img_array, 1, dataformats='HWC')
for i in range(100):
writer.add_scalar("y=2x", 2*i, i)
writer.close()