Nymbo commited on
Commit
fb9344d
·
verified ·
1 Parent(s): a79f923

fixing video generation pipeline

Browse files
Files changed (1) hide show
  1. Modules/Generate_Video.py +12 -5
Modules/Generate_Video.py CHANGED
@@ -59,7 +59,7 @@ def Generate_Video(
59
  width: Annotated[int, "Output width in pixels (multiples of 8 recommended)."] = 768,
60
  height: Annotated[int, "Output height in pixels (multiples of 8 recommended)."] = 768,
61
  fps: Annotated[int, "Frames per second of the output video (e.g., 24)."] = 24,
62
- duration: Annotated[float, "Target duration in seconds (provider/model dependent, commonly 2–6s)."] = 4.0,
63
  ) -> str:
64
  _log_call_start(
65
  "Generate_Video",
@@ -111,10 +111,10 @@ def Generate_Video(
111
  extra_body=extra_body if extra_body else None,
112
  )
113
  else:
114
- result = client.post(
115
- model=model_id,
116
- json={"inputs": prompt, "parameters": {k: v for k, v in parameters.items() if v is not None}},
117
- )
118
  path = _write_video_tmp(result, suffix=".mp4")
119
  try:
120
  size = os.path.getsize(path)
@@ -122,6 +122,13 @@ def Generate_Video(
122
  size = -1
123
  _log_call_end("Generate_Video", f"provider={provider} path={os.path.basename(path)} bytes={size}")
124
  return path
 
 
 
 
 
 
 
125
  except Exception as exc: # pylint: disable=broad-except
126
  last_error = exc
127
  continue
 
59
  width: Annotated[int, "Output width in pixels (multiples of 8 recommended)."] = 768,
60
  height: Annotated[int, "Output height in pixels (multiples of 8 recommended)."] = 768,
61
  fps: Annotated[int, "Frames per second of the output video (e.g., 24)."] = 24,
62
+ duration: Annotated[float, "Target duration in seconds. For Sora-2, must be 4, 8, or 12."] = 4.0,
63
  ) -> str:
64
  _log_call_start(
65
  "Generate_Video",
 
111
  extra_body=extra_body if extra_body else None,
112
  )
113
  else:
114
+ # Fallback for older clients or specific providers if needed, though InferenceClient usually has text_to_video
115
+ # Note: client.post is not available in some versions of InferenceClient
116
+ continue
117
+
118
  path = _write_video_tmp(result, suffix=".mp4")
119
  try:
120
  size = os.path.getsize(path)
 
122
  size = -1
123
  _log_call_end("Generate_Video", f"provider={provider} path={os.path.basename(path)} bytes={size}")
124
  return path
125
+ except KeyError as exc:
126
+ # Handle specific provider errors that manifest as KeyError (e.g. fal-ai missing 'video' key on error)
127
+ if "video" in str(exc):
128
+ last_error = ValueError(f"Provider {provider} returned an invalid response. This often happens with invalid parameters (e.g. duration must be 4, 8, or 12 for Sora-2).")
129
+ else:
130
+ last_error = exc
131
+ continue
132
  except Exception as exc: # pylint: disable=broad-except
133
  last_error = exc
134
  continue