diff --git a/.github/workflows/flip-deploy.yml b/.github/workflows/flip-deploy.yml index 6f25ac6..04c05ad 100644 --- a/.github/workflows/flip-deploy.yml +++ b/.github/workflows/flip-deploy.yml @@ -16,12 +16,11 @@ jobs: build_wheels: strategy: matrix: - # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, windows-latest, macos-13, macos-14] + os: [ubuntu-latest, windows-latest, macos-latest] python: [cp38, cp39, cp310, cp311, cp312, cp312_stable, cp313] exclude: # The first Python version to target Apple arm64 architectures is 3.9. - - os: macos-14 + - os: [macos-latest] python: cp38 name: > ${{ matrix.python }} wheel for ${{ matrix.os }} diff --git a/MODULE.bazel b/MODULE.bazel index cf5f0c2..3623d46 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -30,7 +30,29 @@ # SPDX-License-Identifier: BSD-3-Clause ################################################################################# +<<<<<<<< HEAD:src/CMakeLists.txt +cmake_minimum_required(VERSION 3.9) + +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_BUILD_TYPE_INIT "Release") + +project(flip LANGUAGES CXX) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +include(GNUInstallDirs) + +option(FLIP_ENABLE_CUDA "Include CUDA version of flip" OFF) + +add_subdirectory(cpp) +======== module( name = "flip", compatibility_level = 1, ) +>>>>>>>> upstream/main:MODULE.bazel diff --git a/README.md b/README.md index 5241817..9bb3672 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Teaser image](images/teaser.png "Teaser image") -# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.6) +# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.7) By [Pontus Ebelin](https://research.nvidia.com/person/pontus-ebelin) @@ -27,6 +27,8 @@ The changes made for the different versions of FLIP are summarized in the [versi [An image gallery](https://research.nvidia.com/node/3525) displaying a large quantity of reference/test images and corresponding error maps from different metrics. +**Note**: since v1.7, the automatic stop exposure in HDR-FLIP is able to handle reference images whose median luminance is 0. + **Note**: since v1.6, the Python version of FLIP can now be installed via `pip install flip-evaluator`. **Note**: in v1.3, we switched to a *single header* ([FLIP.h](src/cpp/FLIP.h)) for C++/CUDA for easier integration. @@ -136,4 +138,4 @@ Should your work use the FLIP tool in a more general fashion, please cite the Ra # Acknowledgements We appreciate the following peoples' contributions to this repository: -Jonathan Granskog, Jacob Munkberg, Jon Hasselgren, Jefferson Amstutz, Alan Wolfe, Killian Herveau, Vinh Truong, Philippe Dagobert, Hannes Hergeth, Matt Pharr, Tizian Zeltner, Jan Honsbrok, Chris Zhang, Wenzel Jakob, and Julian Amann. +Jonathan Granskog, Jacob Munkberg, Jon Hasselgren, Jefferson Amstutz, Alan Wolfe, Killian Herveau, Vinh Truong, Philippe Dagobert, Hannes Hergeth, Matt Pharr, Tizian Zeltner, Jan Honsbrok, Chris Zhang, Wenzel Jakob, Julian Amann, and Xijie Yang. diff --git a/misc/versionList.md b/misc/versionList.md index 92ad57b..27bb830 100644 --- a/misc/versionList.md +++ b/misc/versionList.md @@ -3,6 +3,11 @@ In addition to various minor changes, the following was changed for the different versions of FLIP: +# Version 1.7 (commit ?) +- Fixed memory leaks in the C++/CUDA/Python versions of FLIP. +- HDR-FLIP: Fixed crashes that followed from the reference's median being 0. + - Automatic start and stop exposures in HDR-FLIP are computed using statistics of the reference image. For the stop exposure, we use the median luminance of the reference. When that is 0, we used to get undefined behavior or a crash. Version 1.7 fixes this by clamping the median to have a minimum value of [FLT_EPSILON](https://learn.microsoft.com/en-us/cpp/c-language/limits-on-floating-point-constants?view=msvc-170). + # Version 1.6 (commit 7967578) - Flipped the ꟻ in ꟻLIP. The entire name (FLIP) should now be readable on all devices. - Published Python version of FLIP to PyPI (URL: https://pypi.org/project/flip-evaluator/). diff --git a/pyproject.toml b/pyproject.toml index 019073a..ed02803 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ ################################################################################# -# Copyright (c) 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2020-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES +# SPDX-FileCopyrightText: Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES # SPDX-License-Identifier: BSD-3-Clause ################################################################################# @@ -36,7 +36,7 @@ build-backend = "scikit_build_core.build" [project] name = "flip_evaluator" -version = "1.6.0.1" +version = "1.7" description = "A Difference Evaluator for Alternating Images" readme = "README.md" requires-python = ">=3.8" diff --git a/src/cpp/FLIP.h b/src/cpp/FLIP.h index 99d3d7e..8f7fefe 100644 --- a/src/cpp/FLIP.h +++ b/src/cpp/FLIP.h @@ -2227,6 +2227,7 @@ namespace FLIP size_t medianLocation = luminances.size() / 2; std::nth_element(luminances.begin(), luminances.begin() + medianLocation, luminances.end()); float Ymedian = luminances[medianLocation]; + Ymedian = std::max(Ymedian, std::numeric_limits::epsilon()); // Avoid median = 0 when more than half of the image's pixels are black. startExposure = log2(xMax / Ymax); stopExposure = log2(xMax / Ymedian); diff --git a/src/cpp/README.md b/src/cpp/README.md index 6f80409..991d51d 100644 --- a/src/cpp/README.md +++ b/src/cpp/README.md @@ -1,4 +1,4 @@ -# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.6) +# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.7) By [Pontus Ebelin](https://research.nvidia.com/person/pontus-ebelin) diff --git a/src/cpp/tool/FLIPToolHelpers.h b/src/cpp/tool/FLIPToolHelpers.h index 8605836..6c7a9cd 100644 --- a/src/cpp/tool/FLIPToolHelpers.h +++ b/src/cpp/tool/FLIPToolHelpers.h @@ -480,7 +480,7 @@ namespace FLIPTool std::string FLIPString = "FLIP"; int MajorVersion = 1; - int MinorVersion = 6; + int MinorVersion = 7; if (commandLine.optionSet("help")) { diff --git a/src/cpp/tool/imagehelpers.h b/src/cpp/tool/imagehelpers.h index 362f6b6..443bc0b 100644 --- a/src/cpp/tool/imagehelpers.h +++ b/src/cpp/tool/imagehelpers.h @@ -255,6 +255,7 @@ namespace ImageHelpers if (loadImage(fileName, imgWidth, imgHeight, pixels)) { dstImage.setPixels(pixels, imgWidth, imgHeight); + delete[] pixels; return true; } return false; @@ -343,16 +344,15 @@ namespace ImageHelpers const char* error; int ret = SaveEXRImageToFile(&exrImage, &exrHeader, fileName.c_str(), &error); + free(exrHeader.channels); + free(exrHeader.pixel_types); + free(exrHeader.requested_pixel_types); if (ret != TINYEXR_SUCCESS) { std::cerr << "Failed to save EXR file <" << fileName << ">: " << error << "\n"; return false; } - free(exrHeader.channels); - free(exrHeader.pixel_types); - free(exrHeader.requested_pixel_types); - return true; } } \ No newline at end of file diff --git a/src/python/README.md b/src/python/README.md index cad5b12..4a07f8e 100644 --- a/src/python/README.md +++ b/src/python/README.md @@ -1,4 +1,4 @@ -# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.6) +# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.7) By [Pontus Ebelin](https://research.nvidia.com/person/pontus-ebelin) diff --git a/src/pytorch/README.md b/src/pytorch/README.md index 5de1ec7..7dfabda 100644 --- a/src/pytorch/README.md +++ b/src/pytorch/README.md @@ -1,4 +1,4 @@ -# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.6) +# FLIP: A Tool for Visualizing and Communicating Errors in Rendered Images (v1.7) By [Pontus Ebelin](https://research.nvidia.com/person/pontus-ebelin) diff --git a/src/pytorch/flip_loss.py b/src/pytorch/flip_loss.py index e63a15a..687fb71 100644 --- a/src/pytorch/flip_loss.py +++ b/src/pytorch/flip_loss.py @@ -383,6 +383,7 @@ def compute_start_stop_exposures(reference, tone_mapper, tmax, tmin): dim = Y_reference.size() Y_ref = Y_reference.view(dim[0], dim[1], dim[2]*dim[3]) Y_lo = torch.median(Y_ref, dim=2).values.unsqueeze(2).unsqueeze(3) + Y_lo = torch.clamp(Y_lo, min=torch.finfo(torch.float32).eps) # Avoid median = 0 when more than half of the image's pixels are black. stop_exposure = torch.log2(x_min / Y_lo) return start_exposure, stop_exposure