Skip to main content

Distant Viewing Toolkit for the Analysis of Visual Culture

PyPI pyversions PyPI version shields.io PyPI status shields.io DOI

The Distant Viewing Toolkit is a Python package that facilitates the computational analysis of still and moving images. It takes a video, an image or a directory of images and writes a set of tables about it, each a parquet file: the shots of a video, the faces and heads in each frame, image embeddings, the words spoken, and more. Each table is made by one annotator, and the annotators are listed below.

Version 2 of the toolkit is a rewrite, and nothing written for version 1 runs on it.

More information about the toolkit and project is available on the following pages:

If you have any trouble using the toolkit, please open a GitHub issue. If you have additional questions or are interested in collaborating, please contact us at tarnold2@richmond.edu and ltilton@richmond.edu.

Install

The toolkit needs Python 3.13, and ffmpeg and ffprobe on the path:

pip install "dvt[all]"

The extras choose which annotators can run. video brings the annotators that read the picture, face the face annotator and the tracks, yolo the head detector, and audio the annotators that read the sound. all brings every one. Without an extra the package is dvt.tools alone, which reads a media file without a model.

The annotators load their models from one directory, and the models are downloaded once, before anything is annotated:

dvt models fetch

All of them come to about 12 GB. --annotators frames,dino2,face fetches only what those annotators load, and dvt models check lists which models are there. The directory is ~/.cache/dvt unless --models or the environment variable DVT_MODELS names another. MODELS.md says what the directory holds, where each model comes from and under what terms it is used.

Use

dvt film.mp4 --out out

Under out/ this leaves annotations/film/ with the tables, audio/ with the sound taken from the video, frames/film/ with the saved frames and stems/ with the separated sound. --annotators a,b,c runs only those named, and --list prints every annotator, what it writes and what it reads.

An image, or a directory of images, is given the same way. Images below says what is made of one.

The same from Python, where the tables come back as polars data frames by name:

import dvt

tables = dvt.annotate("film.mp4", out="out", annotators=["metadata", "frames", "shots"])
tables["shots"]

With no out nothing is kept but the tables returned, and with no annotators every one that fits the input runs. models names the model directory.

Images

dvt poster.jpg --out out
dvt posters/ --out out --annotators dino2,face

A path is taken as an image when it ends in .jpg, .jpeg, .png, .webp, .bmp, .tif or .tiff, and as a set of images when it is a directory. Every image under the directory is read, however deep, in the order of their sorted paths. Anything else is read as a video.

Five annotators read a single picture, and they are the ones an image has: dino2, siglip2, siglip2_base, face and yolo. All five run when --annotators names none, so the models of all five have to be in the model directory; dvt models fetch --annotators dino2,face brings only those of the two. Naming any other annotator for an image is an error.

The tables go to out/annotations/poster/ for the image poster.jpg and to out/annotations/posters/ for the directory posters/. The images of a directory share one set of tables:

Table Rows
images.parquet one an image: its path, width and height
dino2.parquet one an image, with its embedding
siglip2.parquet one an image, with its embedding
siglip2_base.parquet one an image, with its embedding
face.parquet one a face found, with its box and its embedding
yolo.parquet one a head found, with its box

Each table has a path column where that of a video has frame. The path is stated from the directory given, as in 1950s/poster_012.jpg, and a single image is stated by its file name. An image that cannot be read stays in images.parquet with no width or height and has no row in the others. The images need not be of one size.

From Python:

import dvt

tables = dvt.annotate("posters/", annotators=["dino2", "face"])
tables["images"]
tables["dino2"]

Annotators

Annotator Writes What it holds
metadata metadata.parquet the frame size, the crop, the aspect and the language
letterbox letterbox.parquet the black bars around the picture
chroma chroma.parquet colour or black and white
chapters chapters.parquet the chapters in the file
subtitles subtitles.parquet the text subtitles in the file
frames frames.parquet one row a frame, with the shot boundary TransNetV2 gives
shots shots.parquet the frames cut into shots, and what each shot looks like
frames_r720 frames/ frames of each shot saved as images
dino2 dino2.parquet DINOv2 embeddings of the sampled frames
siglip2 siglip2.parquet SigLIP2 embeddings of the sampled frames
siglip2_base siglip2_base.parquet the same from the smaller SigLIP2 model
face face.parquet SCRFD face detection and an ArcFace embedding, every frame
yolo yolo.parquet the heads detected in every frame
tracks tracks.parquet head and face tracks within shots, one embedding a track
audioseg audioseg_intervals.parquet the sound separated into stems, and where the speech is
words words.parquet the words spoken, each with its time
praat praat.parquet phonetic measurement of the speech, frame by frame
laughter laughter.parquet laughter heard between lines

metadata runs first, and the others are checked against what it records. tracks reads the tables of shots, face and yolo. words, praat and laughter read the speech that audioseg separates.

audioseg stops unless it has a CUDA device, so words, praat and laughter need one too. The annotators of the video and face extras also run on a CPU, more slowly.

Notebooks

The colab links open the notebooks in this repository. The second tutorial uses version 2 of the toolkit, and no longer follows the slides and the chapter linked beside it, which study two sitcoms of the 1960s. The first was written for version 1.1.0 and installs that release.

If you are interested in learning more about application of computer vision and the distant viewing toolkit to humanities applications, we offer a self-guided tutorial through the following Google Colab notebooks. These can be run for free by anyone with a Google account:



NEH The Distant Viewing Toolkit is supported by the National Endowment for the Humanities through a Digital Humanities Advancement Grant.



Citation

If you make use of the toolkit in your work, please cite the relevant papers describing the tool and its application to the study of visual culture:

@article{,
  title   = "Distant Viewing: Analyzing Large Visual Corpora",
  author  = "Arnold, Taylor B and Tilton, Lauren",
  journal = "Digital Scholarship in the Humanities",
  year    = "2019",
  doi     = "10.1093/digitalsh/fqz013",
  url     = "http://dx.doi.org/10.1093/digitalsh/fqz013"
}
@article{,
  title   = "Visual Style in Two Network Era Sitcoms",
  author  = "Arnold, Taylor B and Tilton, Lauren and Berke, Annie",
  journal = "Cultural Analytics",
  year    = "2019",
  doi     = "10.22148/16.043",
  url     = "http://dx.doi.org/10.22148/16.043"
}

License

The toolkit is released under the MIT license; see LICENSE. The models the annotators load, and one of the libraries that run them, have terms of their own, and MODELS.md gives them model by model. Two matter to anyone whose use is not research or not open source:

  • The face annotator loads the insightface buffalo_l models. The insightface code is under the MIT license, but its authors make the models "available for non-commercial research purposes only".
  • The yolo annotator runs on ultralytics, which is under the AGPL-3.0 license unless a license is bought from Ultralytics, and the head detector it loads was trained from an ultralytics model and is under the AGPL-3.0 too. ultralytics is installed only by the yolo and all extras.

The aligners that time the words of French, German, Spanish and Italian speech are under CC BY-NC 4.0.

Contributing

Contributions, including bug fixes and new features, to the toolkit are welcome. When contributing to this repository, please first discuss the change you wish to make via a GitHub issue or email with the maintainers of this repository before making a change. Small bug fixes can be given directly as pull requests.

Metadata

Release files for dvt 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dvt 2.0.2
File Size Uploaded Provenance Actions
dvt-2.0.2.tar.gz 358.8 kB Without provenance Details for dvt-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dvt 2.0.2
File Interpreter ABI Platform Actions
dvt-2.0.2-py3-none-any.whl Python 3 none any Details for dvt-2.0.2-py3-none-any.whl

Total release size: 483.8 kB

Release files / dvt-2.0.2.tar.gz

Download URL dvt-2.0.2.tar.gz
Size 358.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3bc478ca2f06b641e8098a7ca6b41a5f1c91e1d4c7f4d4da1726d3a724f8f435
BLAKE2b-256 checksum
How to use checksums
d3fb781f3ba36a04f7f20ced2f44b1bd4e9c635f0da5c37b54644e8426c15c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dvt-2.0.2-py3-none-any.whl

Download URL dvt-2.0.2-py3-none-any.whl
Size 125.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fa4af9427ed1b7a1e96845189862f97d3f394e8b0b157c9784059a6e39be816
BLAKE2b-256 checksum
How to use checksums
d447c4a9c41ac1c2fc97f48acd55e144a33ff2916cd8204d4cbe4ef621ebea49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for dvt 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page