Spaces:
Running
Running
Update index.html
Browse files- index.html +65 -84
index.html
CHANGED
|
@@ -2,125 +2,106 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<title>
|
| 6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
|
| 7 |
<style>
|
| 8 |
-
:root { --bg: #
|
| 9 |
-
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text);
|
| 10 |
-
.
|
| 11 |
-
textarea, input { width: 100%; padding: 12px; margin: 10px 0; border-radius:
|
| 12 |
-
button { width: 100%; padding: 15px; background: var(--accent); color: white; border: none; border-radius:
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
.
|
| 16 |
-
.
|
| 17 |
-
.
|
| 18 |
-
.card {
|
| 19 |
-
.card img { width: 100%; border-radius: 8px; border: 1px solid #475569; }
|
| 20 |
</style>
|
| 21 |
</head>
|
| 22 |
<body>
|
| 23 |
|
| 24 |
-
<div class="
|
| 25 |
-
<h2>
|
| 26 |
-
<
|
| 27 |
|
| 28 |
-
<
|
| 29 |
-
|
| 30 |
-
|
| 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="
|
| 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
|
| 45 |
const token = document.getElementById('hfToken').value.trim();
|
| 46 |
-
const script = document.getElementById('
|
| 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
|
| 53 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 70 |
-
// Combine with character descriptions
|
| 71 |
-
let finalPrompt = `Photo, 8k, highly detailed, ${scenePrompt} , ${char1} , ${char2}`;
|
| 72 |
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
try {
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
const url = URL.createObjectURL(blob);
|
| 78 |
|
| 79 |
-
const
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
gallery.appendChild(
|
| 83 |
-
|
| 84 |
} catch (err) {
|
| 85 |
-
|
|
|
|
|
|
|
| 86 |
return;
|
| 87 |
}
|
| 88 |
}
|
| 89 |
-
|
| 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 |
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>AI Storyboard Pro - Auto Fix</title>
|
| 6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
|
| 7 |
<style>
|
| 8 |
+
:root { --bg: #0b0f19; --card: #161e2e; --accent: #8b5cf6; --text: #f3f4f6; }
|
| 9 |
+
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; }
|
| 10 |
+
.wrapper { max-width: 850px; margin: auto; background: var(--card); padding: 30px; border-radius: 12px; border: 1px solid #2d3748; }
|
| 11 |
+
textarea, input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: white; box-sizing: border-box; }
|
| 12 |
+
button { width: 100%; padding: 15px; background: var(--accent); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 16px; font-weight: bold; }
|
| 13 |
+
#status { margin: 15px 0; padding: 12px; border-radius: 6px; display: none; text-align: center; }
|
| 14 |
+
.loading { background: #1e3a8a; border: 1px solid #3b82f6; }
|
| 15 |
+
.error { background: #7f1d1d; border: 1px solid #ef4444; }
|
| 16 |
+
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-top: 25px; }
|
| 17 |
+
.card { background: #111827; padding: 10px; border-radius: 8px; border: 1px solid #374151; text-align: center; }
|
| 18 |
+
.card img { width: 100%; border-radius: 5px; margin-top: 8px; }
|
|
|
|
| 19 |
</style>
|
| 20 |
</head>
|
| 21 |
<body>
|
| 22 |
|
| 23 |
+
<div class="wrapper">
|
| 24 |
+
<h2>🎨 Pro AI Storyboard Engine</h2>
|
| 25 |
+
<input type="password" id="hfToken" placeholder="Paste your Hugging Face Token (hf_...) here">
|
| 26 |
|
| 27 |
+
<div style="display: flex; gap: 10px;">
|
| 28 |
+
<textarea id="char1" placeholder="Char 1 details (e.g. Grandma, red cloth)"></textarea>
|
| 29 |
+
<textarea id="char2" placeholder="Char 2 details (e.g. Young boy, blue shirt)"></textarea>
|
|
|
|
|
|
|
| 30 |
</div>
|
| 31 |
|
| 32 |
+
<textarea id="scriptInput" rows="6" placeholder="Paste Scenes here (Scene 1 / 50 format)"></textarea>
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
<button onclick="runProcess()">Generate Storyboard 🚀</button>
|
| 35 |
<div id="status"></div>
|
| 36 |
<div class="gallery" id="gallery"></div>
|
| 37 |
</div>
|
| 38 |
|
| 39 |
<script>
|
| 40 |
+
async function runProcess() {
|
| 41 |
const token = document.getElementById('hfToken').value.trim();
|
| 42 |
+
const script = document.getElementById('scriptInput').value.trim();
|
| 43 |
const char1 = document.getElementById('char1').value.trim();
|
| 44 |
const char2 = document.getElementById('char2').value.trim();
|
| 45 |
const status = document.getElementById('status');
|
| 46 |
const gallery = document.getElementById('gallery');
|
| 47 |
|
| 48 |
+
if (!token) { alert("Please paste your Token!"); return; }
|
| 49 |
+
|
| 50 |
+
const scenes = script.split(/Scene \d+ \/ \d+/).filter(s => s.trim().length > 10);
|
| 51 |
+
if (scenes.length === 0) { alert("Format not correct! Use 'Scene 1 / 50' format."); return; }
|
| 52 |
|
|
|
|
|
|
|
| 53 |
status.style.display = "block";
|
| 54 |
status.className = "loading";
|
| 55 |
+
gallery.innerHTML = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
for (let i = 0; i < scenes.length; i++) {
|
| 58 |
+
status.innerText = `Generating Scene ${i+1} of ${scenes.length}...`;
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
let scenePrompt = scenes[i].split("SCENE IMAGE PROMPT:")[1] || scenes[i];
|
| 61 |
+
let fullPrompt = `${scenePrompt}, 8k resolution, cinematic lighting, ${char1}, ${char2}`.trim();
|
| 62 |
|
| 63 |
try {
|
| 64 |
+
// ہگنگ فیس کی اس ماڈل URL کو براہ راست کال کریں
|
| 65 |
+
const response = await fetch(
|
| 66 |
+
"https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell",
|
| 67 |
+
{
|
| 68 |
+
method: "POST",
|
| 69 |
+
headers: {
|
| 70 |
+
"Authorization": `Bearer ${token}`,
|
| 71 |
+
"Content-Type": "application/json",
|
| 72 |
+
"x-use-cache": "false" // تاکہ نیا امیج بنے
|
| 73 |
+
},
|
| 74 |
+
body: JSON.stringify({ inputs: fullPrompt })
|
| 75 |
+
}
|
| 76 |
+
);
|
| 77 |
+
|
| 78 |
+
if (response.status === 503) {
|
| 79 |
+
status.innerText = "AI Model is starting up... Waiting 10 seconds.";
|
| 80 |
+
await new Promise(r => setTimeout(r, 10000));
|
| 81 |
+
i--; // اس سین کو دوبارہ ٹرائی کریں
|
| 82 |
+
continue;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
if (!response.ok) {
|
| 86 |
+
throw new Error(`API Error: ${response.status}`);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
const blob = await response.blob();
|
| 90 |
const url = URL.createObjectURL(blob);
|
| 91 |
|
| 92 |
+
const card = document.createElement('div');
|
| 93 |
+
card.className = "card";
|
| 94 |
+
card.innerHTML = `<strong>Scene ${i+1}</strong><br><img src="${url}">`;
|
| 95 |
+
gallery.appendChild(card);
|
| 96 |
+
|
| 97 |
} catch (err) {
|
| 98 |
+
status.className = "error";
|
| 99 |
+
status.innerText = "Failed to Fetch! Try a 'Write' Token instead of 'Read'.";
|
| 100 |
+
console.error(err);
|
| 101 |
return;
|
| 102 |
}
|
| 103 |
}
|
| 104 |
+
status.innerText = "✅ Storyboard Completed!";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
</script>
|
| 107 |
|