bob.io.base issueshttps://gitlab.idiap.ch/bob/bob.io.base/-/issues2022-05-13T13:25:29Zhttps://gitlab.idiap.ch/bob/bob.io.base/-/issues/21HDF5File cannot read files written by keras/tensorflow2022-05-13T13:25:29ZManuel Günthersiebenkopf@googlemail.comHDF5File cannot read files written by keras/tensorflowI have just tried to train a model with keras/tensorflow, where I wanted to add some information to the HDF5 file. Unfortunately, an exception is raised when I try to open the file [model.hdf5](/uploads/699cb6d243d8f94472b09905df8f3ab0/m...I have just tried to train a model with keras/tensorflow, where I wanted to add some information to the HDF5 file. Unfortunately, an exception is raised when I try to open the file [model.hdf5](/uploads/699cb6d243d8f94472b09905df8f3ab0/model.hdf5):
```
>>> import bob.io.base
>>> h = bob.io.base.HDF5File("model.hdf5")
RuntimeError: HDF5File - hdf5 constructor: C++ exception caught: 'empty HDF5 dataset'
```
In some cases (which I cannot reproduce here), I even get a `Segmentation fault` crashing the Python console.
Note that the file is perfectly valid, you can open it with `hdfview` and `h5py`:
```
>>> import h5py
>>> h = h5py.File("model.hdf5")
>>> list(h.keys())
['model_weights', 'optimizer_weights']
```
I am not sure, what causes this issue. I haven't dug deeper into the code.https://gitlab.idiap.ch/bob/bob.io.base/-/issues/14automatic array casting in C++ does not work2017-10-24T05:02:23ZManuel Günthersiebenkopf@googlemail.comautomatic array casting in C++ does not workI try to read .png images in ``uint8_t``, regardless of their actual internal representation, i.e., 8 or 16 bit, in C++. In the current way, when I try to read a uint16 .png image using ``bob::io::image::read_color_image`` I get:
```
c...I try to read .png images in ``uint8_t``, regardless of their actual internal representation, i.e., 8 or 16 bit, in C++. In the current way, when I try to read a uint16 .png image using ``bob::io::image::read_color_image`` I get:
```
cannot efficiently retrieve blitz::Array<uint8,3> from buffer of type 'dtype: uint16 (2); shape: [3,606,544]; size: 1977984 bytes'
```
After reading code a little bit, I found that in https://gitlab.idiap.ch/bob/bob.io.image/blob/master/bob/io/image/include/bob.io.image/png.h#L99 I could simply replace:
```
png.read<T,N>(0);
```
with:
```
png.cast<T,N>(0);
```
Theoretically, this should read the data in any format by resetting the image buffer to the type inside the image (uint16):
https://gitlab.idiap.ch/bob/bob.io.image/blob/master/bob/io/image/cpp/png.cpp#L499
read the data, and then cast it back to the desired type:
https://gitlab.idiap.ch/bob/bob.io.base/blob/master/bob/io/base/include/bob.io.base/blitz_array.h#L246
Unfortunately, this doesn't compile, it gives me the error:
```
bob/io/base/include/bob.io.base/blitz_array.h:247:49: error: no matching function for call to ‘cast(const bob::io::base::array::blitz_array&)’
```
Again, reading more code, I figured out that this function doesn't exists in that namespace, but that:
```
return bob::core::array::cast<T,N>(*this);
```
in https://gitlab.idiap.ch/bob/bob.io.base/blob/master/bob/io/base/include/bob.io.base/blitz_array.h#L247 should rather be:
```
return bob::io::base::array::cast<T,N>(*this);
```
Now, this doesn't compile either, it gives me the error:
```
bob/core/include/bob.core/cast.h:23:30: error: invalid static_cast from type ‘const std::complex<float>’ to type ‘unsigned char’
```
(https://gitlab.idiap.ch/bob/bob.core/blob/master/bob/core/include/bob.core/cast.h#L23) which, in the first place looks weired, as I don't deal with complex numbers at all. However, when reading the backtrace, the code here:
https://gitlab.idiap.ch/bob/bob.io.base/blob/master/bob/io/base/include/bob.io.base/array_utils.h#L117
tries to cast anything into anything, which in my case is ``complex<float>`` into ``uint8_t``, which raises the compiler error from above.
So, my question is: was this array casting being tested in any way, and has it been working before? Has anyone ever tried to use the ``bob::io::base::array::cast`` function? André AnjosAndré Anjoshttps://gitlab.idiap.ch/bob/bob.io.base/-/issues/10bob.io.base.test_file.test_peek segfaults with error 112017-10-24T05:02:23ZAndré Anjosbob.io.base.test_file.test_peek segfaults with error 11*Created by: 183amir*
The full log is available here (https://travis-ci.org/conda-forge/staged-recipes/jobs/122066381). Note that this happens only on Mac OSX.*Created by: 183amir*
The full log is available here (https://travis-ci.org/conda-forge/staged-recipes/jobs/122066381). Note that this happens only on Mac OSX.https://gitlab.idiap.ch/bob/bob.io.base/-/issues/9Bob nightlies are failling2017-10-24T05:02:23ZAndré AnjosBob nightlies are failling*Created by: tiagofrepereira2012*
As you can see here, our nightlies is broken (just one example).
https://gitlab.idiap.ch/biometric/bob.nightlies/builds/2355
Follow bellow a short example on how to reproduce the error
```
impo...*Created by: tiagofrepereira2012*
As you can see here, our nightlies is broken (just one example).
https://gitlab.idiap.ch/biometric/bob.nightlies/builds/2355
Follow bellow a short example on how to reproduce the error
```
import numpy
from bob.io.base import File
a3 = numpy.random.normal(size=(3,4)).astype('complex128') #not supported
File("xuxu.bindata",'w').write(a3)
```
Debugging a bit (With André's help), I found that a runtime error is raised here (https://github.com/bioidiap/bob.io.base/blob/master/bob/io/base/file.cpp#L412) and we have a catch here (https://github.com/bioidiap/bob.io.base/blob/master/bob/io/base/file.cpp#L415) ready to catch the std::runtime_error, but for some reason this macro is not working (the macro is defined at this point of the code).
If you explicitly set do try{}catch(...){} in (https://github.com/bioidiap/bob.io.base/blob/master/bob/io/base/file.cpp#L412) and raise a PyExc_RuntimeError (which is exactly the macro does) the code just work nice.
I don't know what is going on here.https://gitlab.idiap.ch/bob/bob.io.base/-/issues/6Cannot write non-continguous numpy view using bob.io.base.save()2017-10-24T05:02:23ZAndré AnjosCannot write non-continguous numpy view using bob.io.base.save()*Created by: anjos*
This will not work as expected:
```
import bob.io.base
import bob.io.image
image = bob.io.base.load('lena.jpg')
bob.io.base.save(image[:, 30:50, 30:50], 'patch.bmp')
```
We need to create a test unit and...*Created by: anjos*
This will not work as expected:
```
import bob.io.base
import bob.io.image
image = bob.io.base.load('lena.jpg')
bob.io.base.save(image[:, 30:50, 30:50], 'patch.bmp')
```
We need to create a test unit and fix this issue before the next relese.