diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 5ada4e5..02597c1 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -18,7 +18,7 @@ set(CXXOPTS_ENABLE_INSTALL OFF CACHE BOOL "Generate the install target" FORCE) FetchContent_MakeAvailable(extern_cxxopts) -foreach(STB_IMAGE_LIB "stb_image" "stb_image_write" "stb_image_resize") +foreach(STB_IMAGE_LIB "stb_image" "stb_image_write" "stb_image_resize2") FetchContent_Declare( extern_${STB_IMAGE_LIB} URL https://raw.githubusercontent.com/nothings/stb/master/${STB_IMAGE_LIB}.h diff --git a/utils/image_io/CMakeLists.txt b/utils/image_io/CMakeLists.txt index e3d8f5e..0b50340 100644 --- a/utils/image_io/CMakeLists.txt +++ b/utils/image_io/CMakeLists.txt @@ -13,7 +13,7 @@ target_sources(image-io PUBLIC src/image_io.cpp ) target_include_directories(image-io PUBLIC include) -target_link_libraries(image-io ${TORCH_LIBRARIES} stb-image stb-image-write stb-image-resize) +target_link_libraries(image-io ${TORCH_LIBRARIES} stb-image stb-image-write stb-image-resize2) set_target_properties(image-io PROPERTIES CXX_STANDARD 14 diff --git a/utils/image_io/src/image_io.cpp b/utils/image_io/src/image_io.cpp index 2a3f8f4..197ba7a 100644 --- a/utils/image_io/src/image_io.cpp +++ b/utils/image_io/src/image_io.cpp @@ -9,7 +9,7 @@ #include "stb_image_write.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION -#include "stb_image_resize.h" +#include "stb_image_resize2.h" namespace image_io { namespace { @@ -165,8 +165,8 @@ torch::Tensor load_image(const std::string& file_path, std::vector image_resized_buffer(buffer_size); - stbir_resize_uint8(image_raw.get(), width, height, 0, - image_resized_buffer.data(), new_width, new_height, 0, depth); + stbir_resize_uint8_linear(image_raw.get(), width, height, 0, + image_resized_buffer.data(), new_width, new_height, 0, static_cast(depth)); return transform(torch::from_blob(image_resized_buffer.data(), {new_height, new_width, depth}, torch::kUInt8).clone().to(torch::kFloat32).permute({2, 0, 1}).div_(255));