Skip to main content

A visualization tool for temporal action localization

Project description

VISTAL: A visualization tool for temporal action localization

A lightweight tool for visualizing temporal action localization results. It generates .ass subtitle files containing timelines for videos.

Installation

pip install vistal

Tutorial

Import the library

from vistal import vistal, ColourScheme, Colour

By now this tool supports non-overlapping localization results, i.e. action segmentation results. Pack these temporal labels into a list of tuple(start, end, label_id), for example:

prediction = [
    # start, end, label_id
    ( 0,     2,     0),
    ( 2,     3,     1),
    ( 3,     5,     2),
    ( 5,     6,     3),
]

start and end are integers or floats in seconds, and label_id are integer IDs for each action.

And the actual temporal label, for example, is

ground_truth = [
    ( 0,     1,     0),
    ( 1,     1.8,   3),
    ( 1.8,   3.7,   1),
    ( 3.7,   4.5,   3),
    ( 4.5,   6,     2),
]

And another dict maps from label IDs to their names:

label_names = {
    0: 'foo',
    1: 'bar',
    2: 'baz',
    3: 'background',
}

Now we create a colour scheme to determine what colour to represent each action:

colour_scheme = ColourScheme(
    colours=[
        Colour(b=255, g=0,   r=0),
        Colour(b=0,   g=255, r=0),
        Colour(b=0,   g=0,   r=255),
        Colour(alpha=255),
    ]
)

Or, we can generate some random colours. The last action is background, therefore it should be transparent.

colour_scheme = ColourScheme(n_colours=4, transparent_id=3)

Suppose the video resolution is 1280x720, and it lasts for 6 seconds:

display_width = 1280
display_height = 720
video_duration = 6

The main function vistal creates a subtitle object:

sub = vistal(
    temporal_list_dict={
        'gt  ': ground_truth,
        'pred': prediction
    },
    label_names=label_names,
    colour_scheme=colour_scheme,
    video_duration=video_duration,
    display_width=display_width,
    display_height=display_height,
    timeline_height=72,
    font_size=72,
    font_name='Ubuntu Mono',
    show_legend=True,
)

Save to an .ass file:

sub.save('tutorial.ass')

Finally, play the video and load the subtitle to the player. Make sure your video player supports .ass subtitle, for example VLC media player and PotPlayer. Here is how it looks like on a blank video:

For another complete example, see example.py.

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

vistal-0.0.2.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

vistal-0.0.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file vistal-0.0.2.tar.gz.

File metadata

  • Download URL: vistal-0.0.2.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for vistal-0.0.2.tar.gz
Algorithm Hash digest
SHA256 125fa40f8cebfc17fdb3b64fc8bcc7b31239080c7105a3d57c3538d333004cfc
MD5 b7de30465e644e1495e293ae0b780833
BLAKE2b-256 3fdfb39b9077626cc0a26ee2db4f29f430de45a5b863b1c0ac28f497c4276b95

See more details on using hashes here.

File details

Details for the file vistal-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: vistal-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for vistal-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e94edfb07cfb4eda1af0c7261a97de9aea52b1dd0f9955006dc740d07baa88d
MD5 5f04dad458643dbe7efb8e973eae567f
BLAKE2b-256 1994bc81ba19b80526083b1852b43f4de5b8a3f0040cb121f267600b89aada96

See more details on using hashes here.

Supported by

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