Skip to content

Commit

Permalink
First code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nshepeleva committed Feb 26, 2019
1 parent b78c8d9 commit 9849cf4
Show file tree
Hide file tree
Showing 23 changed files with 3,142 additions and 1 deletion.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# training-engine
# ALOHA Training Engine

This is stand-alone Training Engine module ALOHA.eu project. http://aloha-h2020.eu

## Setup
Training Engine was developed using Python 3.6, TensorFlow 1.12, PyTorch 1.0 and was tested under Windows 10

``pip install -r requirements.txt``

## Data Standardization
Data standardization description described in [data_standardization](data_standardization)

## Architecture deployment
to be added

## Training Configuration
to be added


## Supported Features
- [x] training/inference TensorFlow support
- [x] classification task support
- [x] segmentation task support

## In development:
- [ ] training/inference PyTorch support
- [ ] detection task support
- [ ] tracking task support
- [ ] GAN architecture support
- [ ] hyperparameter optimization
- [ ] fast/full training mode
- [ ] accuracy prediction metric
- [ ] transfer leraning support


# Acknowledgements
This work was carried out by the European Union\`s Horizon H2020 Research and Innovation programme under grant agreement No. 780788
102 changes: 102 additions & 0 deletions configs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env python
# -----------------------------------------------------------------------------
# Copyright (C) Software Competence Center Hagenberg GmbH (SCCH)
# All rights reserved.
# -----------------------------------------------------------------------------
# This document contains proprietary information belonging to SCCH.
# Passing on and copying of this document, use and communication of its
# contents is not permitted without prior written authorization.
# -----------------------------------------------------------------------------
# Created on : 11/16/2017 11:07 $
# by : shepeleva $
# SVN : $
#

# --- imports -----------------------------------------------------------------

import argparse


class ConfigFlags:
def __init__(self):
"""
"""
parser = argparse.ArgumentParser(description='Tensorflow DL training pipeline')
# mandatory variables
parser.add_argument('--net', help='Network',
type=str, default='ConvNet')
parser.add_argument('--mode', help='training / test',
type=str, default='training')
parser.add_argument('--data_set', help='Name/ID of the used data set',
type=str, default='MNIST')
parser.add_argument('--data_dir', help='Learning data directory',
type=str, default='')
parser.add_argument('--data_file', help='Data file',
type=str)
parser.add_argument('--checkpoint_dir', help='Checkpoint directory',
type=str, default='ckpnt_dir')
parser.add_argument('--trainlog_dir', help='Train records directory',
type=str, default='tr_log')
parser.add_argument('--lr', help='Learning rate',
type=float, default=0.001)
parser.add_argument('--lr_decay', help='Learning rate decay rate',
type=float, default=0.0005)
parser.add_argument('--ref_steps', help='Refinement Steps',
type=int, default=5)
parser.add_argument('--ref_patience', help='Refinement Patience',
type=int, default=200)
parser.add_argument('--batch_size', help='Batch size',
type=int, default=32)
parser.add_argument('--num_epochs', help='Number of epochs',
type=int, default=100)
parser.add_argument('--loss', help='Loss function',
type=str, default='mse')
parser.add_argument('--optimizer', help='Optimizers: \n\t adam - adam optimizer '
'\n\t gradient - gradient descent '
'\n\t proximalgrad - proximal gradient descent ',
default='adam')
parser.add_argument('--dropout', help='Dropout Rate to use',
type=float, default=0.25)
parser.add_argument('--tb_record', help='Tensorboard records on/off',
type=bool, default=True)
parser.add_argument('--darkon_record', help='Darkon tool',
type=bool, default=False)
parser.add_argument('--gradcam_record', help='GradCam tool',
type=bool, default=False)
parser.add_argument('--gradcam_layers', help='Number of inspected convolution layers',
type=int, default=1)
parser.add_argument('--gradcam_layers_max', help='Number of convolution layers',
type=int, default=3)
parser.add_argument('--mi_record', help='MI tool',
type=bool, default=False)
parser.add_argument('--gpu_load', help='GPU load percentage [0.1 : 1]',
type=int, default=0.8)
# optional variables
parser.add_argument('--image_size', help='Image size',
type=list, default=[128, 128, 1])
parser.add_argument('--num_classes', help='Number of labels',
type=int, default=2)
parser.add_argument('--num_filters', help='Number of filters',
type=int)
# todo actually implement following parameters in NetRunner
parser.add_argument('--filter_size', help='Filter size',
type=int)
parser.add_argument('--pool_size', help='Pool size',
type=int)
parser.add_argument('--stride_size', help='stride size',
type=int)
parser.add_argument('--nonlin', help='Nonlinearity',
type=str)
parser.add_argument('--upconv', help='Up convolution type: upconv or upsampling',
type=str)
parser.add_argument('--multi_task', help="multiple task, i.e. different loss functions",
type=bool)
self.args = parser.parse_args()

def return_flags(self):
"""
:return:
"""
return self.args
63 changes: 63 additions & 0 deletions configs/config_ConvNet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python
# -----------------------------------------------------------------------------
# Copyright (C) Software Competence Center Hagenberg GmbH (SCCH)
# All rights reserved.
# -----------------------------------------------------------------------------
# This document contains proprietary information belonging to SCCH.
# Passing on and copying of this document, use and communication of its
# contents is not permitted without prior written authorization.
# -----------------------------------------------------------------------------
# Created on : 01/08/2018 16:29 $
# by : shepeleva $
# SVN : $
#

# --- imports -----------------------------------------------------------------

from configs.config import ConfigFlags


def load_config():
config = ConfigFlags().return_flags()

config.net = 'ConvNet'
config.training_mode = False
config.data_set = 'MNIST'
config.image_size = [28, 28, 1]

config.lr = 0.001
config.lr_decay = 0.1
config.ref_steps = 10
config.ref_patience = 1
config.batch_size = 32
config.num_epochs = 1000
config.loss = 'mse'
config.optimizer = 'adam'
config.gradcam_record = True
config.gradcam_layers = 6
config.gradcam_layers_max = 6
config.mi_record = False
config.gpu_load = 0.8
config.num_classes = 10
config.class_labels = [i for i in range(9)]
config.num_filters = 16
config.upconv = 'upconv'
config.nonlin = 'relu'
config.task_type = 'classification'
config.accuracy = 'mse'
config.augmentation = {'flip_hor': False,
'flip_vert': False}
config.data_split = 0.7
config.long_summary = True
config.trainable_layers = 'all'
config.normalize = True
config.zero_center = True
config.dropout = 0.4
config.chpnt2load = ''
config.multi_task = False
config.cross_val = 1
config.framework = 'tensorflow'
config.experiment_path = None


return config
20 changes: 20 additions & 0 deletions data_standardization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# data_standardization

Description of custom dataset representation accepted by ALOHA tool

Current support of data input into ALOHA tool is following:
- by picking `dataset`
>allowed entries: MNIST, CIFAR10, CIFAR100, <custom>
if `<custom>` is picked, user have two options:
- from `data_file`

> supported file formats: JSON, TXT

- from `data_folder`

> multiple file loading for classification and segmentation case
For more detailed description check corresponding folder

##### Important. Description provided in standardization files are not yet final. Changes my apply during development phase.
113 changes: 113 additions & 0 deletions data_standardization/json/json_standardization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# JSON format standardization

## General information
Rules on dataset description on JSON format.
This representation supports 3 task scenarios:
- Classification
- Segmentation
- Detection
- *In development: Traking, Multi-task*

This standardization describes following input cases:
- IC1: single folder with images
- IC2: multiple folders with images
- IC3: single video
- IC4: multiple videos

## Data loading to ALOHA toolflow
By using JSON format standardization, please, use parameter `data_file` in the configuration and pick JSON file, which describes your dataset.

Please, be aware that all source locations in the JSON format standardization should contain ABSOLUTE path.


## Detailed standardization description
The standardization should be described as a dictionary of `<key>: <value>` pairs.

Allowed list of `key` values:

- `name` - dataset name
>str value, describes dataset name, Ex.: 'random_set'
- `width` - width of the frame/image
>set value only if all frames/images of the same size, otherwise put 0
- `height` - height of the frame/image
>set value only if all frames/images of the same size, otherwise put 0
- `source` - source of the information (`video` or `image`)
>describes which source will be used, avaliable values: `video` or `image`
- `source_path` - absolute path to the source
>absolute or relative to the .json file path to the data source
- `mask_path` - absolute path to masks if presented
>absolute or relative to the .json file path to the masks (only for Segmentation task)
- `data_size` - number of frames per video / number of images in dataset
>depending on IC representaiton this value coud difer use following example: <br>
for IC1 or IC3: 2340 - means that dataset represented by one folder with 2340 images in total OR by one video with 2340 frames in total<br>
for IC2 or IC4: [345, 654, 123] - means that dataset represented by 3 folders with 345, 654 and 123 images accordingly OR by 3 videos with 345, 654 and 123 frames accordingly
- `meta`- detailed information for specific task
>in this section every frame/image should get detailed description accordingly to the task
### `meta` for Classification
List of following dictionaries:
- `frame` - frame/image id
>for IC1: image_name<br>
for IC2: [image_folder, image]<br>
for IC3: frame_id<br>
for IC4: [video_file_name, frame_id]
- `width`
>width of particular frame, if global width is not setted up
- `height`
>height of particular frame, if global height is not setted up
- `mask` - mask presence
>for this task should be equal to null
- `objects` - list of the descriptions of objects which should be classified in current frame
- `object_class` - object class indentification
>integer or one-hot labeling
- `bb` - bounding box
>for this task should be equal to null
- `polygon` - polygon area
>for this task should be equal to null
### `meta` for Segmentation
List of following dictionaries:
- `frame` - frame/image id
>for IC1: image_name<br>
for IC2: [image_folder, image]<br>
for IC3: frame_id<br>
for IC4: [video_file_name, frame_id]
- `width`
>width of particular frame, if global width is not setted up
- `height`
>height of particular frame, if global height is not setted up
- `mask`- mask presence, video/image representation might be independent from frame representaiton
>for IC1: image_name<br>
for IC2: [image_folder, image]<br>
for IC3: frame_id<br>
for IC4: [video_file_name, frame_id]
- `objects` - list of the descriptions of objects which should be classified in current frame
- `object_class` - object class indentification
>integer or one-hot labeling
- `bb` - bounding box
>for this task should be equal to null
- `polygon` - polygon area
>list of points describing polygon
### `meta` for Detection
List of following dictionaries:
- `frame` - frame/image id
>for IC1: image_name<br>
for IC2: [image_folder, image]<br>
for IC3: frame_id<br>
for IC4: [video_file_name, frame_id]
- `width`
>width of particular frame, if global width is not setted up
- `height`
>height of particular frame, if global height is not setted up
- `mask` - mask presence
>for this task should be equal to null
- `objects` - list of the descriptions of objects which should be classified in current frame
- `object_class` - object class indentification
>integer or one-hot labeling
- `bb` - object boundaries
>should be described as [Xmin, Ymin, Xmax, Ymax], where<br>
(Xmin, Ymin) pair specifying the lower-left corner<br>
(Xmax, Ymax) pair specifying the upper-right corner
- `polygon` - polygon area
>list of points describing polygon
41 changes: 41 additions & 0 deletions data_standardization/txt/txt_standardization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# TXT format standardization

## General information
Rules on dataset description on TXT format.
This representation supports 2 task scenarios:
- Classification
- Segmentation
- Detection
- *In development: Traking, Multi-task*

This standardization describes following input cases:
- IC1: single TXT file

## Data loading to ALOHA toolflow
- IC1 case: please, use parameter `data_file` in the configuration and pick TXT file, which describes your dataset.

Please, be aware that all source locations in the TXT format standardization should contain ABSOLUTE path.

## Detailed standardization description
The standardization should be described as a list of paticular fileds separated by space depending on the task.

### Classification
File structure: `<image_file> <label>`
- `image_file` - absolute path to the image
- `label` - label description, integer or one-hot encoded
>for integer description the count start from 0
### Segmentaiton
File structure: `<image_file> <mask_file>`
- `image_file` - absolute path to the image
- `mask_file` - absolute path to the corresponding mask
>segmentation areas should be setted to the integer values starting from 1 (0 - backgound) for a required number of classes in dataset
### Detection
File structure: `<image_file> <bounding_box>`
- `image_file` - absolute path to the image
- `bounding_box` - object boundaries
>should be described as [Xmin, Ymin, Xmax, Ymax], where
(Xmin, Ymin) pair specifying the lower-left corner<br>
(Xmax, Ymax) pair specifying the upper-right corner<br>
for more than one object should be represented as list if lists
Loading

0 comments on commit 9849cf4

Please sign in to comment.