Skip to main content

A package for video and image processing with captioning capabilities

Project description

vistopics

vistopics (Topic Visualization for Visuals) is a Python package for video and image processing, offering features such as:

  • Frame extraction from videos.
  • Caption generation for images using OpenAI.
  • Video scraping and organization.
  • Duplicate frame reduction with efficient algorithms.
  • Image scraping and captioning from article URLs.

This package is designed for developers, researchers, and data scientists working on media processing, visualization, or clustering tasks.


Installation

Install vistopics from PyPI using:

pip install vistopics

If you plan to use FastDup for duplicate frame detection, install with:

pip install vistopics[fastdup]

Alternatively, install it directly from the source:

git clone https://github.com/aysedeniz09/VisTopics
cd VisTopics
pip install .

Note: The repository name on GitHub is VisTopics (capitalized), but the package name and Python import name are lowercase vistopics.


Features

Option A: Video-Based Pipeline

  1. Scrape and download videos from URLs
  2. Extract frames from the downloaded videos
  3. Reduce duplicate frames with FastDup
  4. Generate captions for the cleaned set of frames

Option B: Image URL-Based Pipeline

  1. Download images from a CSV containing article or image URLs
  2. Generate captions for the images

Requirements

The following Python libraries are required:

  • openai>=1.50.0
  • opencv-python>=4.9.0,<4.10
  • opencv-python-headless>=4.9.0,<4.10
  • pandas>=2.0.3,<2.2
  • requests>=2.28.0
  • yt-dlp>=2024.12.6
  • gradio>=3.36.0
  • aiofiles>=23.0
  • pydantic>=2.8
  • urllib3>=1.26
  • beautifulsoup4>=4.12
  • tqdm>=4.66

Note: To use FastDup-based functionality (limiting_frames), you must additionally install:

pip install vistopics[fastdup]

Install base dependencies with:

pip install -r requirements.txt

Usage

Option A: Video-Based Pipeline

1. Video Scraping

from vistopics import video_download

video_download(
    input_df_path="test_data.csv",
    output_df_path="cleaned_videos.csv",
    output_dir="downloaded_videos",
    link_column="Link",
    title_column="Page Name"
)

2. Frame Extraction

from vistopics import extract_frames

extract_frames(
    videofolder="downloaded_videos",
    images_folder="images",
    frame_rate=1
)

3. Duplicate Frame Reduction

from vistopics import limiting_frames

limiting_frames(
    path="images",
    output_file="reduced_frame_list.csv",
    ccthreshold=0.8
)

This step requires the optional fastdup dependency:

pip install vistopics[fastdup]

4. Caption Generation

from vistopics import get_caption

get_caption(
    mykey="your-open-ai-api-key",
    path_in="images",
    captions_file="captions_file.csv",
    model="gpt-4o-mini"
)

Option B: Image URL-Based Pipeline

1. Download Images from URLs

from vistopics import download_images_from_url

download_images_from_url(
    input_csv="urls.csv",              # must have a 'url' column
    output_csv="captions.csv",
    image_dir="images"
)

2. Caption Generation

from vistopics import get_caption

get_caption(
    mykey="your-open-ai-api-key",
    path_in="images",
    captions_file="captions_file.csv",
    model="gpt-4o-mini"
)

License

This project is licensed under the MIT License.


Contributing

We welcome contributions! If you'd like to contribute:

  1. Fork the repository
  2. Create a feature branch:
git checkout -b feature-name
  1. Commit your changes:
git commit -m "Add new feature"
  1. Push to the branch:
git push origin feature-name
  1. Open a pull request

For a full research example using vistopics, see:
Lokmanoglu, A. D., & Walter, D. (2025, accepted). Topic Modeling of Video and Image Data: A Visual Semantic Unsupervised Approach. Communication Methods and Measures. Replication Code on GitHub


Contact

If you have any questions or feedback, feel free to contact:

Ayse Lokmanoglu & Dror Walter GitHub: https://github.com/aysedeniz09/VisTopics


Acknowledgments

The vistopics package incorporates and builds upon the work of the following projects and resources:

  • OpenAI – Provided API access used in the image captioning feature and support through the Researcher Access Program.
  • FastDup – Enabled efficient duplicate frame detection within the video frame processing workflow.
  • OpenCV – Supplied core video and image processing functionality used throughout the package.

We thank the developers and maintainers of these tools for making their work publicly available and for their contributions to the open-source community.

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

vistopics-0.1.8.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vistopics-0.1.8-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file vistopics-0.1.8.tar.gz.

File metadata

  • Download URL: vistopics-0.1.8.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for vistopics-0.1.8.tar.gz
Algorithm Hash digest
SHA256 eba04dfcdfd0ae5489f1c8cf82ce8e172c060367735d5ae9d2f6c5672ee491c1
MD5 f1f7374b9b994c2b4f7ca8ffc0329567
BLAKE2b-256 bd179326a9158d19fb23853114af70d7cd9addaa690fdd4fd999d3bb39a927dc

See more details on using hashes here.

File details

Details for the file vistopics-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: vistopics-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for vistopics-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6a1545328164bab19c814933fcd32504b7ea57b0745c1e2d688d8e5164ac42b9
MD5 d0a9a03d385f2446e42b25d32df7ea3d
BLAKE2b-256 e297fa8bcc5173805594a5b33d42c7cc2c86f8ac80dd6e1f5391cc49adb72fdd

See more details on using hashes here.

Supported by

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