Skip to main content

Interactyive python viewers

Project description

PyViewer

Toolbar Viewer

Pyviewer is a python library for easily visualizing NumPy arrays and PyTorch tensors.

Components

single_image_viewer.py

A viewer for showing single fullscreen images or line plots without other UI elements. Runs in a separate process and remains interactive even if the main process is suspended (e.g. in a debugger). Great for interactively looking at intermediate values of complex ML/CG/CV pipelines.

Usage:

from pyviewer import single_image_viewer as siv
siv.draw(img_chw=np.random.randn(3,64,64))
siv.plot(np.sin(2*np.pi*np.linspace(0, 1, 10_000)))

toolbar_viewer.py

A viewer that shows ImGui UI elemets on the left, and a large image on the right. Runs in the main process, but supports visualizing torch tensors directly from GPU memory (unlike single_image_viewer).

Other features

  • Bundles a custom build of PyImGui with plotting support (via ImPlot)
  • Dynamically rescalable user interface
  • Window resizing to integer multiple of content resolution
  • Pan and zoom of the main image

Installation

pip install pyviewer

Usage

See examples/demo.py for a usage example.

API highlights

PannableArea::screen_to_uv_xform
Maps absolute screen coordinates (e.g. imgui.get_mouse_pos()) to transformed image UVs, useful for picking etc.

PannableArea::uv_to_screen_xform
Maps image UVs to absolute screen coordinates. Useful when combined with imgui's draw lists.

PannableArea::get_visible_box_image()
Returns the top-left and bottom-right UV coordinates of the currently visible image region.

PannableArea::get_hovered_uv_image()
Returns the image UVs that lie under the mouse cursor.

PannableArea::get_hovered_uv_canvas()
Returns the canvas UVs that lie under the mouse cursor. Differs from the image UVs in case of non-matching image and window aspect ratios.

from pyviewer.single_image_viewer import draw; draw(img_chw=...)
One-liner that opens a new viewer (unless already open) and draws the provided image. Runs in a separate process and thus works even when execution is halted by e.g. a debugger.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyviewer-1.6.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

pyviewer-1.6.0-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file pyviewer-1.6.0.tar.gz.

File metadata

  • Download URL: pyviewer-1.6.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyviewer-1.6.0.tar.gz
Algorithm Hash digest
SHA256 9b6d550f9ebe0409c39685a434ff899c602dcb1fc083a29effe9dd70b8b63c7e
MD5 3a66f42ffbb028786c1f02d317a69087
BLAKE2b-256 8bb521a6a421c22f6388d0d3678666ac861f0543e2b35abadd382477e55f4efe

See more details on using hashes here.

File details

Details for the file pyviewer-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: pyviewer-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyviewer-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e019d494322c217891962b1734681e35e38fdccc4f70f9dabe9dda8ead57aaec
MD5 f3e35dbc1d97989d0dc07fa586442c2d
BLAKE2b-256 18103ba0993be4532d5ca47221bb9768e6ec3aef7a2ddb11e5029d40c453a5d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page