使用するvisdomシンプル

公式サイト:https://github.com/facebookresearch/visdomは
入門チュートリアル:http://www.ainoobtech.com/pytorch/pytorch-visdom.html

インストール:visdomのインストールピップ
使用を:visdom

以下のコードの下のフォルダ内のすべての画像の可視化

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2019-09-07 16:20
# @Author  : wangbin
# @FileName: visdom.py

import argparse
import cv2
import glob
import imgaug.augmenters as iaa
import os
from tqdm import tqdm
import visdom
import numpy as np

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('path', type=str, help='path to image')
    args = parser.parse_args()
    path = args.path
    pattern = os.path.join(path, '**', '*.jpg')
    img_paths = glob.glob(pattern, recursive=True)

    imgs = []
    cnt = 0
    for img_path in tqdm(img_paths):
        img = cv2.imread(img_path)
        imgs.append(img[:, :, ::-1])
        cnt += 1
        if cnt > 100:
            break
    resize_aug = iaa.Resize({"height": 224, "width": 448})
    resize_imgs = resize_aug.augment_images(imgs)
    resize_imgs = np.transpose(resize_imgs, (0, 3, 1, 2))
    print(resize_imgs.shape)
    vis = visdom.Visdom(env='heatmaps')
    vis.images(resize_imgs, nrow=5, win='heatmaps', opts={'title': 'headmaps'})

おすすめ

転載: www.cnblogs.com/nowgood/p/visdom-base.html