-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add image with raw pixel data #20
Comments
Not yet, it has to be encoded into one of the supported formats first. |
Hi, I was trying to encode raw pixels data to png format and send it to int out_len = 0;
int width = t.size(0), height = t.size(1), channel = t.size(2);
auto encoded_bytes = stbi_write_png_to_mem((const unsigned char*)v.data(), 0, height, width, channel, &out_len);
std::string png(encoded_bytes, encoded_bytes+out_len);
logger.add_image("Tensor raw data plugin", 1, png, height, width, channel, "imrod");
std::ofstream file("./demo/imord.png", std::ios::binary);
file << png; where I found that the |
Thanks for the feedback, I will try to look into this as soon as possible. Maybe you can do a quick inspection to do a round trip by |
I just tried this, and it worked: diff --git a/CMakeLists.txt b/CMakeLists.txt
index b99ba57..7b885d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,3 +23,7 @@ target_link_libraries(tensorboard_logger PUBLIC ${Protobuf_LIBRARIES})
add_executable(tensorboard_logger_test tests/test_tensorboard_logger.cc)
target_link_libraries(tensorboard_logger_test tensorboard_logger)
+target_include_directories(tensorboard_logger_test PUBLIC
+ ../stb/deprecated/
+ ../stb/
+)
diff --git a/tests/test_tensorboard_logger.cc b/tests/test_tensorboard_logger.cc
index d9f1f3e..bde9d07 100644
--- a/tests/test_tensorboard_logger.cc
+++ b/tests/test_tensorboard_logger.cc
@@ -5,6 +5,14 @@
#include <vector>
#include "tensorboard_logger.h"
+#define STB_IMAGE_WRITE_IMPLEMENTATION
+#include "stb_image_write.h"
+
+#define STB_IMAGE_IMPLEMENTATION
+#include "stb_image.h"
+
+#define STB_DEFINE
+#include "stb.h"
using namespace std;
@@ -57,6 +65,21 @@ int test_log_image(TensorBoardLogger& logger) {
logger.add_image("TensorBoard Audo Plugin", 1, image2, 1766, 814, 3,
"TensorBoard", "Audio");
+ // add image from memory
+ int x, y, c, size;
+ const char* test_file = "tux.png";
+ auto image3 = stbi_load(test_file, &x, &y, &c, 0);
+ auto encoded = stbi_write_png_to_mem(image3, 0, x, y, c, &size);
+ cout << test_file << " x=" << x << " y=" << y << " c=" << c <<
+ " re-encoded size=" << size << endl;
+ string png(encoded, encoded + size);
+ logger.add_image("image from memory", 1, png, x, y, c, "Tux");
+ ofstream file("reencoded_tux.png", ios::binary);
+ file << png;
+ file.close();
+ stbi_image_free(image3);
+ STBIW_FREE(encoded);
+
// add multiple images
// FIXME This seems doesn't work anymore.
// logger.add_images( Test file is this one https://cdn.freebiesupply.com/logos/large/2x/tux-logo-png-transparent.png |
I know what happened why tensorboard didn't detect the event file. From this issue #13, I found that my target ouput filename did not have a substring like |
🤦 I'm planning to add a warning message if the file name is not valid. |
What about assert if the filename does not have substring "tfevents"? |
Yes, on second thought I think throwing a |
Hi, I read all codes in the test file that I actually didn't find an example to save images with its raw pixel data.
Does it already supported or not?
The text was updated successfully, but these errors were encountered: