Disable torch.compile and fix video display
All checks were successful
Build and Push Docker Image / build (push) Successful in 33m17s
All checks were successful
Build and Push Docker Image / build (push) Successful in 33m17s
- Disable torch.compile (inductor -> disabled) to reduce cold start time - Fix handler to detect video type from file extension, not output key - Fix HTML to check filename extension for video display 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
15
handler.py
15
handler.py
@@ -341,6 +341,14 @@ def poll_for_completion(prompt_id: str, timeout: int = MAX_TIMEOUT) -> dict:
|
|||||||
raise TimeoutError(f"Workflow execution timed out after {timeout}s")
|
raise TimeoutError(f"Workflow execution timed out after {timeout}s")
|
||||||
|
|
||||||
|
|
||||||
|
def get_file_type(filename: str) -> str:
|
||||||
|
"""Determine file type from extension."""
|
||||||
|
ext = Path(filename).suffix.lower()
|
||||||
|
if ext in [".mp4", ".webm", ".gif", ".mov", ".avi", ".mkv"]:
|
||||||
|
return "video"
|
||||||
|
return "image"
|
||||||
|
|
||||||
|
|
||||||
def get_output_files(history: dict) -> list:
|
def get_output_files(history: dict) -> list:
|
||||||
"""Extract output file info from history."""
|
"""Extract output file info from history."""
|
||||||
outputs = []
|
outputs = []
|
||||||
@@ -349,12 +357,13 @@ def get_output_files(history: dict) -> list:
|
|||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
for node_id, node_output in history["outputs"].items():
|
for node_id, node_output in history["outputs"].items():
|
||||||
# Handle image outputs
|
# Handle image outputs (note: SaveVideo sometimes puts videos here)
|
||||||
if "images" in node_output:
|
if "images" in node_output:
|
||||||
for img in node_output["images"]:
|
for img in node_output["images"]:
|
||||||
|
filename = img["filename"]
|
||||||
outputs.append({
|
outputs.append({
|
||||||
"type": "image",
|
"type": get_file_type(filename),
|
||||||
"filename": img["filename"],
|
"filename": filename,
|
||||||
"subfolder": img.get("subfolder", ""),
|
"subfolder": img.get("subfolder", ""),
|
||||||
"type_folder": img.get("type", "output")
|
"type_folder": img.get("type", "output")
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -523,33 +523,48 @@
|
|||||||
showStatus(`✅ Video generated successfully in ${finalElapsed}s`, 'success');
|
showStatus(`✅ Video generated successfully in ${finalElapsed}s`, 'success');
|
||||||
|
|
||||||
const outputContainer = document.getElementById('outputContainer');
|
const outputContainer = document.getElementById('outputContainer');
|
||||||
|
const output = result.output;
|
||||||
|
|
||||||
if (result.output.video) {
|
// Handler returns: {status, prompt_id, outputs: [{type, filename, data/path, size}]}
|
||||||
|
if (output.outputs && output.outputs.length > 0) {
|
||||||
|
for (const item of output.outputs) {
|
||||||
|
// Determine type from extension (more reliable than type field)
|
||||||
|
const filename = item.filename || '';
|
||||||
|
const isVideo = /\.(mp4|webm|mov|gif|avi|mkv)$/i.test(filename);
|
||||||
|
|
||||||
|
if (isVideo && item.data) {
|
||||||
// Base64 video
|
// Base64 video
|
||||||
const videoElem = document.createElement('video');
|
const videoElem = document.createElement('video');
|
||||||
videoElem.className = 'output-video';
|
videoElem.className = 'output-video';
|
||||||
videoElem.controls = true;
|
videoElem.controls = true;
|
||||||
videoElem.autoplay = true;
|
videoElem.autoplay = true;
|
||||||
videoElem.loop = true;
|
videoElem.loop = true;
|
||||||
videoElem.src = 'data:video/mp4;base64,' + result.output.video;
|
videoElem.src = 'data:video/mp4;base64,' + item.data;
|
||||||
outputContainer.appendChild(videoElem);
|
outputContainer.appendChild(videoElem);
|
||||||
} else if (result.output.image) {
|
} else if (!isVideo && item.data) {
|
||||||
// Base64 image
|
// Base64 image
|
||||||
const imgElem = document.createElement('img');
|
const imgElem = document.createElement('img');
|
||||||
imgElem.className = 'output-video';
|
imgElem.className = 'output-video';
|
||||||
imgElem.src = 'data:image/png;base64,' + result.output.image;
|
imgElem.src = 'data:image/png;base64,' + item.data;
|
||||||
outputContainer.appendChild(imgElem);
|
outputContainer.appendChild(imgElem);
|
||||||
} else if (result.output.file_path) {
|
} else if (item.path) {
|
||||||
// File path (large output)
|
// File path (large output saved to volume)
|
||||||
const fileInfo = document.createElement('div');
|
const fileInfo = document.createElement('div');
|
||||||
fileInfo.className = 'status info show';
|
fileInfo.className = 'status info show';
|
||||||
fileInfo.innerHTML = `
|
fileInfo.innerHTML = `
|
||||||
<strong>Large output saved to:</strong><br>
|
<strong>Large output saved to:</strong><br>
|
||||||
<code>${result.output.file_path}</code><br><br>
|
<code>${item.path}</code><br>
|
||||||
|
<em>File: ${item.filename} (${(item.size / 1024 / 1024).toFixed(2)} MB)</em><br><br>
|
||||||
<em>File is too large to display (>10MB). Access it on your RunPod volume.</em>
|
<em>File is too large to display (>10MB). Access it on your RunPod volume.</em>
|
||||||
`;
|
`;
|
||||||
outputContainer.appendChild(fileInfo);
|
outputContainer.appendChild(fileInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else if (output.error) {
|
||||||
|
showStatus('❌ Handler error: ' + output.error, 'error');
|
||||||
|
} else {
|
||||||
|
showStatus('⚠️ No outputs in response', 'error');
|
||||||
|
}
|
||||||
} else if (result.status === 'FAILED') {
|
} else if (result.status === 'FAILED') {
|
||||||
showStatus('❌ Generation failed: ' + (result.error || 'Unknown error'), 'error');
|
showStatus('❌ Generation failed: ' + (result.error || 'Unknown error'), 'error');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
},
|
},
|
||||||
"127": {
|
"127": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"backend": "inductor",
|
"backend": "disabled",
|
||||||
"fullgraph": false,
|
"fullgraph": false,
|
||||||
"mode": "default",
|
"mode": "default",
|
||||||
"dynamic": false,
|
"dynamic": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user