Skip to main content

A professional tool for cleaning duplicate or near-duplicate image frames using perceptual hashing and embeddings.

Project description

CleanFrames

CleanFrames is a Python library designed to clean and summarize video frames efficiently using embedding models and clustering techniques. It provides tools to process video frames, remove duplicates or near-duplicates, and generate concise reports and visualizations.

Key Features

  • Support for multiple embedding models to represent frames.
  • Various clustering methods to group similar frames.
  • Caching mechanisms to optimize performance.
  • Visualization tools to inspect clusters and embeddings.
  • Cleaning functions to remove redundant frames.
  • Reporting capabilities to summarize cleaning results.
  • Two main classes: CleanFrame for standard processing and CleanFrame_optimized for enhanced performance.

Installation

To install CleanFrames, you can clone the repository and install the required dependencies. (Note: The exact installation commands depend on your setup and are not specified in the code.)

git clone <repository-url>
cd cleanframes
pip install -r requirements.txt

Usage

Using CleanFrame

from cleanframes import CleanFrame

# Initialize with video path and parameters
cf = CleanFrame(
    video_path='path/to/video.mp4',
    embedding_model='clip-ViT-B-32',
    clustering_method='kmeans',
    cache_folder='cache/',
    verbose=True
)

# Load video frames
cf.load_frames()

# Generate embeddings for frames
cf.embed_frames()

# Cluster embeddings to group similar frames
cf.cluster_frames()

# Clean frames by removing duplicates or near-duplicates
cleaned_frames = cf.clean_frames()

# Generate report of cleaning
cf.report()

# Visualize clusters or embeddings
cf.visualize()

Using CleanFrame_optimized

from cleanframes import CleanFrame_optimized

# Initialize with video path and parameters
cf_opt = CleanFrame_optimized(
    video_path='path/to/video.mp4',
    embedding_model='clip-ViT-L-14',
    clustering_method='dbscan',
    cache_folder='cache_optimized/',
    verbose=True
)

# Load video frames with optimized method
cf_opt.load_frames()

# Generate embeddings using optimized pipeline
cf_opt.embed_frames()

# Cluster embeddings
cf_opt.cluster_frames()

# Clean frames
cleaned_frames_opt = cf_opt.clean_frames()

# Generate report
cf_opt.report()

# Visualize results
cf_opt.visualize()

Supported Embedding Models

CleanFrames supports various embedding models to convert video frames into numerical representations, including but not limited to:

  • CLIP models such as clip-ViT-B-32 and clip-ViT-L-14
  • Other models can be integrated as per user requirements.

Clustering Methods

The library provides different clustering algorithms to group similar frames:

  • KMeans clustering
  • DBSCAN clustering
  • Other clustering methods can be added or customized.

Caching

To improve performance, CleanFrames supports caching of intermediate results such as extracted frames and computed embeddings. Users can specify a cache folder where these results are stored and reused.

Visualization

CleanFrames includes visualization tools to help users inspect the clustering results and embedding distributions. This aids in understanding the cleaning process and verifying the quality of frame grouping.

Cleaning and Reporting

The cleaning functions remove redundant frames based on clustering results and embedding similarity. After cleaning, a report is generated summarizing the number of frames processed, removed, and retained, providing insights into the cleaning effectiveness.


For more detailed information and advanced usage, please refer to the source code and examples provided in the repository.

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

cleanframes-0.3.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

cleanframes-0.3.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file cleanframes-0.3.3.tar.gz.

File metadata

  • Download URL: cleanframes-0.3.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for cleanframes-0.3.3.tar.gz
Algorithm Hash digest
SHA256 d3110318fc9ecd087b7026cf1c0ff6b8cf9b600f8b8582694909ed04bd2de159
MD5 d0788356f11a3470431a171f5883d56e
BLAKE2b-256 487ee713eafd45de5d0dd4db0e026f794d13b232e43905a6c5a5cbdcb5f2e21c

See more details on using hashes here.

File details

Details for the file cleanframes-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: cleanframes-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for cleanframes-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b4366d0643aebee506d1759719ae099edac3d50a24fa1fc34658c09277f2d596
MD5 d19af05360b035156699cd2f1063d03b
BLAKE2b-256 eca5ddce9360e4d5e2c5ac2a8663173e7f436375f055c4a0071ddc3a994c29f4

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