From 7d2545eb5f659ceaf3e995b4bc20acd29e1fb849 Mon Sep 17 00:00:00 2001 From: Eljas Hyyrynen Date: Thu, 14 Apr 2022 11:46:19 +0300 Subject: [PATCH 1/4] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 156800a..7452656 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ A deep learning framework based on Tensorflow for the training of high performan *All implementations are re-implementations of published algorithms and thus provided models should not be considered as reference.* +--- + +This is a fork from [swook/GazeML](https://github.com/swook/GazeML). I am on fixing some issues in importing the model to `.onnx` format and further to TensorRT `.engine` format. + +--- + This framework currently integrates the following models: ## ELG From b9a5a5c6763e017f659deaa505ef7a3db2ff8d89 Mon Sep 17 00:00:00 2001 From: Eljas Hyyrynen Date: Sun, 24 Apr 2022 14:44:13 +0300 Subject: [PATCH 2/4] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 7452656..1569834 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ A deep learning framework based on Tensorflow for the training of high performan This is a fork from [swook/GazeML](https://github.com/swook/GazeML). I am on fixing some issues in importing the model to `.onnx` format and further to TensorRT `.engine` format. +I have tested this on: +- Ubuntu 20.04 +- NVIDIA GeForce RTX 3080 Laptop GPU +- Nvidia driver 510.54 +- CUDA 11.6 +- python 3.6 +- tensorflow 1.14 + --- This framework currently integrates the following models: From 21a2cdbb8adb30174eece23330cc813d58ccd537 Mon Sep 17 00:00:00 2001 From: Eljas Hyyrynen Date: Mon, 6 Jun 2022 21:49:20 +0300 Subject: [PATCH 3/4] changes to make model convertable to TensorRT disable batch statistics as we are not training the batch statistics were forgotten to set to False. the batchnorm function gave some errors with tf2onnx converter TensorRT does not support uint8 so one output was converted to int64 instead Add code to save the model to folder tmp --- src/core/model.py | 13 ++++++++++--- src/datasources/frames.py | 2 +- src/models/elg.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/model.py b/src/core/model.py index ffed8a9..9f93406 100644 --- a/src/core/model.py +++ b/src/core/model.py @@ -29,7 +29,7 @@ def __init__(self, train_data: Dict[str, BaseDataSource] = {}, test_data: Dict[str, BaseDataSource] = {}, test_losses_or_metrics: str = None, - use_batch_statistics_at_test: bool = True, + use_batch_statistics_at_test: bool = False, identifier: str = None): """Initialize model with data sources and parameters.""" self._tensorflow_session = tensorflow_session @@ -324,7 +324,7 @@ def train(self, num_epochs=None, num_steps=None): fetches=fetches, feed_dict={ self.is_training: True, - self.use_batch_statistics: True, + self.use_batch_statistics: False, } ) self.time.end('train_iteration') @@ -378,8 +378,15 @@ def inference_generator(self): fetches=fetches, feed_dict={ self.is_training: False, - self.use_batch_statistics: True, + self.use_batch_statistics: False, }, ) + + + # Save saved-model + # This model can be used to convert to .onnx and further to .engine + tf.saved_model.simple_save(self._tensorflow_session, "tmp", + inputs=data_source.output_tensors, outputs=fetches) + outputs['inference_time'] = 1e3*(time.time() - start_time) yield outputs diff --git a/src/datasources/frames.py b/src/datasources/frames.py index e445e2f..a60d415 100644 --- a/src/datasources/frames.py +++ b/src/datasources/frames.py @@ -113,7 +113,7 @@ def entry_generator(self, yield_just_one=False): yield { 'frame_index': np.int64(current_index), 'eye': eye_dict['image'], - 'eye_index': np.uint8(i), + 'eye_index': np.int64(i), } finally: diff --git a/src/models/elg.py b/src/models/elg.py index cb48b47..6a24803 100644 --- a/src/models/elg.py +++ b/src/models/elg.py @@ -178,7 +178,7 @@ def _apply_bn(self, tensor): tensor, scale=True, center=True, - is_training=self.use_batch_statistics, + is_training=False, trainable=True, data_format=self._data_format, updates_collections=None, From a6d7434ccf6e0218c07e757ad1d96aa52939d0da Mon Sep 17 00:00:00 2001 From: Eljas Hyyrynen Date: Mon, 6 Jun 2022 21:53:52 +0300 Subject: [PATCH 4/4] Update README.md --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1569834..ae6cd32 100644 --- a/README.md +++ b/README.md @@ -44,24 +44,26 @@ Deep Pictorial Gaze Estimation ## Installing dependencies -Run (with `sudo` appended if necessary), +Follow [these instructions](https://opensource.com/article/20/4/install-python-linux) to download Python 3.7 + +Use python virtual environment ([venv](https://docs.python.org/3/tutorial/venv.html)) to install python dependencies: + +Run the following inside `GazeML` repository root folder: ``` -python3 setup.py install +python3.7 -m venv .venv +source .venv/bin/activate ``` -Note that this can be done within a [virtual environment](https://docs.python.org/3/tutorial/venv.html). In this case, the sequence of commands would be similar to: +Install dependencies: ``` - mkvirtualenv -p $(which python3) myenv - python3 setup.py install +pip install --upgrade pip +pip install cython +pip install scipy +python3 setup.py install +pip install tensorflow==1.14 +pip install tensorflow-gpu==1.14 ``` -when using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/). - -### Tensorflow -Tensorflow is assumed to be installed separately, to allow for usage of [custom wheel files](https://github.com/mind/wheels) if necessary. - -Please follow the official installation guide for Tensorflow [here](https://www.tensorflow.org/install/). - ## Getting pre-trained weights To acquire the pre-trained weights provided with this repository, please run: ```