Nymbo commited on
Commit
9c65006
·
verified ·
1 Parent(s): 3024225

Update Modules/Generate_Video.py

Browse files
Files changed (1) hide show
  1. Modules/Generate_Video.py +5 -5
Modules/Generate_Video.py CHANGED
@@ -54,7 +54,7 @@ def _write_video_tmp(data_iter_or_bytes: object, suffix: str = ".mp4") -> str:
54
  )
55
  def Generate_Video(
56
  prompt: Annotated[str, "Text description of the video to generate (e.g., 'a red fox running through a snowy forest at sunrise')."],
57
- model_id: Annotated[str, "Hugging Face model id in the form 'creator/model-name'. Defaults to akhaliq/sora-2."] = "akhaliq/sora-2",
58
  negative_prompt: Annotated[str, "What should NOT appear in the video."] = "",
59
  steps: Annotated[int, "Number of denoising steps (1–100). Higher can improve quality but is slower."] = 25,
60
  cfg_scale: Annotated[float, "Guidance scale (1–20). Higher = follow the prompt more closely, lower = more creative."] = 3.5,
@@ -62,7 +62,7 @@ def Generate_Video(
62
  width: Annotated[int, "Output width in pixels (multiples of 8 recommended)."] = 768,
63
  height: Annotated[int, "Output height in pixels (multiples of 8 recommended)."] = 768,
64
  fps: Annotated[int, "Frames per second of the output video (e.g., 24)."] = 24,
65
- duration: Annotated[float, "Target duration in seconds. For Sora-2, must be 4, 8, or 12."] = 4.0,
66
  ) -> str:
67
  _log_call_start(
68
  "Generate_Video",
@@ -127,7 +127,7 @@ def Generate_Video(
127
  except KeyError as exc:
128
  # Handle specific provider errors that manifest as KeyError (e.g. fal-ai missing 'video' key on error)
129
  if "video" in str(exc):
130
- 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).")
131
  else:
132
  last_error = exc
133
  continue
@@ -146,7 +146,7 @@ def build_interface() -> gr.Interface:
146
  gr.Textbox(label="Prompt", placeholder="Enter a prompt for the video", lines=2, info="Text description of the video to generate"),
147
  gr.Textbox(
148
  label="Model",
149
- value="akhaliq/sora-2",
150
  placeholder="creator/model-name",
151
  max_lines=1,
152
  info="<a href=\"https://huggingface.co/models?pipeline_tag=text-to-video&inference_provider=nebius,cerebras,novita,fireworks-ai,together,fal-ai,groq,featherless-ai,nscale,hyperbolic,sambanova,cohere,replicate,scaleway,publicai,hf-inference&sort=trending\" target=\"_blank\" rel=\"noopener noreferrer\">Browse models</a>",
@@ -164,7 +164,7 @@ def build_interface() -> gr.Interface:
164
  title="Generate Video",
165
  description=(
166
  "<div style=\"text-align:center\">Generate short videos via Hugging Face serverless inference. "
167
- "Default model is Sora-2.</div>"
168
  ),
169
  api_description=TOOL_SUMMARY,
170
  flagging_mode="never",
 
54
  )
55
  def Generate_Video(
56
  prompt: Annotated[str, "Text description of the video to generate (e.g., 'a red fox running through a snowy forest at sunrise')."],
57
+ model_id: Annotated[str, "Hugging Face model id in the form 'creator/model-name'. Defaults to Wan-AI/Wan2.2-T2V-A14B."] = "Wan-AI/Wan2.2-T2V-A14B",
58
  negative_prompt: Annotated[str, "What should NOT appear in the video."] = "",
59
  steps: Annotated[int, "Number of denoising steps (1–100). Higher can improve quality but is slower."] = 25,
60
  cfg_scale: Annotated[float, "Guidance scale (1–20). Higher = follow the prompt more closely, lower = more creative."] = 3.5,
 
62
  width: Annotated[int, "Output width in pixels (multiples of 8 recommended)."] = 768,
63
  height: Annotated[int, "Output height in pixels (multiples of 8 recommended)."] = 768,
64
  fps: Annotated[int, "Frames per second of the output video (e.g., 24)."] = 24,
65
+ duration: Annotated[float, "Target duration in seconds, default 4."] = 4.0,
66
  ) -> str:
67
  _log_call_start(
68
  "Generate_Video",
 
127
  except KeyError as exc:
128
  # Handle specific provider errors that manifest as KeyError (e.g. fal-ai missing 'video' key on error)
129
  if "video" in str(exc):
130
+ last_error = ValueError(f"Provider {provider} returned an invalid response. This often happens with invalid parameters.")
131
  else:
132
  last_error = exc
133
  continue
 
146
  gr.Textbox(label="Prompt", placeholder="Enter a prompt for the video", lines=2, info="Text description of the video to generate"),
147
  gr.Textbox(
148
  label="Model",
149
+ value="Wan-AI/Wan2.2-T2V-A14B",
150
  placeholder="creator/model-name",
151
  max_lines=1,
152
  info="<a href=\"https://huggingface.co/models?pipeline_tag=text-to-video&inference_provider=nebius,cerebras,novita,fireworks-ai,together,fal-ai,groq,featherless-ai,nscale,hyperbolic,sambanova,cohere,replicate,scaleway,publicai,hf-inference&sort=trending\" target=\"_blank\" rel=\"noopener noreferrer\">Browse models</a>",
 
164
  title="Generate Video",
165
  description=(
166
  "<div style=\"text-align:center\">Generate short videos via Hugging Face serverless inference. "
167
+ "Default model is Wan2.2-T2V-A14B.</div>"
168
  ),
169
  api_description=TOOL_SUMMARY,
170
  flagging_mode="never",