Spaces:
Running
Running
Update index.html
#1
by wmhealt - opened
- index.html +76 -18
index.html
CHANGED
|
@@ -1,19 +1,77 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
|
|
|
|
|
| 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 |
+
|