Skip to content

Fix checkpoint loading IsADirectoryError#10

Open
wang-h wants to merge 1 commit intoHINTLab:mainfrom
wang-h:fix-checkpoint-loading
Open

Fix checkpoint loading IsADirectoryError#10
wang-h wants to merge 1 commit intoHINTLab:mainfrom
wang-h:fix-checkpoint-loading

Conversation

@wang-h
Copy link

@wang-h wang-h commented Mar 9, 2026

Bug Fix

This PR fixes #5 and #6 - the IsADirectoryError when loading pretrained encoders.

Problem

When checkpoint_filename in the config points to a directory (e.g., point_encoder), the code fails with:

Solution

Added two helper functions:

  1. resolve_checkpoint_path(path) - Smart path resolver:

    • If path is a file → return as-is
    • If path is a directory → search for *.pkl, *.pt, *.pth files
    • Returns None if not found
  2. get_save_path(path, default_filename) - Smart save path handler:

    • If path is a directory → append default filename
    • Ensures parent directories exist

Changes

  • Improved error messages when checkpoints not found
  • Auto-detection of model files in checkpoint directories
  • Backward compatible with existing file paths

Testing

  • Test loading from directory containing .pkl file
  • Test loading from explicit file path (backward compat)
  • Test saving to directory path
  • Test saving to explicit file path

- Add resolve_checkpoint_path() to auto-detect model files in directories
- Add get_save_path() to handle directory paths when saving
- Support .pkl, .pt, .pth file extensions
- Better error messages when checkpoints not found
- Fixes IsADirectoryError when checkpoint_filename points to directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in pipeline when we try to read checkpoint models

1 participant