Update app_enhanced.py
Browse files- app_enhanced.py +24 -44
app_enhanced.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import spaces # <--- CRITICAL: MUST BE THE FIRST IMPORT
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
import threading
|
|
@@ -14,15 +13,6 @@ import numpy as np
|
|
| 14 |
import srt
|
| 15 |
from flask import Flask, jsonify, request, send_from_directory, send_file
|
| 16 |
|
| 17 |
-
# ======================================================
|
| 18 |
-
# π ZEROGPU CONFIGURATION
|
| 19 |
-
# ======================================================
|
| 20 |
-
@spaces.GPU
|
| 21 |
-
def gpu_warmup():
|
| 22 |
-
import torch
|
| 23 |
-
print(f"β
ZeroGPU Warmup: CUDA Available: {torch.cuda.is_available()}")
|
| 24 |
-
return True
|
| 25 |
-
|
| 26 |
# ======================================================
|
| 27 |
# πΎ STORAGE SETUP
|
| 28 |
# ======================================================
|
|
@@ -81,15 +71,19 @@ class Page:
|
|
| 81 |
self.bubbles = bubbles
|
| 82 |
|
| 83 |
# ======================================================
|
| 84 |
-
# π§
|
| 85 |
# ======================================================
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
print(f"π Generating 864x1080 Comic: {video_path}")
|
| 89 |
import cv2
|
| 90 |
import srt
|
| 91 |
import numpy as np
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
cap = cv2.VideoCapture(video_path)
|
| 95 |
if not cap.isOpened(): raise Exception("Cannot open video")
|
|
@@ -101,11 +95,14 @@ def generate_comic_gpu(video_path, user_dir, frames_dir, metadata_path, target_p
|
|
| 101 |
# Subtitles
|
| 102 |
user_srt = os.path.join(user_dir, 'subs.srt')
|
| 103 |
try:
|
| 104 |
-
get_real_subtitles
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
| 109 |
except:
|
| 110 |
with open(user_srt, 'w') as f: f.write("1\n00:00:01,000 --> 00:00:04,000\n...\n")
|
| 111 |
|
|
@@ -205,8 +202,7 @@ def generate_comic_gpu(video_path, user_dir, frames_dir, metadata_path, target_p
|
|
| 205 |
|
| 206 |
return result
|
| 207 |
|
| 208 |
-
|
| 209 |
-
def regen_frame_gpu(video_path, frames_dir, metadata_path, fname, direction):
|
| 210 |
import cv2
|
| 211 |
import json
|
| 212 |
if not os.path.exists(metadata_path): return {"success": False, "message": "No metadata"}
|
|
@@ -231,8 +227,7 @@ def regen_frame_gpu(video_path, frames_dir, metadata_path, fname, direction):
|
|
| 231 |
return {"success": True, "message": f"Time: {new_t:.2f}s", "new_time": new_t}
|
| 232 |
return {"success": False}
|
| 233 |
|
| 234 |
-
|
| 235 |
-
def get_frame_at_ts_gpu(video_path, frames_dir, metadata_path, fname, ts):
|
| 236 |
import cv2
|
| 237 |
import json
|
| 238 |
cap = cv2.VideoCapture(video_path)
|
|
@@ -272,7 +267,8 @@ class EnhancedComicGenerator:
|
|
| 272 |
def run(self, target_pages):
|
| 273 |
try:
|
| 274 |
self.write_status("Generating...", 5)
|
| 275 |
-
|
|
|
|
| 276 |
with open(os.path.join(self.output_dir, 'pages.json'), 'w') as f:
|
| 277 |
json.dump(data, f, indent=2)
|
| 278 |
self.write_status("Complete!", 100)
|
|
@@ -334,7 +330,6 @@ INDEX_HTML = '''
|
|
| 334 |
--y: 50%; --t1: 100%; --t2: 100%; --b1: 100%; --b2: 100%;
|
| 335 |
--gap: 5px; /* Size of White Gap */
|
| 336 |
}
|
| 337 |
-
|
| 338 |
/* π― BLACK BORDER INSIDE THE PANEL */
|
| 339 |
.panel {
|
| 340 |
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
|
@@ -352,13 +347,11 @@ INDEX_HTML = '''
|
|
| 352 |
}
|
| 353 |
.panel img.panning { cursor: grabbing; transition: none; }
|
| 354 |
.panel.selected { border: 4px solid #3498db; z-index: 5; }
|
| 355 |
-
|
| 356 |
/* Clip Paths */
|
| 357 |
.panel:nth-child(1) { clip-path: polygon(0 0, calc(var(--t1) - var(--gap)) 0, calc(var(--t2) - var(--gap)) calc(var(--y) - var(--gap)), 0 calc(var(--y) - var(--gap))); z-index: 1; }
|
| 358 |
.panel:nth-child(2) { clip-path: polygon(calc(var(--t1) + var(--gap)) 0, 100% 0, 100% calc(var(--y) - var(--gap)), calc(var(--t2) + var(--gap)) calc(var(--y) - var(--gap))); z-index: 1; }
|
| 359 |
.panel:nth-child(3) { clip-path: polygon(0 calc(var(--y) + var(--gap)), calc(var(--b1) - var(--gap)) calc(var(--y) + var(--gap)), calc(var(--b2) - var(--gap)) 100%, 0 100%); z-index: 1; }
|
| 360 |
.panel:nth-child(4) { clip-path: polygon(calc(var(--b1) + var(--gap)) calc(var(--y) + var(--gap)), 100% calc(var(--y) + var(--gap)), 100% 100%, calc(var(--b2) + var(--gap)) 100%); z-index: 1; }
|
| 361 |
-
|
| 362 |
.handle { position: absolute; width: 26px; height: 26px; border: 3px solid white; border-radius: 50%; transform: translate(-50%, -50%); z-index: 101; cursor: ew-resize; box-shadow: 0 2px 5px rgba(0,0,0,0.8); }
|
| 363 |
.h-t1 { background: #3498db; left: var(--t1); top: 0%; margin-top: 15px; }
|
| 364 |
.h-t2 { background: #3498db; left: var(--t2); top: 50%; margin-top: -15px; }
|
|
@@ -385,7 +378,6 @@ INDEX_HTML = '''
|
|
| 385 |
.speech-bubble.speech.tail-top:before { bottom: 100%; left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: scaleY(-1); }
|
| 386 |
.speech-bubble.speech.tail-left:before { right: 100%; top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: rotate(90deg); transform-origin: top right; }
|
| 387 |
.speech-bubble.speech.tail-right:before { left: 100%; top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: rotate(-90deg); transform-origin: top left; }
|
| 388 |
-
|
| 389 |
.speech-bubble.thought { background: var(--bubble-fill, #fff); color: var(--bubble-text, #000); border: 2px dashed #555; border-radius: 50%; }
|
| 390 |
.speech-bubble.thought::before { display:none; }
|
| 391 |
.thought-dot { position: absolute; background-color: var(--bubble-fill, #fff); border: 2px solid #555; border-radius: 50%; z-index: -1; }
|
|
@@ -397,7 +389,6 @@ INDEX_HTML = '''
|
|
| 397 |
|
| 398 |
.resize-handle { position: absolute; bottom:-5px; right:-5px; width:15px; height:15px; background:#3498db; border:1px solid white; cursor:se-resize; display:none; }
|
| 399 |
.speech-bubble.selected .resize-handle { display:block; }
|
| 400 |
-
|
| 401 |
/* CONTROLS */
|
| 402 |
.edit-controls { position: fixed; bottom: 20px; right: 20px; width: 280px; background: rgba(44, 62, 80, 0.95); color: white; padding: 15px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 900; font-size: 13px; max-height: 90vh; overflow-y: auto; }
|
| 403 |
.edit-controls h4 { margin: 0 0 10px 0; color: #4ECDC4; text-align: center; }
|
|
@@ -420,10 +411,9 @@ INDEX_HTML = '''
|
|
| 420 |
.code { font-size: 24px; font-weight: bold; letter-spacing: 3px; background: #eee; padding: 10px; margin: 15px 0; display: inline-block; font-family: monospace; }
|
| 421 |
</style>
|
| 422 |
</head> <body>
|
| 423 |
-
|
| 424 |
<div id="upload-container">
|
| 425 |
<div class="upload-box">
|
| 426 |
-
<h1>β‘ 864x1080 Robust Comic</h1>
|
| 427 |
<input type="file" id="file-upload" class="file-input" onchange="document.getElementById('fn').innerText=this.files[0].name">
|
| 428 |
<label for="file-upload" class="file-label">π Choose Video</label>
|
| 429 |
<span id="fn" style="margin-bottom:10px; display:block; color:#aaa;">No file selected</span>
|
|
@@ -446,7 +436,6 @@ INDEX_HTML = '''
|
|
| 446 |
</div>
|
| 447 |
</div>
|
| 448 |
</div>
|
| 449 |
-
|
| 450 |
<div id="editor-container">
|
| 451 |
<div class="tip">π Drag Right-Side Dots to reveal 4 panels! | π Scroll to Zoom/Pan</div>
|
| 452 |
<div class="comic-wrapper" id="comic-container"></div>
|
|
@@ -459,7 +448,6 @@ INDEX_HTML = '''
|
|
| 459 |
<button onclick="undo()" style="background:#7f8c8d; color:white;">β©οΈ Undo</button>
|
| 460 |
<button onclick="saveComic()" class="save-btn">πΎ Save Comic</button>
|
| 461 |
</div>
|
| 462 |
-
|
| 463 |
<div class="control-group">
|
| 464 |
<label>π¬ Bubble Styling:</label>
|
| 465 |
<select id="bubble-type" onchange="updateBubbleType()">
|
|
@@ -487,7 +475,6 @@ INDEX_HTML = '''
|
|
| 487 |
<input type="range" min="10" max="90" value="50" oninput="slideTail(this.value)" title="Tail Pos">
|
| 488 |
</div>
|
| 489 |
</div>
|
| 490 |
-
|
| 491 |
<div class="control-group">
|
| 492 |
<label>πΌοΈ Time Frame (MM:SS):</label>
|
| 493 |
<div class="timestamp-controls">
|
|
@@ -514,7 +501,6 @@ INDEX_HTML = '''
|
|
| 514 |
</div>
|
| 515 |
</div>
|
| 516 |
</div>
|
| 517 |
-
|
| 518 |
<div class="modal-overlay" id="save-modal">
|
| 519 |
<div class="modal-content">
|
| 520 |
<h2>β
Comic Saved!</h2>
|
|
@@ -522,7 +508,6 @@ INDEX_HTML = '''
|
|
| 522 |
<button onclick="closeModal()">Close</button>
|
| 523 |
</div>
|
| 524 |
</div>
|
| 525 |
-
|
| 526 |
<script>
|
| 527 |
function genUUID(){ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,c=>{var r=Math.random()*16|0,v=c=='x'?r:(r&0x3|0x8);return v.toString(16);}); }
|
| 528 |
let sid = localStorage.getItem('comic_sid') || genUUID();
|
|
@@ -619,7 +604,6 @@ INDEX_HTML = '''
|
|
| 619 |
setTimeout(() => restoreFromState(JSON.parse(localStorage.getItem('comic_draft_'+sid))), 500);
|
| 620 |
});
|
| 621 |
}
|
| 622 |
-
|
| 623 |
async function upload() {
|
| 624 |
const f = document.getElementById('file-upload').files[0];
|
| 625 |
const pCount = document.getElementById('page-count').value;
|
|
@@ -654,7 +638,6 @@ INDEX_HTML = '''
|
|
| 654 |
renderFromState(cleanData);
|
| 655 |
saveState();
|
| 656 |
}
|
| 657 |
-
|
| 658 |
function renderFromState(pagesData) {
|
| 659 |
const con = document.getElementById('comic-container'); con.innerHTML = '';
|
| 660 |
pagesData.forEach((page, pageIdx) => {
|
|
@@ -820,7 +803,6 @@ INDEX_HTML = '''
|
|
| 820 |
}
|
| 821 |
saveState();
|
| 822 |
}
|
| 823 |
-
|
| 824 |
function handleZoom(val) { if(selectedPanel) { const img = selectedPanel.querySelector('img'); img.dataset.zoom = val; updateImageTransform(img); saveState(); } }
|
| 825 |
function updateImageTransform(img) { const z = (img.dataset.zoom||100)/100, x = img.dataset.translateX||0, y = img.dataset.translateY||0; img.style.transform = `translateX(${x}px) translateY(${y}px) scale(${z})`; }
|
| 826 |
function resetPanelTransform() { if(selectedPanel) { const img = selectedPanel.querySelector('img'); img.dataset.zoom=100; img.dataset.translateX=0; img.dataset.translateY=0; updateImageTransform(img); document.getElementById('zoom-slider').value=100; saveState(); } }
|
|
@@ -942,14 +924,14 @@ def regen():
|
|
| 942 |
sid = request.args.get('sid')
|
| 943 |
d = request.get_json()
|
| 944 |
gen = EnhancedComicGenerator(sid)
|
| 945 |
-
return jsonify(
|
| 946 |
|
| 947 |
@app.route('/goto_timestamp', methods=['POST'])
|
| 948 |
def go_time():
|
| 949 |
sid = request.args.get('sid')
|
| 950 |
d = request.get_json()
|
| 951 |
gen = EnhancedComicGenerator(sid)
|
| 952 |
-
return jsonify(
|
| 953 |
|
| 954 |
@app.route('/replace_panel', methods=['POST'])
|
| 955 |
def rep_panel():
|
|
@@ -996,6 +978,4 @@ def load_comic(code):
|
|
| 996 |
except Exception as e: return jsonify({'success': False, 'message': str(e)})
|
| 997 |
|
| 998 |
if __name__ == '__main__':
|
| 999 |
-
try: gpu_warmup()
|
| 1000 |
-
except: pass
|
| 1001 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import time
|
| 3 |
import threading
|
|
|
|
| 13 |
import srt
|
| 14 |
from flask import Flask, jsonify, request, send_from_directory, send_file
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# ======================================================
|
| 17 |
# πΎ STORAGE SETUP
|
| 18 |
# ======================================================
|
|
|
|
| 71 |
self.bubbles = bubbles
|
| 72 |
|
| 73 |
# ======================================================
|
| 74 |
+
# π§ CPU GENERATION (Formerly GPU)
|
| 75 |
# ======================================================
|
| 76 |
+
def generate_comic_cpu(video_path, user_dir, frames_dir, metadata_path, target_pages):
|
| 77 |
+
print(f"π Generating 864x1080 Comic (CPU Mode): {video_path}")
|
|
|
|
| 78 |
import cv2
|
| 79 |
import srt
|
| 80 |
import numpy as np
|
| 81 |
+
# Assuming backend.subtitles.subs_real exists in your file structure.
|
| 82 |
+
# If not, the try/except block below handles the fallback.
|
| 83 |
+
try:
|
| 84 |
+
from backend.subtitles.subs_real import get_real_subtitles
|
| 85 |
+
except ImportError:
|
| 86 |
+
get_real_subtitles = None
|
| 87 |
|
| 88 |
cap = cv2.VideoCapture(video_path)
|
| 89 |
if not cap.isOpened(): raise Exception("Cannot open video")
|
|
|
|
| 95 |
# Subtitles
|
| 96 |
user_srt = os.path.join(user_dir, 'subs.srt')
|
| 97 |
try:
|
| 98 |
+
if get_real_subtitles:
|
| 99 |
+
get_real_subtitles(video_path)
|
| 100 |
+
if os.path.exists('test1.srt'):
|
| 101 |
+
shutil.move('test1.srt', user_srt)
|
| 102 |
+
elif not os.path.exists(user_srt):
|
| 103 |
+
with open(user_srt, 'w') as f: f.write("1\n00:00:01,000 --> 00:00:04,000\n...\n")
|
| 104 |
+
else:
|
| 105 |
+
raise Exception("Subtitles module missing")
|
| 106 |
except:
|
| 107 |
with open(user_srt, 'w') as f: f.write("1\n00:00:01,000 --> 00:00:04,000\n...\n")
|
| 108 |
|
|
|
|
| 202 |
|
| 203 |
return result
|
| 204 |
|
| 205 |
+
def regen_frame_cpu(video_path, frames_dir, metadata_path, fname, direction):
|
|
|
|
| 206 |
import cv2
|
| 207 |
import json
|
| 208 |
if not os.path.exists(metadata_path): return {"success": False, "message": "No metadata"}
|
|
|
|
| 227 |
return {"success": True, "message": f"Time: {new_t:.2f}s", "new_time": new_t}
|
| 228 |
return {"success": False}
|
| 229 |
|
| 230 |
+
def get_frame_at_ts_cpu(video_path, frames_dir, metadata_path, fname, ts):
|
|
|
|
| 231 |
import cv2
|
| 232 |
import json
|
| 233 |
cap = cv2.VideoCapture(video_path)
|
|
|
|
| 267 |
def run(self, target_pages):
|
| 268 |
try:
|
| 269 |
self.write_status("Generating...", 5)
|
| 270 |
+
# Call CPU function instead of GPU
|
| 271 |
+
data = generate_comic_cpu(self.video_path, self.user_dir, self.frames_dir, self.metadata_path, int(target_pages))
|
| 272 |
with open(os.path.join(self.output_dir, 'pages.json'), 'w') as f:
|
| 273 |
json.dump(data, f, indent=2)
|
| 274 |
self.write_status("Complete!", 100)
|
|
|
|
| 330 |
--y: 50%; --t1: 100%; --t2: 100%; --b1: 100%; --b2: 100%;
|
| 331 |
--gap: 5px; /* Size of White Gap */
|
| 332 |
}
|
|
|
|
| 333 |
/* π― BLACK BORDER INSIDE THE PANEL */
|
| 334 |
.panel {
|
| 335 |
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
|
|
|
| 347 |
}
|
| 348 |
.panel img.panning { cursor: grabbing; transition: none; }
|
| 349 |
.panel.selected { border: 4px solid #3498db; z-index: 5; }
|
|
|
|
| 350 |
/* Clip Paths */
|
| 351 |
.panel:nth-child(1) { clip-path: polygon(0 0, calc(var(--t1) - var(--gap)) 0, calc(var(--t2) - var(--gap)) calc(var(--y) - var(--gap)), 0 calc(var(--y) - var(--gap))); z-index: 1; }
|
| 352 |
.panel:nth-child(2) { clip-path: polygon(calc(var(--t1) + var(--gap)) 0, 100% 0, 100% calc(var(--y) - var(--gap)), calc(var(--t2) + var(--gap)) calc(var(--y) - var(--gap))); z-index: 1; }
|
| 353 |
.panel:nth-child(3) { clip-path: polygon(0 calc(var(--y) + var(--gap)), calc(var(--b1) - var(--gap)) calc(var(--y) + var(--gap)), calc(var(--b2) - var(--gap)) 100%, 0 100%); z-index: 1; }
|
| 354 |
.panel:nth-child(4) { clip-path: polygon(calc(var(--b1) + var(--gap)) calc(var(--y) + var(--gap)), 100% calc(var(--y) + var(--gap)), 100% 100%, calc(var(--b2) + var(--gap)) 100%); z-index: 1; }
|
|
|
|
| 355 |
.handle { position: absolute; width: 26px; height: 26px; border: 3px solid white; border-radius: 50%; transform: translate(-50%, -50%); z-index: 101; cursor: ew-resize; box-shadow: 0 2px 5px rgba(0,0,0,0.8); }
|
| 356 |
.h-t1 { background: #3498db; left: var(--t1); top: 0%; margin-top: 15px; }
|
| 357 |
.h-t2 { background: #3498db; left: var(--t2); top: 50%; margin-top: -15px; }
|
|
|
|
| 378 |
.speech-bubble.speech.tail-top:before { bottom: 100%; left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: scaleY(-1); }
|
| 379 |
.speech-bubble.speech.tail-left:before { right: 100%; top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: rotate(90deg); transform-origin: top right; }
|
| 380 |
.speech-bubble.speech.tail-right:before { left: 100%; top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b))); transform: rotate(-90deg); transform-origin: top left; }
|
|
|
|
| 381 |
.speech-bubble.thought { background: var(--bubble-fill, #fff); color: var(--bubble-text, #000); border: 2px dashed #555; border-radius: 50%; }
|
| 382 |
.speech-bubble.thought::before { display:none; }
|
| 383 |
.thought-dot { position: absolute; background-color: var(--bubble-fill, #fff); border: 2px solid #555; border-radius: 50%; z-index: -1; }
|
|
|
|
| 389 |
|
| 390 |
.resize-handle { position: absolute; bottom:-5px; right:-5px; width:15px; height:15px; background:#3498db; border:1px solid white; cursor:se-resize; display:none; }
|
| 391 |
.speech-bubble.selected .resize-handle { display:block; }
|
|
|
|
| 392 |
/* CONTROLS */
|
| 393 |
.edit-controls { position: fixed; bottom: 20px; right: 20px; width: 280px; background: rgba(44, 62, 80, 0.95); color: white; padding: 15px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 900; font-size: 13px; max-height: 90vh; overflow-y: auto; }
|
| 394 |
.edit-controls h4 { margin: 0 0 10px 0; color: #4ECDC4; text-align: center; }
|
|
|
|
| 411 |
.code { font-size: 24px; font-weight: bold; letter-spacing: 3px; background: #eee; padding: 10px; margin: 15px 0; display: inline-block; font-family: monospace; }
|
| 412 |
</style>
|
| 413 |
</head> <body>
|
|
|
|
| 414 |
<div id="upload-container">
|
| 415 |
<div class="upload-box">
|
| 416 |
+
<h1>β‘ 864x1080 Robust Comic (CPU)</h1>
|
| 417 |
<input type="file" id="file-upload" class="file-input" onchange="document.getElementById('fn').innerText=this.files[0].name">
|
| 418 |
<label for="file-upload" class="file-label">π Choose Video</label>
|
| 419 |
<span id="fn" style="margin-bottom:10px; display:block; color:#aaa;">No file selected</span>
|
|
|
|
| 436 |
</div>
|
| 437 |
</div>
|
| 438 |
</div>
|
|
|
|
| 439 |
<div id="editor-container">
|
| 440 |
<div class="tip">π Drag Right-Side Dots to reveal 4 panels! | π Scroll to Zoom/Pan</div>
|
| 441 |
<div class="comic-wrapper" id="comic-container"></div>
|
|
|
|
| 448 |
<button onclick="undo()" style="background:#7f8c8d; color:white;">β©οΈ Undo</button>
|
| 449 |
<button onclick="saveComic()" class="save-btn">πΎ Save Comic</button>
|
| 450 |
</div>
|
|
|
|
| 451 |
<div class="control-group">
|
| 452 |
<label>π¬ Bubble Styling:</label>
|
| 453 |
<select id="bubble-type" onchange="updateBubbleType()">
|
|
|
|
| 475 |
<input type="range" min="10" max="90" value="50" oninput="slideTail(this.value)" title="Tail Pos">
|
| 476 |
</div>
|
| 477 |
</div>
|
|
|
|
| 478 |
<div class="control-group">
|
| 479 |
<label>πΌοΈ Time Frame (MM:SS):</label>
|
| 480 |
<div class="timestamp-controls">
|
|
|
|
| 501 |
</div>
|
| 502 |
</div>
|
| 503 |
</div>
|
|
|
|
| 504 |
<div class="modal-overlay" id="save-modal">
|
| 505 |
<div class="modal-content">
|
| 506 |
<h2>β
Comic Saved!</h2>
|
|
|
|
| 508 |
<button onclick="closeModal()">Close</button>
|
| 509 |
</div>
|
| 510 |
</div>
|
|
|
|
| 511 |
<script>
|
| 512 |
function genUUID(){ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,c=>{var r=Math.random()*16|0,v=c=='x'?r:(r&0x3|0x8);return v.toString(16);}); }
|
| 513 |
let sid = localStorage.getItem('comic_sid') || genUUID();
|
|
|
|
| 604 |
setTimeout(() => restoreFromState(JSON.parse(localStorage.getItem('comic_draft_'+sid))), 500);
|
| 605 |
});
|
| 606 |
}
|
|
|
|
| 607 |
async function upload() {
|
| 608 |
const f = document.getElementById('file-upload').files[0];
|
| 609 |
const pCount = document.getElementById('page-count').value;
|
|
|
|
| 638 |
renderFromState(cleanData);
|
| 639 |
saveState();
|
| 640 |
}
|
|
|
|
| 641 |
function renderFromState(pagesData) {
|
| 642 |
const con = document.getElementById('comic-container'); con.innerHTML = '';
|
| 643 |
pagesData.forEach((page, pageIdx) => {
|
|
|
|
| 803 |
}
|
| 804 |
saveState();
|
| 805 |
}
|
|
|
|
| 806 |
function handleZoom(val) { if(selectedPanel) { const img = selectedPanel.querySelector('img'); img.dataset.zoom = val; updateImageTransform(img); saveState(); } }
|
| 807 |
function updateImageTransform(img) { const z = (img.dataset.zoom||100)/100, x = img.dataset.translateX||0, y = img.dataset.translateY||0; img.style.transform = `translateX(${x}px) translateY(${y}px) scale(${z})`; }
|
| 808 |
function resetPanelTransform() { if(selectedPanel) { const img = selectedPanel.querySelector('img'); img.dataset.zoom=100; img.dataset.translateX=0; img.dataset.translateY=0; updateImageTransform(img); document.getElementById('zoom-slider').value=100; saveState(); } }
|
|
|
|
| 924 |
sid = request.args.get('sid')
|
| 925 |
d = request.get_json()
|
| 926 |
gen = EnhancedComicGenerator(sid)
|
| 927 |
+
return jsonify(regen_frame_cpu(gen.video_path, gen.frames_dir, gen.metadata_path, d['filename'], d['direction']))
|
| 928 |
|
| 929 |
@app.route('/goto_timestamp', methods=['POST'])
|
| 930 |
def go_time():
|
| 931 |
sid = request.args.get('sid')
|
| 932 |
d = request.get_json()
|
| 933 |
gen = EnhancedComicGenerator(sid)
|
| 934 |
+
return jsonify(get_frame_at_ts_cpu(gen.video_path, gen.frames_dir, gen.metadata_path, d['filename'], float(d['timestamp'])))
|
| 935 |
|
| 936 |
@app.route('/replace_panel', methods=['POST'])
|
| 937 |
def rep_panel():
|
|
|
|
| 978 |
except Exception as e: return jsonify({'success': False, 'message': str(e)})
|
| 979 |
|
| 980 |
if __name__ == '__main__':
|
|
|
|
|
|
|
| 981 |
app.run(host='0.0.0.0', port=7860)
|