ai-forever
DataProcessingFramework
Python

Framework for processing and filtering datasets

Last updated Mar 5, 2026
31
Stars
3
Forks
3
Issues
0
Stars/day
Attention Score
11
Language breakdown
Python 100.0%
Files click to expand
README

DataProcessingFramework

DPF - a framework for processing and filtering multimodal datasets.

Installation

Install with pip:

pip install git+https://github.com/ai-forever/DataProcessingFramework
Install from repository:
git clone https://github.com/ai-forever/DataProcessingFramework cd DataProcessingFramework pip install .

Extra requirements: filters, dev, llava, video_llava, lita

To install extra requirements run: pip install .[dev,filters] (insert needed extra requirements)

Overview

Framework supports following features:

  • Reading datasets
  • Filtering datasets and calculating metrics using different models and algorithms. Full list of filters can be found there
  • Effectively transforming data such as videos and images
  • Data filtering and transformation pipelines
  • Converting datasets to other formats
  • Validating datasets
  • Support for various file systems (local, s3)
DPF allows you to easily filter datasets and add new metadata. You can use various filters and transformations on your data, create pipelines from them and run them efficiently and quickly. Basic code examples for filtering data are given below:

Basic example

Check out basic usage for more info about DPF's API.

This is a simple example for image deduplication and image aesthetic quality prediction. All filters in DPF extract attributes from the dataset's data and write them into metadata. You can then use these attributes to filter the data according to your needs.

from DPF import ShardsDatasetConfig, DatasetReader

creating config for dataset

config = ShardsDatasetConfig.frompathand_columns( 'examples/example_dataset', imagenamecol='image_name', text_col="caption" )

reading dataset's metadata

reader = DatasetReader() processor = reader.readfromconfig(config)

from DPF.filters.images.hash_filters import PHashFilter datafilter = PHashFilter(simhashsize=8, workers=16) # creating PHash filter

calculating PHash

new column "imagephash8" will be added

processor.applydatafilter(datafilter)

print('Dataset length before deduplication:', len(processor)) processor.filterdf(~processor.df['imagephash_8'].duplicated()) print('Dataset length after deduplication:', len(processor))

from DPF.filters.images.aestheticimprovedfilter import ImprovedAestheticFilter datafilter = ImprovedAestheticFilter( weights_folder='../weights', # path to weights folder, will be downloaded to this folder device='cuda:0', workers=16 ) processor.applydatafilter(datafilter)

print(processor.df) # printing new dataset's metadata

Run simple_example.py file:

python simple_example.py

Generate captions example

Code below generates synthetic captions for images in shards on remote S3-compatible storage and updates dataset's metadata without downloading shards:

Before running the example below, install extra requirements: pip install DPF[filters,llava]

from DPF import S3Connector, DatasetReader, ShardsDatasetConfig

creating connector for S3 storage

connector = S3Connector( key='access_key', secret='secret_key', endpointurl='endpointurl' )

reader = DatasetReader(connector)

creating dataset config

config = ShardsDatasetConfig.frompathand_columns( "s3://your-bucket/path/to/shards", imagenamecol='image_name', )

reading a dataset

processor = reader.readfromconfig(config, workers=16)

from DPF.filters.images.llavacaptioningfilter import LLaVaCaptioningFilter

creating LLaVA captioner filter

datafilter = LLaVaCaptioningFilter( workers=16, prompt='short', batch_size=16, device="cuda:0" ) print(datafilter.result_columns) # prints list of columns that will be added

applying filter to dataset

processor.applydatafilter(datafilter) # new metadata is created

newcolumnname = datafilter.result_columns[1] # name of new added column with generated caption

print(processor.df[newcolumnname]) # prints generated image captions

adding new metadata to remote dataset

processor.updatecolumns([newcolumn_name], workers=16)

You can find more examples there

Supported data modalities

The framework supports data that has any combination of the following modalities:

  • Text
  • Image
  • Video
Datasets with several data of the same modality in one sample are not supported.
For example, datasets with following modalities are supported: text-video, text-image, image-video, images, etc. Modalities that are not supported: image2image, image-text-image, etc.

Supported data formats

The dataset should be stored in one of the following formats:

  • Files
  • Shards
  • Sharded files
More about data formats

Basic usage

Configs

To read a dataset, you must first create a config that describes the dataset and the type of data in it. For each data format, you need to use the appropriate config.

Example for shards format:

from DPF import ShardsDatasetConfig

config = ShardsDatasetConfig.frompathand_columns( 'examples/example_dataset', # path to shards imagenamecol='image_name', # name of column in csv file with image names text_col='caption' # name of column in csv file with text/captions )

Reading a dataset

You can read dataset using DatasetReader.from_config method:
from DPF import ShardsDatasetConfig, DatasetReader

config = ShardsDatasetConfig.frompathand_columns( 'examples/example_dataset', imagenamecol='image_name', text_col='caption' )

reader = DatasetReader() processor = reader.readfromconfig(config)

Example for sharded files format:

from DPF import ShardedFilesDatasetConfig, DatasetReader

config = ShardedFilesDatasetConfig.frompathand_columns( 'examples/examplevideodataset', videonamecol='video_name', text_col='caption' )

reader = DatasetReader() processor = reader.readfromconfig(config)

Examples of reading data in other formats

Example reading a dataset directly from S3 storage:

from DPF import S3Connector, DatasetReader, ShardsDatasetConfig

connector = S3Connector( key='access_key', secret='secret_key', endpointurl='endpointurl' ) reader = DatasetReader(connector)

config = ShardsDatasetConfig.frompathand_columns( "s3://your-bucket/path/to/shards", imagenamecol='image_name', ) processor = reader.readfromconfig(config, workers=16)

Viewing and updating dataset

A dataset processor provides an interface for interacting with data and modifying it.

More about dataset processor

Filtering dataset

Filters are models or algorithms that calculate metrics for a dataset. Filters process the data and add new columns with the calculated metrics.

More about filters

Transforming dataset

You can transform data in dataset with DPF. For example, resize videos or photos in dataset. You can use DPF.transforms for these tasks.

More about transforms

Pipelines

Pipelines help to combine several filters into one pipeline and process the dataset using it. For example:

from DPF.configs import ShardsDatasetConfig from DPF.dataset_reader import DatasetReader from DPF.pipelines import FilterPipeline from DPF.filters.images.info_filter import ImageInfoFilter from DPF.filters.images.hash_filters import PHashFilter

reader = DatasetReader() config = ShardsDatasetConfig.frompathand_columns( "examples/example_dataset", imagenamecol='image_name', ) processor = reader.readfromconfig(config, workers=4)

pipeline = FilterPipeline("pipeline_example") pipeline.add_datafilter( ImageInfoFilter, {'workers': 4}, processorrunkwargs={'returnnoneon_error': True}, ) pipeline.add_datafilter(PHashFilter, {'workers': 4}) pipeline.adddeduplication(["imagephash_8"]) pipeline.add_shuffle() pipeline.run(processor)

More about pipelines

🔗 More in this category

© 2026 GitRepoTrend · ai-forever/DataProcessingFramework · Updated daily from GitHub