fix: resolve multiple open issues (#11, #19, #20, #7/#12/#16/#23)#27
Draft
fix: resolve multiple open issues (#11, #19, #20, #7/#12/#16/#23)#27
Conversation
Extract utility functions from models/__init__.py into a dedicated util.py module to break the circular import chain: __init__.py -> dist_model -> networks_basic -> __init__.py - Create codes/metrics/LPIPS/models/util.py with shared helper functions - Update __init__.py to import from util.py and use lazy import for dist_model - Update networks_basic.py to use relative import 'from . import util' - Update dist_model.py to use relative import 'from . import util' - Ensure codes/metrics/__init__.py and codes/metrics/LPIPS/__init__.py exist Co-authored-by: Thmen <Thmen@users.noreply.github.com>
…t protection (fixes #20) - Change metric_calculator to accept both png and jpg image files (consistent with PairedFolderDataset which already accepts both) - Add warning when no GT image files are found in a directory - Add protection against averaging empty metric lists (prevents NaN) - Replace bare except clauses in main.py with proper exception handling - Show clear warning messages instead of silent failures Co-authored-by: Thmen <Thmen@users.noreply.github.com>
…ile.sh (fixes #19) - Add usage examples and argument descriptions to both scripts - Add input validation with helpful error messages - Add directory existence checks before running - Users no longer need to guess the correct command format Co-authored-by: Thmen <Thmen@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses several open issues in the EGVSR repository with code fixes and documentation improvements.
Issues Fixed
Fix #11: Circular import in LPIPS module (
profile.shfails withAttributeError)Problem: Running
profile.sh(or any code importing LPIPS) fails with:This was caused by a circular import chain:
models/__init__.py→dist_model→networks_basic→metrics.LPIPS.models(same__init__.pystill loading).Solution: Extract utility functions (
normalize_tensor,tensor2im,l2, etc.) frommodels/__init__.pyinto a dedicatedutil.pymodule. Updatenetworks_basic.pyanddist_model.pyto use relative imports (from . import util) instead of absolute imports that trigger circular dependencies. ThePerceptualLossclass now uses lazy import fordist_model.Fix #20: NaN metrics when running
test.shProblem: All metrics (PSNR, LPIPS, tOF) show as NaN with warnings about "Mean of empty slice".
Root causes & solutions:
metric_calculator.pyonly searched for.pngfiles in GT directories, but data could be in.jpgformat (the dataset loader already supported both). Fixed to acceptpng|jpg.except:clauses inmain.pysilently swallowed all errors during metric computation, making debugging impossible. Replaced withexcept Exception as e:and proper logging.Fix #19:
test.shusage unclearProblem: Users didn't know how to properly invoke
test.shandprofile.sh.Solution: Added usage instructions, argument descriptions, examples, and input validation with helpful error messages to both scripts.
Fix #7, #12, #16, #23: Testing dataset download links broken
Problem: The Baidu Netdisk download link for testing datasets (Vid4, ToS3, Gvt72) is no longer available.
Solution: Updated README to mark the link as defunct and provide alternative guidance for obtaining the datasets.
Changes
codes/metrics/LPIPS/models/util.pycodes/metrics/LPIPS/models/__init__.pyutil.py, lazy import fordist_modelcodes/metrics/LPIPS/models/dist_model.pyutilcodes/metrics/LPIPS/models/networks_basic.pyutilcodes/metrics/metric_calculator.pycodes/main.pytest.shprofile.shREADME.md