Spaces:
Running
Running
Update index.html
Browse files- index.html +129 -77
index.html
CHANGED
|
@@ -1,77 +1,129 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<title>
|
| 6 |
-
<
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
<
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
<
|
| 25 |
-
|
| 26 |
-
<
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Ultimate Storyboard Engine - Fixed Fetch</title>
|
| 6 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
|
| 7 |
+
<style>
|
| 8 |
+
:root { --bg: #0f172a; --panel: #1e293b; --accent: #7c3aed; --text: #f8fafc; }
|
| 9 |
+
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); margin: 0; padding: 20px; }
|
| 10 |
+
.container { max-width: 900px; margin: auto; background: var(--panel); padding: 30px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
|
| 11 |
+
textarea, input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 8px; border: 1px solid #475569; background: #0f172a; color: white; box-sizing: border-box; }
|
| 12 |
+
button { width: 100%; padding: 15px; background: var(--accent); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 16px; transition: 0.3s; }
|
| 13 |
+
button:hover { background: #6d28d9; }
|
| 14 |
+
#status { margin: 20px 0; padding: 15px; border-radius: 8px; display: none; font-size: 14px; line-height: 1.5; }
|
| 15 |
+
.loading { background: #1e3a8a; color: #bfdbfe; border: 1px solid #3b82f6; }
|
| 16 |
+
.error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
|
| 17 |
+
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-top: 30px; }
|
| 18 |
+
.card { background: #0f172a; padding: 10px; border-radius: 10px; border: 1px solid #334155; }
|
| 19 |
+
.card img { width: 100%; border-radius: 8px; border: 1px solid #475569; }
|
| 20 |
+
</style>
|
| 21 |
+
</head>
|
| 22 |
+
<body>
|
| 23 |
+
|
| 24 |
+
<div class="container">
|
| 25 |
+
<h2>🚀 AI Storyboard Engine (FLUX Fixed)</h2>
|
| 26 |
+
<p style="font-size: 13px; color: #94a3b8;">Paste your Hugging Face Token and Script below.</p>
|
| 27 |
+
|
| 28 |
+
<input type="password" id="hfToken" placeholder="Enter Hugging Face Token (hf_...)">
|
| 29 |
+
|
| 30 |
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
|
| 31 |
+
<textarea id="char1" placeholder="Character 1 Description (e.g. 60yo woman in red dress)"></textarea>
|
| 32 |
+
<textarea id="char2" placeholder="Character 2 Description (e.g. 10yo boy in blue shirt)"></textarea>
|
| 33 |
+
</div>
|
| 34 |
+
|
| 35 |
+
<textarea id="promptInput" rows="8" placeholder="Paste your script here... (Scene 1 / 50 etc.)"></textarea>
|
| 36 |
+
|
| 37 |
+
<button onclick="startGeneration()">Generate My Storyboard</button>
|
| 38 |
+
|
| 39 |
+
<div id="status"></div>
|
| 40 |
+
<div class="gallery" id="gallery"></div>
|
| 41 |
+
</div>
|
| 42 |
+
|
| 43 |
+
<script>
|
| 44 |
+
async function startGeneration() {
|
| 45 |
+
const token = document.getElementById('hfToken').value.trim();
|
| 46 |
+
const script = document.getElementById('promptInput').value.trim();
|
| 47 |
+
const char1 = document.getElementById('char1').value.trim();
|
| 48 |
+
const char2 = document.getElementById('char2').value.trim();
|
| 49 |
+
const status = document.getElementById('status');
|
| 50 |
+
const gallery = document.getElementById('gallery');
|
| 51 |
+
|
| 52 |
+
if (!token) { alert("Please enter your Token!"); return; }
|
| 53 |
+
if (!script) { alert("Please paste your script!"); return; }
|
| 54 |
+
|
| 55 |
+
// Clear previous
|
| 56 |
+
gallery.innerHTML = "";
|
| 57 |
+
status.style.display = "block";
|
| 58 |
+
status.className = "loading";
|
| 59 |
+
|
| 60 |
+
// Parsing Scenes
|
| 61 |
+
const scenes = script.split(/Scene \d+ \/ \d+/).filter(s => s.trim().length > 10);
|
| 62 |
+
|
| 63 |
+
if (scenes.length === 0) {
|
| 64 |
+
updateStatus("Error: No scenes found. Please check your script format.", "error");
|
| 65 |
+
return;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
for (let i = 0; i < scenes.length; i++) {
|
| 69 |
+
let scenePrompt = scenes[i].split("SCENE IMAGE PROMPT:")[1] || scenes[i];
|
| 70 |
+
// Combine with character descriptions
|
| 71 |
+
let finalPrompt = `Photo, 8k, highly detailed, ${scenePrompt} , ${char1} , ${char2}`;
|
| 72 |
+
|
| 73 |
+
updateStatus(`Generating Scene ${i+1} of ${scenes.length}...`, "loading");
|
| 74 |
+
|
| 75 |
+
try {
|
| 76 |
+
const blob = await callAI(finalPrompt, token);
|
| 77 |
+
const url = URL.createObjectURL(blob);
|
| 78 |
+
|
| 79 |
+
const div = document.createElement('div');
|
| 80 |
+
div.className = "card";
|
| 81 |
+
div.innerHTML = `<strong>Scene ${i+1}</strong><br><img src="${url}">`;
|
| 82 |
+
gallery.appendChild(div);
|
| 83 |
+
|
| 84 |
+
} catch (err) {
|
| 85 |
+
updateStatus(`Error at Scene ${i+1}: ${err.message}. Make sure your token has 'Inference' permissions.`, "error");
|
| 86 |
+
return;
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
updateStatus("🎉 All scenes generated successfully!", "loading");
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
async function callAI(prompt, token) {
|
| 93 |
+
// We use a slightly different fetch method to avoid CORS
|
| 94 |
+
const response = await fetch(
|
| 95 |
+
"https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell",
|
| 96 |
+
{
|
| 97 |
+
headers: {
|
| 98 |
+
"Authorization": `Bearer ${token}`,
|
| 99 |
+
"Content-Type": "application/json"
|
| 100 |
+
},
|
| 101 |
+
method: "POST",
|
| 102 |
+
body: JSON.stringify({ inputs: prompt }),
|
| 103 |
+
}
|
| 104 |
+
);
|
| 105 |
+
|
| 106 |
+
if (response.status === 503) {
|
| 107 |
+
// Model is loading, wait 5 seconds and retry
|
| 108 |
+
await new Promise(r => setTimeout(r, 5000));
|
| 109 |
+
return callAI(prompt, token);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if (!response.ok) {
|
| 113 |
+
const errorText = await response.text();
|
| 114 |
+
throw new Error(`API returned ${response.status}: ${errorText}`);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
return await response.blob();
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function updateStatus(msg, type) {
|
| 121 |
+
const status = document.getElementById('status');
|
| 122 |
+
status.innerText = msg;
|
| 123 |
+
status.className = type;
|
| 124 |
+
}
|
| 125 |
+
</script>
|
| 126 |
+
|
| 127 |
+
</body>
|
| 128 |
+
</html>
|
| 129 |
+
|