otbtf issueshttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues2023-04-04T12:25:12+02:00https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/1Complementary informations for GPU users2023-04-04T12:25:12+02:00Gaetano RaffaeleComplementary informations for GPU usersGreat job with the otftf docker suite, I grabbed the otbtf2.0:gpu docker and it really eases things up!
By the way, some additional information for gpu users might be included in the documentation, basically:
- the need to install the n...Great job with the otftf docker suite, I grabbed the otbtf2.0:gpu docker and it really eases things up!
By the way, some additional information for gpu users might be included in the documentation, basically:
- the need to install the nvidia-container-runtime package at the host level
- the need to specify the '--gpus' option when calling the container to make system gpus visible in the docker
Cheers!
Rafhttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/2Migration TF22022-03-07T19:18:58+01:00Narcon NicolasMigration TF2Commande utile pour visualiser un modèle .pb
```
saved_model_cli show --dir chemin/du/modele --tag_set serve --signature_def serving_default
```
### TF1
Les noms des noeuds sont du type `tower_0/s2_t`. On y accède via les nodes du Graph...Commande utile pour visualiser un modèle .pb
```
saved_model_cli show --dir chemin/du/modele --tag_set serve --signature_def serving_default
```
### TF1
Les noms des noeuds sont du type `tower_0/s2_t`. On y accède via les nodes du GraphDef
### TF2
Lors du parcours des nodes du GraphDef :
- Les noms des noeuds "inputs" sont du type `serving_default_s2_t`.
- Les noms des noeuds "outputs" sont du type `StatefulPartitionedCall`
A la place, il est plus pertinent de parcourir :
- `bundle.GetSignatures().at("serving_default").inputs()` qui est un mapping du type {"s2_t": node_info}
- `bundle.GetSignatures().at("serving_default").outputs()` qui est un mapping du type {"s2_t": node_info}
Ressources utiles :
- https://stackoverflow.com/a/64385815/13711499
- https://stackoverflow.com/questions/63181951/how-to-get-graph-or-graphdef-from-a-given-model
- https://stackoverflow.com/questions/58968918/accessing-input-and-output-tensors-of-a-tensorflow-2-0-savedmodel-via-the-c-apiNarcon NicolasNarcon Nicolashttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/3More unit tests2022-03-07T19:19:45+01:00Cresson RemiMore unit testsAdd new unit tests (@remi.cresson):
- [x] .gitlab-ci jobs
- [x] c++ build from OTB+TF docker image
- [x] Python static analysis (pylint + flake8)
- [x] model train
New test to do (todo @nicolas.narcon )
- [x] Tester la super resolution ...Add new unit tests (@remi.cresson):
- [x] .gitlab-ci jobs
- [x] c++ build from OTB+TF docker image
- [x] Python static analysis (pylint + flake8)
- [x] model train
New test to do (todo @nicolas.narcon )
- [x] Tester la super resolution ([lien](https://github.com/remicres/sr4rs#quick-hr-image-generation-using-pre-trained-model))
- [x] Tester les modèles du Tutoriel (https://github.com/remicres/otbtf_tutorial_resources)
Ajouter les tests au CMakeLists directement dans la branche migration-tf2Narcon NicolasNarcon Nicolashttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/4Segmentation fault en cas de tagsets incorrects2021-08-31T15:21:44+02:00Narcon NicolasSegmentation fault en cas de tagsets incorrectsA exécuter, dans le dossier `otbtf/test` :
```bash
otbcli_TensorflowModelServe -model.tagsets train -source1.il data/pxs_subset.tif -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x -model.dir models/model1/ -output.names ...A exécuter, dans le dossier `otbtf/test` :
```bash
otbcli_TensorflowModelServe -model.tagsets train -source1.il data/pxs_subset.tif -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x -model.dir models/model1/ -output.names prediction -out /mnt/mo-gpu/decloud/results/otbtf_test_unitaire_model1_avec_OTBTF2.tif
```
ça fonctionne comme attendu. En ne spécifiant pas `-model.tagsets train` ou en spécifiant un tag-set qui existe mais qui est vide par contre ça segfault. Par exemple:
```bash
otbcli_TensorflowModelServe -model.tagsets serve -source1.il data/pxs_subset.tif -source1.rfieldx 16 -source1.rfieldy 16 -source1.placeholder x -model.dir models/model1/ -output.names prediction -out /mnt/mo-gpu/decloud/results/otbtf_test_unitaire_model1_avec_OTBTF2.tif
```
le saved_model_cli de model2:
```
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
MetaGraphDef with tag-set: 'train' contains the following SignatureDefs:
signature_def['model']:
The given SavedModel SignatureDef contains the following input(s):
inputs['x1:0'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, -1, 4)
name: x1:0
inputs['x2:0'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, -1, 1)
name: x2:0
inputs['y:0'] tensor_info:
dtype: DT_INT32
shape: (-1, -1, -1, 1)
name: y:0
The given SavedModel SignatureDef contains the following output(s):
outputs['features:0'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 128)
name: features:0
outputs['prediction:0'] tensor_info:
dtype: DT_INT64
shape: (-1)
name: prediction:0
Method name is: tensorflow/serving/predict
```https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/5Clang-format2022-07-21T15:58:09+02:00Cresson RemiClang-formatClang-format permet de formater le code c++.
On peur le lancer sur les fichiers `.hxx`, `.txx`, `.cxx`, `.h` de la façon suivante:
```
find . -regex '.*\.\(cxx\|hxx\|txx\|h\)' -exec clang-format -style=file -i {} \;
```
Il faut ajouter...Clang-format permet de formater le code c++.
On peur le lancer sur les fichiers `.hxx`, `.txx`, `.cxx`, `.h` de la façon suivante:
```
find . -regex '.*\.\(cxx\|hxx\|txx\|h\)' -exec clang-format -style=file -i {} \;
```
Il faut ajouter le fichier `.clang-format` qui définit les rêgles de formatage à la racine de otbtf (cf [celui d'OTB](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/blob/develop/.clang-format)).
J'ai essayé chez moi c'est pas mal du tout!https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/6Support des vecteurs dans les usersplaceholders2022-03-07T19:19:21+01:00Cresson RemiSupport des vecteurs dans les usersplaceholders# description
Actuellement on peut donner des scalaires en entrée, par ex
```
is_training=true, my_int=135, float_val=0.15566
```
Il faudrait qu'on puisse faire aussi:
```
is_training=true, my_int=135, float_val=0.15566, mon_vecteur=(0....# description
Actuellement on peut donner des scalaires en entrée, par ex
```
is_training=true, my_int=135, float_val=0.15566
```
Il faudrait qu'on puisse faire aussi:
```
is_training=true, my_int=135, float_val=0.15566, mon_vecteur=(0.25, 1.2)
```
# fichiers et classes
`otbTensorflowCopyUtils.cxx`https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/7Improve handling of 3-dimensional output tensors + more explanation in error ...2022-03-07T19:19:33+01:00Cresson RemiImprove handling of 3-dimensional output tensors + more explanation in error messages about output tensors dimensions# Problem
We face a `(FATAL) TensorflowModelServe: Caught std::exception during application execution: std::bad_alloc` when the output tensors of a model are not in the right shape (i.e. the last component is not the number of channels)...# Problem
We face a `(FATAL) TensorflowModelServe: Caught std::exception during application execution: std::bad_alloc` when the output tensors of a model are not in the right shape (i.e. the last component is not the number of channels).
While this is nominal that the error occurs, we should be able to explain the user why, instead of having this incomprehensible `std::bad_alloc` message :wink:
# How to reproduce
Model:
```
import tensorflow as tf
# Input
x = tf.keras.Input(shape=[None, None, None], name="x") # [1, h, w, N]
# Compute norm on the last axis
y = tf.norm(x, axis=-1)
# Create model
model = tf.keras.Model(inputs={"x": x}, outputs={"y": y}, name="my_model")
model.save("my_model")
```
Inference:
We run the model in **fully convolutional**, meaning that the input image is processed in blocks of `[1, h, w, N]`.
```
otbcli_TensorflowModelServe \
-source1.il sr4rs_data/input/SENTINEL2B_20200929-104857-489_L2A_T31TEJ_C_V2-2_FRE_10m.tif \
-model.dir my_model/ -out norm.tif -model.fullyconv on
```
# What to tell to the user instead?
Explain him how to arrange output tensor dimensions.
It is already in the doc but the point is to have some explicit warning/error message/suggestion message
# Improve OTBTF to work with dimension-3 tensors
We can assume that 3-dimensional tensors are always [batch, h, x]. I don't see why a model would produce otherwise.https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/8Support model with no-named inputs/outputs2021-11-23T19:53:49+01:00Narcon NicolasSupport model with no-named inputs/outputsOTBTF should handle a model that doesn't name inputs/outputs, e.g. a model created like that :
```python
import tensorflow as tf
# Input
x1 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
x2 = tf.keras.Input(shape=[None, None, 4]) ...OTBTF should handle a model that doesn't name inputs/outputs, e.g. a model created like that :
```python
import tensorflow as tf
# Input
x1 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
x2 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
# Compute multiply
y = tf.math.multiply(x1, x2)
# Create model
model = tf.keras.Model(inputs=[x1, x2], outputs=y, name="multiply")
model.save("my_model_multiply")
```
When running `TensorflowModelServe`, the user could ommit the `source#.placeholder` and `output.names` argumentshttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/9Cannot mix OTBTF application and Tensorflow in Python2023-04-04T12:25:13+02:00Narcon NicolasCannot mix OTBTF application and Tensorflow in PythonThis piece of script raises an error on the last line
```python
import tensorflow as tf
import otbApplication
# Create a dummy Tensorflow model and save it
x1 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
x2 = tf.keras.Input(shap...This piece of script raises an error on the last line
```python
import tensorflow as tf
import otbApplication
# Create a dummy Tensorflow model and save it
x1 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
x2 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
y = tf.math.multiply(x1, x2)
model = tf.keras.Model(inputs=[x1, x2], outputs=y, name="multiply")
model.save("my_model_multiply")
# Create an OTB application
serve = otbApplication.Registry.CreateApplication('TensorflowModelServe')
```
Was run in 4 differents environments and raised different errors.
On `mdl4eo/otbtf2.4:cpu` and `mdl4eo/otbtf2.4:gpu` :
```
[libprotobuf ERROR external/com_google_protobuf/src/google/protobuf/descriptor_database.cc:118] File already exists in database: tensorflow/core/profiler/profiler_service_monitor_result.proto
[libprotobuf FATAL external/com_google_protobuf/src/google/protobuf/descriptor.cc:1379] CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):
Traceback (most recent call last):
File "pyotb.py", line 12, in <module>
serve = otbApplication.Registry.CreateApplication('TensorflowModelServe')
```
on `mdl4eo/otbtf2.5:gpu` and `mdl4eo/otbtf2.5:cpu` :
```
2021-10-28 13:31:51.933796: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/node_counter
2021-10-28 13:31:51.933889: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/graph_counter
2021-10-28 13:31:51.933922: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/op_counter
2021-10-28 13:31:51.933988: F tensorflow/core/framework/device_factory.cc:90] Duplicate registration of device factory for type XLA_CPU with the same priority 50
Aborted (core dumped)
```https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/10PatchesSelection: choice auto/corner/center2021-11-23T19:53:35+01:00Cresson RemiPatchesSelection: choice auto/corner/centerSelect appropriately center if patch size dimension is odd, corner if even
- corner: when patch size is even
- center: when patch size is oddSelect appropriately center if patch size dimension is odd, corner if even
- corner: when patch size is even
- center: when patch size is oddCresson RemiCresson Remihttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/11Migrate to git-lfs2021-11-23T19:53:28+01:00Cresson RemiMigrate to git-lfsMigrate all files in doc/images and test/data to git-lfsMigrate all files in doc/images and test/data to git-lfshttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/12Bugs in v3.0-rc12022-03-07T19:19:12+01:00Cresson RemiBugs in v3.0-rc1- add exception when returned number of components is -1 (CopyUtils)
- resolve userplaceholders tensors names- add exception when returned number of components is -1 (CopyUtils)
- resolve userplaceholders tensors nameshttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/13PatchesExtration writes garbage patches when sampler->GetNumberOfAcceptedSamp...2022-03-07T19:18:37+01:00Cresson RemiPatchesExtration writes garbage patches when sampler->GetNumberOfAcceptedSamples() is 0When sampler->GetNumberOfAcceptedSamples() is 0, the resizer doesn't work inside the `otb::tf::Sampler`.
In the meantime, there is no need to write a (0, 0) image!
An exception must be thrown when no patch can be extracted.When sampler->GetNumberOfAcceptedSamples() is 0, the resizer doesn't work inside the `otb::tf::Sampler`.
In the meantime, there is no need to write a (0, 0) image!
An exception must be thrown when no patch can be extracted.Cresson RemiCresson Remihttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/14Add TFRecords creation to OTBTF2022-05-10T12:13:39+02:00Narcon NicolasAdd TFRecords creation to OTBTFWe would need to define a new class TFRecord that handles all the dataset <-> tfrecord conversions. Inside `otbtf.py` ? Or we split `otbtf.py` into a python module:
```
otbtf
|───dataset.py
|───tfrecord.py
└───utils.py
```
Maybe add a m...We would need to define a new class TFRecord that handles all the dataset <-> tfrecord conversions. Inside `otbtf.py` ? Or we split `otbtf.py` into a python module:
```
otbtf
|───dataset.py
|───tfrecord.py
└───utils.py
```
Maybe add a method `to_tfrecords(out_dir)` inside Dataset class ?https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/15PatchesSelection: add the possibility to specify proportions/datasets custom ...2022-04-05T19:55:32+02:00Narcon NicolasPatchesSelection: add the possibility to specify proportions/datasets custom namesAt the moment, a user can use the mode chessboard to create 2 balanced datasets:
- "A" : 50% of points
- "B" : 50% of points
Maybe we could (like in decloud) enable to create any number of datasets, with any proportions, e.g.
- "train"...At the moment, a user can use the mode chessboard to create 2 balanced datasets:
- "A" : 50% of points
- "B" : 50% of points
Maybe we could (like in decloud) enable to create any number of datasets, with any proportions, e.g.
- "train": 75% of points
- "valid": 15% of points
- "test" : 10% of points
That would imply to add a new strategy option, that would have at least 2 subparameters
- "names": names of the datasets
- "proportions": corresponding proportions of the datasetshttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/16Build docker images after release2022-04-22T16:26:06+02:00Cresson RemiBuild docker images after releaseUse a custom runner to build & push docker images on the registry
- gpu basic dev
- cpu basic dev
- gpu basic
- cpu basic
- gpu dev (SSE, AVX optimized)
- cpu dev (SSE, AVX optimized)Use a custom runner to build & push docker images on the registry
- gpu basic dev
- cpu basic dev
- gpu basic
- cpu basic
- gpu dev (SSE, AVX optimized)
- cpu dev (SSE, AVX optimized)https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/17gdal import (python)2022-04-05T19:55:32+02:00Cresson Remigdal import (python)see https://github.com/remicres/otbtf/issues/71see https://github.com/remicres/otbtf/issues/71Cresson RemiCresson Remihttps://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/18Add toy example to train a model with keras/otbtf dataset2022-07-28T07:35:49+02:00Cresson RemiAdd toy example to train a model with keras/otbtf datasetAdd an example how to train a model with keras, using some otbtf.datasets and saving the trained model as SavedModel.Add an example how to train a model with keras, using some otbtf.datasets and saving the trained model as SavedModel.https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/19Update release notes2022-04-05T19:55:32+02:00Cresson RemiUpdate release notescloses #17, #15, #19closes #17, #15, #19https://gitlab.irstea.fr/remi.cresson/otbtf/-/issues/20Add warning message when no output_shape or output_type is missing2022-09-14T09:06:30+02:00Cresson RemiAdd warning message when no output_shape or output_type is missing