Skip to content

Hardcoded ImageNet labels path causes FileNotFoundError #2

@sjoerdgunneweg

Description

@sjoerdgunneweg

FileNotFoundError due to hardcoded Imagenet1k_labels.txt path in loaders.py

Error

  File "/modernvbert/src/modernvbert/contrastive_training/evaluate.py", line 16, in <module>
    from config import load_config
  File "/modernvbert/src/modernvbert/contrastive_training/config.py", line 24, in <module>
    from loaders import *
  File "/modernvbert/src/modernvbert/contrastive_training/loaders.py", line 22, in <module>
    IMAGENET_LABELS = Path("/lustre/fswork/projects/rech/nwd/uyn61im/repos/mteb-vlm/mteb/tasks/Image/ZeroShotClassification/eng/templates/Imagenet1k_labels.txt").read_text().splitlines()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scur1716/.conda/envs/issues/lib/python3.12/pathlib.py", line 1028, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scur1716/.conda/envs/issues/lib/python3.12/pathlib.py", line 1014, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/lustre/fswork/projects/rech/nwd/uyn61im/repos/mteb-vlm/mteb/tasks/Image/ZeroShotClassification/eng/templates/Imagenet1k_labels.txt'

Investigation

evaluate.py imports load_config from config.py
config.py does from loaders import *
n loaders.py, lines 22–26 attempt to read a hardcoded absolute path to Imagenet1k_labels.txt

Workaround

Commenting out lines 22–26 in loaders.py resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions