wmhealt commited on
Commit
98bcb88
·
verified ·
1 Parent(s): f264a3f

Update index.html

Browse files
Files changed (1) hide show
  1. 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>AI Storyboard - Final Test</title>
6
- <style>
7
- body { font-family: sans-serif; background: #111; color: white; padding: 40px; text-align: center; }
8
- .box { background: #222; padding: 20px; border-radius: 10px; max-width: 600px; margin: auto; }
9
- input, textarea { width: 100%; padding: 10px; margin-top: 10px; border-radius: 5px; border: none; }
10
- button { background: #7c3aed; color: white; padding: 15px 30px; border: none; border-radius: 5px; cursor: pointer; margin-top: 20px; width: 100%; font-weight: bold; }
11
- #output img { width: 100%; margin-top: 20px; border-radius: 10px; border: 2px solid #555; }
12
- #status { margin-top: 15px; color: #fbbf24; }
13
- </style>
14
- </head>
15
- <body>
16
-
17
- <div class="box">
18
- <h2>Storyboard Creator</h2>
19
- <input type="password" id="token" placeholder="Paste your hf_... token here">
20
- <textarea id="prompt" rows="4" placeholder="Describe the scene (e.g. A cat sitting on a throne, pixar style)"></textarea>
21
- <button onclick="generateImage()">Generate Image</button>
22
- <div id="status"></div>
23
- <div id="output"></div>
24
- </div>
25
-
26
- <script>
27
- async function generateImage() {
28
- const token = document.getElementById('token').value.trim();
29
- const prompt = document.getElementById('prompt').value.trim();
30
- const status = document.getElementById('status');
31
- const output = document.getElementById('output');
32
-
33
- if (!token || !prompt) { alert("Please fill both fields!"); return; }
34
-
35
- status.innerText = "Connecting to AI Model... (Please wait 20-30 seconds)";
36
- output.innerHTML = "";
37
-
38
- try {
39
- const response = await fetch(
40
- "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell",
41
- {
42
- headers: {
43
- "Authorization": `Bearer ${token}`,
44
- "Content-Type": "application/json"
45
- },
46
- method: "POST",
47
- body: JSON.stringify({ inputs: prompt }),
48
- }
49
- );
50
-
51
- if (response.status === 503) {
52
- status.innerText = "Model is loading... Retrying in 5 seconds.";
53
- setTimeout(generateImage, 5000);
54
- return;
55
- }
56
-
57
- if (!response.ok) {
58
- const errorData = await response.json();
59
- throw new Error(errorData.error || "API Error");
60
- }
61
-
62
- const blob = await response.blob();
63
- const imgUrl = URL.createObjectURL(blob);
64
- output.innerHTML = `<img src="${imgUrl}">`;
65
- status.innerText = "Image Generated Successfully!";
66
-
67
- } catch (error) {
68
- status.innerText = "Error: " + error.message;
69
- console.error(error);
70
- }
71
- }
72
- </script>
73
-
74
- </body>
75
- </html>
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
+