← 开源
xwying

torchshow

Visualize PyTorch tensors with a single line of code.

Model DevelopmentInterpretabilityPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
713
Star
17
Fork
+0
本周
4
贡献者
创建于 2020-12-11 · 更新于 2026-09-28 · 今日第 14669 名
主要开发者
xwyinggenghisunShenhanQian

xwying/torchshow 排名第 14,669,有 713 个星标。

同类别比较

xwying/torchshow 排名第 14,669,此处有 8 个同类条目;BYU-PRISM/GEKKO 排名第 14,670。

同类别比较
名称排名指标
LC1332/Chinese-alpaca-lora14,658
语言:
Jupyter Notebook
星标数:
713
分叉数:
81
简介:
骆驼:A Chinese finetuned instruction LLaMA. Developed by 陈启源 @ 华中师范大学 & 李鲁鲁 @ 商汤科技 & 冷子昂 @ 商汤科技
clcarwin/sphereface_pytorch14,662
语言:
Python
星标数:
713
分叉数:
168
简介:
A PyTorch Implementation of SphereFace.
lavis-nlp/spert14,663
语言:
Python
星标数:
713
分叉数:
149
简介:
PyTorch code for SpERT: Span-based Entity and Relation Transformer
lonePatient/albert_pytorch14,664
语言:
Python
星标数:
713
分叉数:
148
简介:
A Lite Bert For Self-Supervised Learning Language Representations
BYU-PRISM/GEKKO14,670
语言:
Python
星标数:
712
分叉数:
120
简介:
GEKKO Python for Machine Learning and Dynamic Optimization
THUDM/ReST-MCTS14,672
语言:
Python
星标数:
712
分叉数:
52
简介:
ReST-MCTS*: LLM Self-Training via Process Reward Guided Tree Search (NeurIPS 2024)
aimclub/FEDOT14,674
语言:
Python
星标数:
712
分叉数:
97
简介:
Automated modeling and machine learning framework FEDOT
developer0hye/Yolo_Label14,676
语言:
C++
星标数:
712
分叉数:
140
简介:
GUI for marking bounded boxes of objects in images for training neural network YOLO
关键参数与规格
关键参数与规格
参数值
语言Python
类别Model Development
子类别Interpretability
星标数713
分叉数17
贡献者4
创建日期2020-12-11
更新日期2026-09-28
1 天星标数0
7 天星标数0
排名14,669
上次排名14,518
排名变化-151
7 天星标排名14,592
上次 7 天星标排名14,600
7 天星标排名变化8
总星标排名14,684
上次总星标排名14,657
总星标排名变化-27
国家USA
README 摘录

It is designed to help debugging Computer Vision project. Torchshow automatically infers the type of a tensor such as RGB images, grayscale images, binary masks, categorical masks (automatically apply color palette), etc. and perform necessary unnormalization if needed. **Supported Type:** [x] RGB Images [x] Grayscale Images [x] Binary Mask [x] Categorical Mask (Integer Labels) [x] Multiple Images [x] Videos [x] Multiple Videos [x] Optical Flows (powered by flow_vis) What's New in v0. 2 Fixed the version comparison bugs in

function (#24). Support more data dtype for pytorch tensors. Installation Install from PyPI: Alternatively, you can install directly from this repo to test the latest features. Basic Usage The usage of TorchShow is extremely simple. Simply import the package and visualize your data in one line: If you work on a headless server without display. API References Please check this page for detailed API references. Examples Table of Contents Visualizing Image Tensor Visualizing Mask Tensors Visualizing Batch of Tensors Visualizing

Channels in Feature Maps Visualizing Multiple Tensors with Custom Layout. Examine the pixel with rich information. Visualizing Tensors as Video Clip Display Video Animation in Jupyter Notebook Visualizing Optical Flows Change Channel Order (RGB/BGR) Change Unnormalization Presets Overlay Visualizations 1. Visualizing Image Tensor Visualizing an image-like tensor is not difficult but could be very cumbersome. You usually need to convert the tensor to numpy array with proper shapes. In many cases images were normalized during dataloader, which means

that you have to unnormalize it so it can be displayed correctly. If you need to frequently verify what your tensors look like, TorchShow is a very helpful tool. | TorchShow does the conversion automatically. This can be easily done using TorchShow. | TorchShow automatically apply color palletes during visualization. Visualizing Batch of Tensors When the tensor is a batch of images, TorchShow will automatically create grid layout to visualize them. It is also possible to manually control the number of rows

and columns. Visualizing Feature Maps If the input tensor has more than 3 channels, TorchShow will visualize each of the channel similar to batch visualization. This is useful to visualize a feature map. Visualizing Multiple Tensors with Custom Layout. TorchShow has more flexibility to visualize multiple tensor using a custom layout. To control the layout, put the tensors in list of list as an 2D array. The following example will create a 2 x 3 grid layout. It is worth

mentioning that there is no need to fill up all the places in the grid. The following example visualizes 5 tensors in a 2 x 3 grid layout. Examine the pixel with richer information. Since , TorchShow allows you to get richer information from a pixel you are interested by simply hovering your mouse over that pixel. This is very helpful for some types of tensors such as Categorical Mask and Optical Flows. Currently, Torchshow displays the following information: : Visualization Mode

. , : The pixel location of the mouse cursor. **Note: if the information is not showing on the status bar, try to

常见问题

记录了多少星标和分叉?

xwying/torchshow 有 713 个星标和 17 个分叉。

仓库排名是多少?

xwying/torchshow 排名第 14,669。

记录的语言和类别是什么?

xwying/torchshow 有 713 个星标,语言为 Python,类别为 Model Development。

哪个仓库排名最接近?

xwying/torchshow 与 BYU-PRISM/GEKKO 比较,后者排名第 14,670,有 712 个星标。

README


Torchshow visualizes your data in one line of code. It is designed to help debugging Computer Vision project.

Torchshow automatically infers the type of a tensor such as RGB images, grayscale images, binary masks, categorical masks (automatically apply color palette), etc. and perform necessary unnormalization if needed.

Supported Type:

  • [x] RGB Images
  • [x] Grayscale Images
  • [x] Binary Mask
  • [x] Categorical Mask (Integer Labels)
  • [x] Multiple Images
  • [x] Videos
  • [x] Multiple Videos
  • [x] Optical Flows (powered by flow_vis)

What's New in v0.5.2

  • Fixed the version comparison bugs in set_window_title function (#24).
  • Support more data dtype for pytorch tensors.

See the complete changelogs.

Installation

Install from PyPI:

pip install torchshow

Alternatively, you can install directly from this repo to test the latest features.

pip install git+https://github.com/xwying/torchshow.git@master

Basic Usage

The usage of TorchShow is extremely simple. Simply import the package and visualize your data in one line:

import torchshow as ts
ts.show(tensor)

If you work on a headless server without display. You can use ts.save(tensor) command (since version 0.3.2).

import torchshow as ts
ts.save(tensor) # Figure will be saved under ./_torchshow/***.png
ts.save(tensor, './vis/test.jpg') # You can specify the save path.

API References

Please check this page for detailed API references.

Examples

Table of Contents

1. Visualizing Image Tensor

Visualizing an image-like tensor is not difficult but could be very cumbersome. You usually need to convert the tensor to numpy array with proper shapes. In many cases images were normalized during dataloader, which means that you have to unnormalize it so it can be displayed correctly.

If you need to frequently verify what your tensors look like, TorchShow is a very helpful tool.

Using Matplotlib Using TorchShow
The image tensor has been normalized so Matplotlib cannot display it correctly. TorchShow does the conversion automatically.

2. Visualizing Mask Tensors

For projects related to Semantic Segmentation or Instance Segmentation, we often need to visualize mask tensors -- either ground truth annotations or model's prediction. This can be easily done using TorchShow.

Using Matplotlib Using TorchShow
Different instances have same colors. Some categories are missing. TorchShow automatically apply color palletes during visualization.

3. Visualizing Batch of Tensors

When the tensor is a batch of images, TorchShow will automatically create grid layout to visualize them. It is also possible to manually control the number of rows and columns.

4. Visualizing Feature Maps

If the input tensor has more than 3 channels, TorchShow will visualize each of the channel similar to batch visualization. This is useful to visualize a feature map.

5. Visualizing Multiple Tensors with Custom Layout.

TorchShow has more flexibility to visualize multiple tensor using a custom layout.

To control the layout, put the tensors in list of list as an 2D array. The following example will create a 2 x 3 grid layout.

ts.show([[tensor1, tensor2, tensor3],
         [tensor4, tensor5, tensor6]])

It is worth mentioning that there is no need to fill up all the places in the grid. The following example visualizes 5 tensors in a 2 x 3 grid layout.

ts.show([[tensor1, tensor2],
         [tensor3, tensor4, tensor5]])

6. Examine the pixel with richer information.

Since v0.4.1, TorchShow allows you to get richer information from a pixel you are interested by simply hovering your mouse over that pixel. This is very helpful for some types of tensors such as Categorical Mask and Optical Flows.

Currently, Torchshow displays the following information:

  • Mode: Visualization Mode.
  • Shape: Shape of the tensor.
  • X, Y: The pixel location of the mouse cursor.
  • Raw: The raw tensor value at (X, Y).
  • Disp: The display value at (X, Y).

Note: if the information is not showing on the status bar, try to resize the window and make it wider.

This feature can be turned off by ts.show_rich_info(False).

7. Visualizing Tensors as Video Clip

Tensors can be visualized as video clips, which very helpful if the tensor is a sequence of frames. This can be done using show_video function.

ts.show_video(video_tensor)

It is also possible to visualize multiple videos in a custom grid layout.

8. Display Video Animation in Jupyter Notebook

TorchShow visualizes video clips as an matplotlib.func_animation object and may not display in a notebook by default. The following example shows a simple trick to display it.

import torchshow as ts
from IPython.display import HTML

ani = ts.show_video(video_tensor)
HTML(ani.to_jshtml())

9. Visualizing Optical Flows

TorchShow support visualizing optical flow (powered by flow_vis). Below is a demostration using a VSCode debugger remotely attached to a SSH server (with X-server configured). Running in a Jupyter Notebook is also supported.

10. Change Channel Order (RGB/BGR)

By default tensorflow visualize image tensor in the RGB mode, you can switch the setting to BGR in case you are using opencv to load the image.

ts.set_color_mode('bgr')

11. Change Unnormalization Presets

The image tensor may have been preprocessed with a normalization function. If not specified, torchshow will automatically rescale it to 0-1.

To change the preset to imagenet normalization. Use the following code.

ts.show(tensor, unnormalize='imagenet')

To use a customize mean and std value, use the following command.

ts.set_image_mean([0., 0., 0.])
ts.set_image_std([1., 1., 1.])

Note that once this is set, torchshow will use this value for the following visualization. This is useful because usually only a single normalization preset will be used for the entire project.

12. Overlay Visualizations

In Computer Vision project there are many times we will be dealing with different representations of the scene, including but not limited to RGB image, depth image, infrared image, semantic mask, instance mask, etc. Sometimes it will be very helpful to overlay these different data for visualization. Since v0.5.0, TorchShow provides a very useful API ts.overlay() for this purpose.

In the below example we have an RGB image and its corresponding semantic mask. Let's first check what they look like using TorchShow.

import torchshow as ts
ts.show(["example_rgb.jpg", "example_category_mask.png"])

Now I would like to overlay the mask on top of the RGB image to gain more insights, with TorchShow this can be easily done with one line of code.

import torchshow as ts
ts.overlay(["example_rgb.jpg", "example_category_mask.png"], alpha=[1, 0.6])

排名相邻
同类项目