Closed ghost closed 3 years ago
I also understand that torchvision has integration with libpng: https://github.com/pytorch/vision
But I could not find any example.
Hi!
so as you describe here, you are able to read images from disk to torch::tensor
s using stb_image but you are missing the conversion torch::tensor
-> s3d::Image
?
If that is the case, have you tried the available constructors of the Image
class in OpenSiv3D? I could find constructors taking s3d::FilePath
s and s3d::IReader
s (e.g.: s3d::BinaryReader
seems to be relevant for you) here.
So it might be worth trying to read torch::tensor
's data_ptr()
using s3d::BinaryReader
and passing that to the s3d::Image
constructor.
@mfl28 Thank you so much for your reply. I ended up writing a small lib: https://github.com/QuantScientist/PngTorch
I am going to test it with Siv3D, it works great independently.
Is your feature request related to a problem? Please describe. I am the author of Siv3DTorch (https://github.com/QuantScientist/Siv3DTorch) which integrates OpenSiv3d with Libtorch C++. At the moment Siv3D does not support CMake and therefore all integration efforts are on VC 19. One main burning issue that I have is reading and writing Images/video frames from and to Siv3D without using OpenCV.
Describe the solution you'd like I would love to have an Image conversation method between the two frameworks, either using stb_image or libpng (used by Siv3D).
Additional context The whole scenario is described here: https://github.com/Siv3D/OpenSiv3D/issues/534
The source code is here: https://github.com/QuantScientist/Siv3DTorch/blob/master/src/loadmodel003.cpp
Many thanks for your help,