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")
|
||||
|
||||
|
||||
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:
|
||||
"""Extract output file info from history."""
|
||||
outputs = []
|
||||
@@ -349,12 +357,13 @@ def get_output_files(history: dict) -> list:
|
||||
return outputs
|
||||
|
||||
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:
|
||||
for img in node_output["images"]:
|
||||
filename = img["filename"]
|
||||
outputs.append({
|
||||
"type": "image",
|
||||
"filename": img["filename"],
|
||||
"type": get_file_type(filename),
|
||||
"filename": filename,
|
||||
"subfolder": img.get("subfolder", ""),
|
||||
"type_folder": img.get("type", "output")
|
||||
})
|
||||
|
||||
@@ -523,32 +523,47 @@
|
||||
showStatus(`✅ Video generated successfully in ${finalElapsed}s`, 'success');
|
||||
|
||||
const outputContainer = document.getElementById('outputContainer');
|
||||
const output = result.output;
|
||||
|
||||
if (result.output.video) {
|
||||
// Base64 video
|
||||
const videoElem = document.createElement('video');
|
||||
videoElem.className = 'output-video';
|
||||
videoElem.controls = true;
|
||||
videoElem.autoplay = true;
|
||||
videoElem.loop = true;
|
||||
videoElem.src = 'data:video/mp4;base64,' + result.output.video;
|
||||
outputContainer.appendChild(videoElem);
|
||||
} else if (result.output.image) {
|
||||
// Base64 image
|
||||
const imgElem = document.createElement('img');
|
||||
imgElem.className = 'output-video';
|
||||
imgElem.src = 'data:image/png;base64,' + result.output.image;
|
||||
outputContainer.appendChild(imgElem);
|
||||
} else if (result.output.file_path) {
|
||||
// File path (large output)
|
||||
const fileInfo = document.createElement('div');
|
||||
fileInfo.className = 'status info show';
|
||||
fileInfo.innerHTML = `
|
||||
<strong>Large output saved to:</strong><br>
|
||||
<code>${result.output.file_path}</code><br><br>
|
||||
<em>File is too large to display (>10MB). Access it on your RunPod volume.</em>
|
||||
`;
|
||||
outputContainer.appendChild(fileInfo);
|
||||
// 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
|
||||
const videoElem = document.createElement('video');
|
||||
videoElem.className = 'output-video';
|
||||
videoElem.controls = true;
|
||||
videoElem.autoplay = true;
|
||||
videoElem.loop = true;
|
||||
videoElem.src = 'data:video/mp4;base64,' + item.data;
|
||||
outputContainer.appendChild(videoElem);
|
||||
} else if (!isVideo && item.data) {
|
||||
// Base64 image
|
||||
const imgElem = document.createElement('img');
|
||||
imgElem.className = 'output-video';
|
||||
imgElem.src = 'data:image/png;base64,' + item.data;
|
||||
outputContainer.appendChild(imgElem);
|
||||
} else if (item.path) {
|
||||
// File path (large output saved to volume)
|
||||
const fileInfo = document.createElement('div');
|
||||
fileInfo.className = 'status info show';
|
||||
fileInfo.innerHTML = `
|
||||
<strong>Large output saved to:</strong><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>
|
||||
`;
|
||||
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') {
|
||||
showStatus('❌ Generation failed: ' + (result.error || 'Unknown error'), 'error');
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
},
|
||||
"127": {
|
||||
"inputs": {
|
||||
"backend": "inductor",
|
||||
"backend": "disabled",
|
||||
"fullgraph": false,
|
||||
"mode": "default",
|
||||
"dynamic": false,
|
||||
|
||||
Reference in New Issue
Block a user