Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
PyTorchPipe (PTP) is a component-oriented framework that facilitates development of computational _multi-modal pipelines_ and comparison of diverse neural network-based models.

PTP frames training and testing procedures as _pipelines_ consisting of many components communicating through data streams.
Each such a stream can consist of several components, including one problem instance (providing batches of data), any number of trainable components (models) and additional components providing required transformations and computations.
Each such a stream can consist of several components, including one task instance (providing batches of data), any number of trainable components (models) and additional components providing required transformations and computations.

As a result, the training & testing procedures are no longer pinned to a specific problem or model, and built-in mechanisms for compatibility checking (handshaking), configuration and global variables management & statistics collection facilitate rapid development of complex pipelines and running diverse experiments.
As a result, the training & testing procedures are no longer pinned to a specific task or model, and built-in mechanisms for compatibility checking (handshaking), configuration and global variables management & statistics collection facilitate rapid development of complex pipelines and running diverse experiments.

In its core, to _accelerate the computations_ on their own, PTP relies on PyTorch and extensively uses its mechanisms for distribution of computations on CPUs/GPUs, including multi-process data loaders and multi-GPU data parallelism.
The models are _agnostic_ to those operations and one indicates whether to use them in configuration files (data loaders) or by passing adequate run-time arguments (--gpu).

**Datasets:**
PTP focuses on multi-modal reasoning combining vision and language. Currently it offers the following _Problems_ from the following problem domains:
PTP focuses on multi-modal reasoning combining vision and language. Currently it offers the following _Tasks_ from the following task domains:

* CLEVR, GQA, ImageCLEF VQA-Med 2019 (Visual Question Answering)
* MNIST, CIFAR-100 (Image Classification)
* WiLY (Language Identification)
* WikiText-2 / WikiText-103 (Language Modelling)
* ANKI (Machine Translation)

Aside of providing batches of samples, the Problem class will automatically download the files associated with a given dataset (as long as the dataset is publicly available).
The diversity of those problems (and associated models) proves the flexibility of the framework, we are working on incorporation of new ones into PTP.
Aside of providing batches of samples, the Task class will automatically download the files associated with a given dataset (as long as the dataset is publicly available).
The diversity of those tasks (and associated models) proves the flexibility of the framework, we are working on incorporation of new ones into PTP.

**Pipelines:**
What people typically define as a _model_ in PTP is framed as a _pipeline_, consisting of many inter-connected components, with one or more _Models_ containing trainable elements.
Expand Down Expand Up @@ -72,14 +72,14 @@ The framework also offers several components useful when working with text:
and several general-purpose components, from tensor transformations (List to Tensor, Reshape Tensor, Reduce Tensor, Concatenate Tensor), to components calculating losses (NLL Loss) and statistics (Accuracy Statistics, Precision/Recall Statistics, BLEU Statistics etc.) to viewers (Stream Viewer, Stream File Exporter etc.).

**Workers:**
PTP workers are python scripts that are _agnostic_ to the problems/models/pipelines that they are supposed to work with.
PTP workers are python scripts that are _agnostic_ to the tasks/models/pipelines that they are supposed to work with.
Currently framework offers three workers:

* ptp-offline-trainer (a trainer relying on classical methodology interlacing training and validation at the end of every epoch, creates separate instances of training and validation problems and trains the models by feeding the created pipeline with batches of data, relying on the notion of an _epoch_)
* ptp-offline-trainer (a trainer relying on classical methodology interlacing training and validation at the end of every epoch, creates separate instances of training and validation tasks and trains the models by feeding the created pipeline with batches of data, relying on the notion of an _epoch_)

* ptp-online-trainer (a flexible trainer creating separate instances of training and validation problems and training the models by feeding the created pipeline with batches of data, relying on the notion of an _episode_)
* ptp-online-trainer (a flexible trainer creating separate instances of training and validation tasks and training the models by feeding the created pipeline with batches of data, relying on the notion of an _episode_)

* ptp-processor (performing one pass over the all samples returned by a given problem instance, useful for collecting scores on test set, answers for submissions to competitions etc.)
* ptp-processor (performing one pass over the all samples returned by a given task instance, useful for collecting scores on test set, answers for submissions to competitions etc.)


## Installation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Load config defining CIFAR100 problems for training, validation and testing.
# Load config defining CIFAR100 tasks for training, validation and testing.
default_configs: cifar100/default_cifar100.yml

# Definition of the pipeline.
Expand Down
8 changes: 4 additions & 4 deletions configs/cifar100/default_cifar100.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Training parameters:
training:
problem:
task:
type: CIFAR100
batch_size: &b 1024
use_train_data: True
Expand All @@ -25,7 +25,7 @@ training:
# Validation parameters:
validation:
#partial_validation_interval: 100
problem:
task:
type: CIFAR100
batch_size: *b
use_train_data: True # True because we are splitting the training set to: validation and training
Expand All @@ -37,7 +37,7 @@ validation:

# Testing parameters:
test:
problem:
task:
type: MNIST
batch_size: *b
use_train_data: False
Expand Down Expand Up @@ -94,7 +94,7 @@ pipeline:

image_viewer:
priority: 100.5
type: ImageToClassViewer
type: ImageViewer
streams:
images: inputs
labels: fine_labels
Expand Down
12 changes: 6 additions & 6 deletions configs/clevr/clevr_all_vgg_glove_lstm_concat_ffn.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Load config defining CLEVR problems for training, validation and testing.
# Load config defining CLEVR tasks for training, validation and testing.
default_configs: clevr/default_clevr.yml

# Resize and normalize images - in all sets.
training:
problem:
task:
resize_image: [224, 224]
image_preprocessing: normalize

validation:
problem:
task:
resize_image: [224, 224]
image_preprocessing: normalize

test:
problem:
task:
resize_image: [224, 224]
image_preprocessing: normalize

Expand Down Expand Up @@ -76,7 +76,7 @@ pipeline:
# Image encoder.
image_encoder:
priority: 2.1
type: TorchVisionWrapper
type: GenericImageEncoder
model_type: vgg16
streams:
inputs: images
Expand All @@ -87,7 +87,7 @@ pipeline:
##################################################################
# 3rd subpipeline: concatenation + FF.
concat:
type: Concatenation
type: ConcatenateTensor
priority: 3.1
input_streams: [question_activations,image_activations]
dim: 1 # default
Expand Down
2 changes: 1 addition & 1 deletion configs/clevr/clevr_image_convnet_ffn.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Load config defining CLEVR problems for training, validation and testing.
# Load config defining CLEVR tasks for training, validation and testing.
default_configs: clevr/default_clevr.yml

# Definition of the pipeline.
Expand Down
8 changes: 4 additions & 4 deletions configs/clevr/clevr_question_glove_lstm.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Load config defining CLEVR problems for training, validation and testing.
# Load config defining CLEVR tasks for training, validation and testing.
default_configs: clevr/default_clevr.yml

# This is unimodal (questino-based) baseline, thus stop streaming images - in all sets.
training:
problem:
task:
stream_images: False

validation:
problem:
task:
stream_images: False

test:
problem:
task:
stream_images: False

# Definition of the pipeline.
Expand Down
8 changes: 4 additions & 4 deletions configs/clevr/default_clevr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Training parameters:
training:
problem:
task:
type: CLEVR
batch_size: &b 64
split: training
Expand All @@ -18,15 +18,15 @@ training:

# Validation parameters:
validation:
problem:
task:
type: CLEVR
batch_size: *b
split: validation
#resize_image: [224, 224]

# Testing parameters:
test:
problem:
task:
type: CLEVR
batch_size: *b
split: test
Expand Down Expand Up @@ -96,7 +96,7 @@ pipeline:

#image_viewer:
# priority: 100.5
# type: ImageToClassViewer
# type: ImageViewer
# streams:
# images: inputs
# labels: labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/'

# Source files that will be used to create the vocabulary (LOADED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/'

# Source files that will be used to create the vocabulary (LOADED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/'

# Source files that will be used to create the vocabulary (LOADED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/'

# Source files that will be used to create the vocabulary (LOADED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/'

# Source files that will be used to create the vocabulary (LOADED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file defines the default values for the MultimodalFactorizedBilinearPooling model.
# This file defines the default values for the FactorizedBilinearPooling model.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file defines the default values for the ElementWiseMultiplication model.
# This file defines the default values for the LowRankBilinearPooling model.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file defines the default values for the VQA_Attention model.
# This file defines the default values for the QuestionDrivenAttention model.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file defines the default values for the ElementWiseMultiplication model.
# This file defines the default values for the LowRankBilinearPooling model.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This file defines the default values for the CLEVR problem.
# This file defines the default values for the CLEVR task.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/CLEVR_v1.0'

# Defines the set (split) that will be used (LOADED)
# Options: training | validation | test | cogent_a_training | cogent_a_validation | cogent_b_validation
split: training

# Flag indicating whether the problem will load and return images (LOADED)
# Flag indicating whether the task will load and return images (LOADED)
stream_images: True

# Resize parameter (LOADED)
Expand All @@ -31,7 +31,7 @@ streams:
####################################################################

# Stream containing batch of indices (OUTPUT)
# Every problem MUST return that stream.
# Every task MUST return that stream.
indices: indices

# Stream containing batch of images (OUTPUT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This file defines the default values for the GQA problem.
# This file defines the default values for the GQA task.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/gqa'

# Defines the set (split) that will be used (LOADED)
# Options: training_0 | training | validation | test_dev | test | challenge | submission (?)
# Note: test_dev should be used for validation.
split: training_0

# Flag indicating whether the problem will load and return images (LOADED)
# Flag indicating whether the task will load and return images (LOADED)
stream_images: True

# Resize parameter (LOADED)
Expand All @@ -32,7 +32,7 @@ streams:
####################################################################

# Stream containing batch of indices (OUTPUT)
# Every problem MUST return that stream.
# Every task MUST return that stream.
indices: indices

# Stream containing batch of sample (original) identifiers (OUTPUT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file defines the default values for the VQAMED2019 problem.
# This file defines the default values for the VQAMED2019 task.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/vqa-med'

# Defines the set (split) that will be used (LOADED)
Expand All @@ -15,7 +15,7 @@ split: training
# Options: all | c1 | c2 | c3 | c4 (or any combination of the latter 4)
categories: all

# Flag indicating whether the problem will load and return images (LOADED)
# Flag indicating whether the task will load and return images (LOADED)
stream_images: True

# Flag indicating whether images will be preloaded (i.e. loaded once at start) (LOADED)
Expand All @@ -29,7 +29,7 @@ preload_images: False
#resize_image: [height, width]

# Scale parameter [height, width] (LOADED)
# Problem will use those values to rescale the image_sizes to range (0, 1).
# Task will use those values to rescale the image_sizes to range (0, 1).
scale_image_size: [2414, 2323]

# Select applied image preprocessing/augmentations (LOADED)
Expand All @@ -50,7 +50,7 @@ question_preprocessing: lowercase, remove_punctuation
# Accepted formats: a,b,c or [a,b,c]
answer_preprocessing: none

# When filename is not empty, problem will calculate weights associated with all samples
# When filename is not empty, task will calculate weights associated with all samples
# by looking at the distribution of all answers from all loaded samples (LOADED)
# Those weights can be next used by weighted samplers (e.g. kFoldWeightedSampler)
export_sample_weights: ''
Expand Down Expand Up @@ -78,7 +78,7 @@ streams:
####################################################################

# Stream containing batch of indices (OUTPUT)
# Every problem MUST return that stream.
# Every task MUST return that stream.
indices: indices

# Stream containing batch of images (OUTPUT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file defines the default values for the CIFAR-100 problem.
# This file defines the default values for the CIFAR-100 task.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where problem will store data (LOADED)
# Folder where task will store data (LOADED)
data_folder: '~/data/cifar-100'

# Defines the set that will be used used (LOADED)
Expand All @@ -21,7 +21,7 @@ streams:
####################################################################

# Stream containing batch of indices (OUTPUT)
# Every problem MUST return that stream.
# Every task MUST return that stream.
indices: indices

# Stream containing batch of images (OUTPUT)
Expand Down
Loading