Skip to content

Conversation

@tonywjs
Copy link

@tonywjs tonywjs commented Dec 8, 2025

Problem

The notebook fails with FileNotFoundError when running on Google Colab with recent versions of scikit-image (0.25.x+):

FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/scikit-image/0.25.2/data'

This occurs because newer versions of scikit-image use lazy loading for sample images, and the skimage.data_dir directory may not exist until images are explicitly loaded.

Solution

Replace the directory-based image loading approach with direct function calls from skimage.data module:

  • Instead of iterating over os.listdir(skimage.data_dir), use the corresponding skimage.data functions directly
  • For motorcycle_right, use skimage.data.stereo_motorcycle()[1] since it's provided as part of a stereo image pair

Changes

  • Added get_motorcycle_right() helper function to retrieve the right motorcycle image from stereo_motorcycle()
  • Created image_functions dictionary mapping image names to their loader functions
  • Modified the image loading loop to call functions directly instead of reading from filesystem

Testing

Tested on Google Colab with:

  • Python 3.12
  • scikit-image 0.25.2
  • PyTorch 2.9.0+cu126

…-image versions

### Problem

The notebook fails with FileNotFoundError when running on Google Colab with recent versions of scikit-image (0.25.x+):
```
FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/scikit-image/0.25.2/data'
```
This occurs because newer versions of scikit-image use lazy loading for sample images, and the skimage.data_dir directory may not exist until images are explicitly loaded.

### Solution

Replace the directory-based image loading approach with direct function calls from skimage.data module:

- Instead of iterating over os.listdir(skimage.data_dir), use the corresponding skimage.data functions directly
- For motorcycle_right, use skimage.data.stereo_motorcycle()[1] since it's provided as part of a stereo image pair

### Changes

- Added get_motorcycle_right() helper function to retrieve the right motorcycle image from stereo_motorcycle()
- Created image_functions dictionary mapping image names to their loader functions
- Modified the image loading loop to call functions directly instead of reading from filesystem

### Testing

Tested on Google Colab with:
- Python 3.12
- scikit-image 0.25.2
- PyTorch 2.9.0+cu126
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.

1 participant