Spaces:
Running on Zero
Running on Zero
Restore encode_remote
Browse files
app.py
CHANGED
|
@@ -177,6 +177,28 @@ def conditioner():
|
|
| 177 |
return Client(CONDITIONER_SPACE)
|
| 178 |
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
|
| 182 |
# Fitted on live probes (5 configs spanning canvas, duration and steps; max residual 3.7 s):
|
|
|
|
| 177 |
return Client(CONDITIONER_SPACE)
|
| 178 |
|
| 179 |
|
| 180 |
+
def encode_remote(prompt, image_path, last_image_path, canvas, num_frames, rewrite_prompt=False):
|
| 181 |
+
"""Ask the conditioner Space for `prompt_embeds` + `text_token_tags`. Off this Space's GPU time entirely.
|
| 182 |
+
|
| 183 |
+
`rewrite_prompt` asks the conditioner to rewrite the request into MiniMax-H3's trained format with its own
|
| 184 |
+
Qwen3-VL and encode that, handing the rewrite back under the plan's `refined_prompt`. It runs on the conditioner's
|
| 185 |
+
booking, and this call happens before `_generate` books a card here, so `get_duration` is unaffected.
|
| 186 |
+
"""
|
| 187 |
+
from gradio_client import handle_file
|
| 188 |
+
from safetensors import safe_open
|
| 189 |
+
|
| 190 |
+
path, plan = conditioner().predict(
|
| 191 |
+
prompt=prompt,
|
| 192 |
+
image_path=handle_file(image_path) if image_path else None,
|
| 193 |
+
last_image_path=handle_file(last_image_path) if last_image_path else None,
|
| 194 |
+
canvas=canvas,
|
| 195 |
+
num_frames=num_frames,
|
| 196 |
+
rewrite_prompt=bool(rewrite_prompt),
|
| 197 |
+
api_name="/encode",
|
| 198 |
+
)
|
| 199 |
+
with safe_open(path, framework="pt") as handle:
|
| 200 |
+
metadata = handle.metadata()
|
| 201 |
+
return handle.get_tensor("prompt_embeds"), handle.get_tensor("text_token_tags"), metadata, plan
|
| 202 |
|
| 203 |
|
| 204 |
# Fitted on live probes (5 configs spanning canvas, duration and steps; max residual 3.7 s):
|