当前位置:网站首页>Mmseg - Mutli view time series data inspection and visualization
Mmseg - Mutli view time series data inspection and visualization
2022-07-05 13:22:00 【Irving. Gao】
Visualization function
First, we need to construct a function that can be used for visualization , We write it in tools/visualize_helper.py
Next , Convenient to call in other functions :
visualize_helper.py
import os
import cv2
import torch
import numpy as np
# visualize
label_colors = np.array([
[255, 255, 255],
[0, 0, 255],
[0, 255, 0],
[255, 0, 0],
[0, 255, 255],
])
def decode_segmap(mask):
rgb_mask_list = [mask.copy() for i in range(3)]
rgb = np.ones((mask.shape[0], mask.shape[1], 3)) # create an empty rgb image to save clorized masks
for idx, single_mask in enumerate(rgb_mask_list):
for idx_c, color in enumerate(label_colors):
rgb_mask_list[idx][single_mask == idx_c] = color[idx] # colorize pixels if the value is equal to the class num
rgb[:, :, idx] = rgb_mask_list[idx] # rgb = [r, g, b]
return rgb.astype(np.int)
def post_process(mask):
''' mask: [W, H] gt_mask: [W, H, 3] '''
gt_mask = decode_segmap(mask)
return gt_mask
def get_multi_view_imgs(multi_view_file_list, dataset_dir):
''' multi_view_imgs (Tensor): input images, shape is [B,6,3,H,W] '''
img_list = []
for i, img_path in enumerate(multi_view_file_list):
img = cv2.imread(os.path.join(dataset_dir, img_path))
img_list.append(img.astype('float32'))
num_temporal = int(len(img_list)/6)
surr_img_list = []
for idx in range(num_temporal):
surr_img_top = cv2.hconcat(img_list[0+idx*6:3+idx*6]) # Horizontal splicing
surr_img_btm = cv2.hconcat(img_list[3+idx*6:6+idx*6]) # Horizontal splicing
surr_img = cv2.vconcat([surr_img_top, surr_img_btm])
surr_img_list.append(surr_img)
surr_imgs = cv2.hconcat(surr_img_list)
return surr_imgs, num_temporal
def get_gt_imgs(gt):
''' gt (Tensor): input gt, shape is [B,H,W] '''
gt = gt.squeeze(0).squeeze(0)
gt = gt.cpu().numpy()
gt_img = post_process(gt)
return gt_img.astype('float32')
def save_train_imgs(img_metas, gt, save_name="multi_view_imgs"):
''' img_metas (list[dict]): List of image info dict gt (Tensor): input gt, shape is [B,H,W] '''
for idx, img_meta in enumerate(img_metas):
dataset_dir = "/".join(img_meta['filename'].split("/")[:-3])
file_list = img_meta['ori_filename']
surr_img, num_temporal = get_multi_view_imgs(file_list, dataset_dir)
gt_img = get_gt_imgs(gt)
surr_img = cv2.resize(surr_img ,(1600*num_temporal, 600))
gt_img = cv2.resize(gt_img, (300, 600))
print(surr_img.shape)
print(gt_img.shape)
all_img = cv2.hconcat([surr_img, gt_img]) # Horizontal splicing
cv2.imwrite(f"{
save_name}_bs{
idx}.jpg", all_img)
Visualize during training
stay forward_train
Functions can be realized by adding functions to functions :
def forward_train(self, img, img_metas, gt_semantic_seg):
#####################
# Data inspection and visualization during training
from tools.visualize_helper import save_train_imgs
save_train_imgs(img_metas, gt_semantic_seg)
###################
x = self.extract_feat(img)
losses = dict()
loss_decode = self._decode_head_forward_train(x, img_metas,
gt_semantic_seg)
losses.update(loss_decode)
if self.with_auxiliary_head:
loss_aux = self._auxiliary_head_forward_train(
x, img_metas, gt_semantic_seg)
losses.update(loss_aux)
return losses
Visualization
- On the left is the previous moment 6 A look around image , On the right is the current moment 6 A look around image , On the far right is BEV Of GT.
边栏推荐
- Lb10s-asemi rectifier bridge lb10s
- Actual combat simulation │ JWT login authentication
- 49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
- #从源头解决# 自定义头文件在VS上出现“无法打开源文件“XX.h“的问题
- UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe6 in position 76131: invalid continuation byt
- Talk about seven ways to realize asynchronous programming
- Shandong University Summer Training - 20220620
- 运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
- 不知道这4种缓存模式,敢说懂缓存吗?
- C object storage
猜你喜欢
leetcode:221. Maximum square [essence of DP state transition]
Backup and restore of Android local SQLite database
蜀天梦图×微言科技丨达梦图数据库朋友圈+1
什么是网络端口
“百度杯”CTF比赛 九月场,Web:SQL
The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched
Natural language processing series (I) introduction overview
What is a network port
"Baidu Cup" CTF competition in September, web:sql
Flutter draws animation effects of wave movement, curves and line graphs
随机推荐
Cf:a. the third three number problem
Can and can FD
RHCSA10
C# 对象存储
Natural language processing from Xiaobai to proficient (4): using machine learning to classify Chinese email content
前缀、中缀、后缀表达式「建议收藏」
mysql econnreset_Nodejs 套接字报错处理 Error: read ECONNRESET
JPA规范总结和整理
Go string operation
运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
Summary and arrangement of JPA specifications
个人组件 - 消息提示
OpenHarmony应用开发之Navigation组件详解
Developers, is cloud native database the future?
解决uni-app配置页面、tabBar无效问题
[deep learning paper notes] hnf-netv2 for segmentation of brain tumors using multimodal MR imaging
手把手带你入门Apache伪静态的配置
华为推送服务内容,阅读笔记
SAE international strategic investment geometry partner
【Hot100】34. Find the first and last positions of elements in a sorted array