ATH-MaaS/Pixelle-Video · error · FileNotFoundError

参考图片不存在: {ref_image_path}

Error message

参考图片不存在: {ref_image_path}

What it means

generate_video iterates the reference_image_paths list and raises FileNotFoundError for the first entry that does not exist on disk. Same fail-fast validation, applied per-element of the multi-reference list.

Source

Thrown at pixelle_video/services/api_services/video_dashscope.py:189

        Raises:
            FileNotFoundError: 输入图片不存在
            RuntimeError: API 调用或下载失败
        """
        if VideoSynthesis is None:
            raise RuntimeError("dashscope package not installed. Run: pip install dashscope")

        if image_path and not os.path.exists(image_path):
            raise FileNotFoundError(f"输入图片不存在: {image_path}")
        if last_image_path and not os.path.exists(last_image_path):
            raise FileNotFoundError(f"尾帧图片不存在: {last_image_path}")
        if first_clip_path and not os.path.exists(first_clip_path):
            raise FileNotFoundError(f"输入视频片段不存在: {first_clip_path}")
        if reference_image_path and not os.path.exists(reference_image_path):
            raise FileNotFoundError(f"参考图片不存在: {reference_image_path}")
        for ref_image_path in reference_image_paths or []:
            if ref_image_path and not os.path.exists(ref_image_path):
                raise FileNotFoundError(f"参考图片不存在: {ref_image_path}")
        for ref_video_path in reference_video_paths or []:
            if ref_video_path and not os.path.exists(ref_video_path):
                raise FileNotFoundError(f"参考视频不存在: {ref_video_path}")
        if reference_audio_path and not os.path.exists(reference_audio_path):
            raise FileNotFoundError(f"参考音频不存在: {reference_audio_path}")
        if audio_path and not os.path.exists(audio_path):
            raise FileNotFoundError(f"驱动音频不存在: {audio_path}")

        logger.info(f"DashscopeVideoClient: model={model}, prompt={prompt[:60]}...")

        if self._is_text_to_video_model(model):
            call_kwargs = {
                "api_key": self.api_key,
                "model": model,
                "prompt": prompt,
                "duration": duration,
                "watermark": watermark,
            }

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Loop over reference_image_paths with os.path.exists and filter/fix missing entries before calling
  2. Re-upload the missing reference images and rebuild the list
  3. Log all resolved paths to find which entry is stale
  4. Make list construction defensive (only include files that exist) if missing refs are acceptable

Example fix

// before
paths = ['refs/a.jpg', 'refs/b.jpg', 'refs/gone.jpg']
client.generate_video(prompt, reference_image_paths=paths)  # FileNotFoundError: refs/gone.jpg
// after
paths = [p for p in paths if os.path.exists(p)]
if paths:
    client.generate_video(prompt, reference_image_paths=paths)
Defensive patterns

Strategy: validation

Validate before calling

import os
missing = [p for p in (reference_image_paths or []) if p and not os.path.isfile(p)]
if missing:
    raise FileNotFoundError(f'参考图片不存在: {missing}')

Type guard

def all_files_exist(paths) -> bool:
    return all(isinstance(p, str) and os.path.isfile(p) for p in (paths or []))

Try / catch

try:
    video = client.generate_video(prompt, reference_image_paths=refs)
except FileNotFoundError as e:
    logging.error(f'Reference image missing: {e}')
    refs = [p for p in refs if os.path.isfile(p)]  # drop stale entries and retry
    video = client.generate_video(prompt, reference_image_paths=refs) if refs else None

Prevention

When it happens

Trigger: generate_video(..., reference_image_paths=['a.jpg','b.jpg','c.jpg'], ...) where any listed file is missing — the error message names the offending ref_image_path.

Common situations: Batch paths built from a config/database where some files were purged; one item in the list has a typo; moved directory after the list was built; partial upload of a reference set.

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 ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/a129e6bd250df5f4. Report an issue: GitHub.