invoke-ai/InvokeAI · error · ImageFileNotFoundException

ImageFileNotFoundException

Error message

ImageFileNotFoundException

What it means

ImageFilesDisk.get() could not find the image file on disk when attempting to load a PIL image. The underlying FileNotFoundError is chained as the cause. This service is the storage layer for generated/uploaded images in InvokeAI, so the error means the requested image name/path does not resolve to an existing file.

Source

Thrown at invokeai/app/services/image_files/image_files_disk.py:125

        try:
            image_path = self.get_path(image_name, image_subfolder=image_subfolder)

            cache_item = self.__get_cache(image_path)
            if cache_item:
                return cache_item

            image = Image.open(image_path)
            # Image.open() is lazy: it reads the header but defers pixel decoding (and holds the
            # file handle open) until the first .load()/.copy()/.convert(). The opened object is
            # cached and the SAME object is handed to every caller, so in multi-GPU parallel mode
            # two worker threads can call .copy() on it concurrently and race on the shared file
            # handle and decoder state, producing "broken data stream" / "self.png is not None"
            # errors. Forcing the decode here makes the cached object safe for concurrent reads.
            image.load()
            self.__set_cache(image_path, image)
            return image
        except FileNotFoundError as e:
            raise ImageFileNotFoundException from e

    def save(
        self,
        image: PILImageType,
        image_name: str,
        metadata: Optional[str] = None,
        workflow: Optional[str] = None,
        graph: Optional[str] = None,
        thumbnail_size: int = 256,
        image_subfolder: str = "",
    ) -> None:
        image_path: Optional[Path] = None
        thumbnail_path: Optional[Path] = None
        image_existed = False
        thumbnail_existed = False
        try:
            self.__validate_storage_folders()
            image_path = self.get_path(image_name, image_subfolder=image_subfolder)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Confirm the image file exists at the resolved path (get_path(image_name, ...)) and that image_name/subfolder are correct
  2. Delete the stale image record via the API if the file is genuinely gone, so DB and disk re-sync
  3. Check whether a staged delete committed while the record remained, and restore the file from backup if needed
  4. Verify the output folder configuration points at the same directory used when the image was saved

Example fix

// before
image = services.images.get(image_name)
// after
from invokeai.app.services.images.images_common import ImageFileNotFoundException
try:
    image = services.images.get(image_name)
except ImageFileNotFoundException:
    services.images.delete_image_on_record_missing(image_name)  # or handle gracefully
Defensive patterns

Strategy: try-catch

Validate before calling

from pathlib import Path
path = services.images.get_path(image_name, image_subfolder=subfolder)
if not Path(path).exists():
    # record is stale; skip or clean up instead of loading
    ...

Try / catch

try:
    image = services.images.get(image_name)
except ImageFileNotFoundException:
    logger.warning(f"image file missing on disk: {image_name}")
    handle_missing_image(image_name)  # skip, regenerate, or purge the record

Prevention

When it happens

Trigger: Calling get(image_name) (or indirectly via graph/workflow execution paths like get_workflow/get_graph) for an image whose file was deleted, never saved, or whose name/subfolder path does not exist under the output folder.

Common situations: Database record out of sync with disk (image deleted manually or by an external cleanup); images moved between flat/subfolder layouts after a migration; stale cache or board references pointing at removed files; interrupted staged deletes leaving records without files.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/64c350ff1d76faf5. Report an issue: GitHub.