Spaces:
Running
Running
Update index.html
Browse files- index.html +96 -114
index.html
CHANGED
|
@@ -1,117 +1,99 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
text-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
padding: 10px;
|
| 48 |
-
border: 1px solid #ccc;
|
| 49 |
-
border-radius: 4px;
|
| 50 |
-
min-height: 100px;
|
| 51 |
-
font-family: monospace;
|
| 52 |
-
resize: vertical;
|
| 53 |
-
}
|
| 54 |
-
button {
|
| 55 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 56 |
-
color: white;
|
| 57 |
-
padding: 10px 20px;
|
| 58 |
-
border: none;
|
| 59 |
-
border-radius: 4px;
|
| 60 |
-
cursor: pointer;
|
| 61 |
-
font-size: 1em;
|
| 62 |
-
transition: background 0.3s ease;
|
| 63 |
-
}
|
| 64 |
-
button:hover {
|
| 65 |
-
background: linear-gradient(135deg, #5a6fd0 0%, #673f8a 100%);
|
| 66 |
-
}
|
| 67 |
-
.output-section {
|
| 68 |
-
margin-top: 30px;
|
| 69 |
-
}
|
| 70 |
-
.output-section h2 {
|
| 71 |
-
color: #444;
|
| 72 |
-
border-bottom: 2px solid #eee;
|
| 73 |
-
padding-bottom: 10px;
|
| 74 |
-
margin-bottom: 15px;
|
| 75 |
-
}
|
| 76 |
-
#model-output {
|
| 77 |
-
background-color: #f9f9f9;
|
| 78 |
-
border: 1px solid #eee;
|
| 79 |
-
border-radius: 4px;
|
| 80 |
-
padding: 15px;
|
| 81 |
-
min-height: 150px;
|
| 82 |
-
white-space: pre-wrap;
|
| 83 |
-
word-wrap: break-word;
|
| 84 |
-
font-family: monospace;
|
| 85 |
-
color: #666;
|
| 86 |
-
}
|
| 87 |
-
</style>
|
| 88 |
-
</head>
|
| 89 |
-
<body>
|
| 90 |
-
<div class="container">
|
| 91 |
-
<header>
|
| 92 |
-
<h1>Seedance AI API</h1>
|
| 93 |
-
</header>
|
| 94 |
-
<main>
|
| 95 |
-
<section class="input-section">
|
| 96 |
-
<label for="model-prompt">Model Prompt:</label>
|
| 97 |
-
<textarea id="model-prompt" placeholder="Enter your prompt here..."></textarea>
|
| 98 |
-
<br><br>
|
| 99 |
-
<button onclick="generateOutput()">Generate</button>
|
| 100 |
-
</section>
|
| 101 |
-
<section class="output-section">
|
| 102 |
-
<h2>Model Output:</h2>
|
| 103 |
-
<div id="model-output">[Output will appear here]</div>
|
| 104 |
-
</section>
|
| 105 |
-
</main>
|
| 106 |
</div>
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
-
|
| 115 |
-
</
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Seedance2API - Functional AI</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
body { background-color: #0f172a; color: white; }
|
| 10 |
+
.glass { background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); }
|
| 11 |
+
.loading { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
|
| 12 |
+
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
|
| 13 |
+
</style>
|
| 14 |
+
</head>
|
| 15 |
+
<body class="flex items-center justify-center min-h-screen p-4">
|
| 16 |
+
|
| 17 |
+
<div class="glass max-w-2xl w-full rounded-2xl p-8 shadow-2xl">
|
| 18 |
+
<div class="flex items-center mb-8">
|
| 19 |
+
<div class="bg-indigo-500 p-3 rounded-lg mr-4">
|
| 20 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 21 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
|
| 22 |
+
</svg>
|
| 23 |
+
</div>
|
| 24 |
+
<div>
|
| 25 |
+
<h1 class="text-2xl font-bold tracking-tight">Aligned AI - Seedance2API</h1>
|
| 26 |
+
<p class="text-slate-400 text-sm">Live Model Interface with Aligned's safeguards over the scemantic.</p>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
|
| 30 |
+
<div class="space-y-4">
|
| 31 |
+
<div>
|
| 32 |
+
<label class="block text-sm font-medium text-slate-300 mb-2">Input Prompt</label>
|
| 33 |
+
<textarea id="promptInput" class="w-full bg-slate-800 border border-slate-700 rounded-xl p-4 text-white focus:ring-2 focus:ring-indigo-500 focus:outline-none transition-all" rows="4" placeholder="Describe an image you want to generate..."></textarea>
|
| 34 |
+
</div>
|
| 35 |
+
|
| 36 |
+
<button onclick="generateImage()" id="genBtn" class="w-full bg-indigo-600 hover:bg-indigo-500 text-white font-semibold py-3 px-6 rounded-xl transition-all transform active:scale-95 flex items-center justify-center">
|
| 37 |
+
<span id="btnText">Generate Image</span>
|
| 38 |
+
</button>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<div class="mt-8 pt-8 border-t border-slate-800">
|
| 42 |
+
<h3 class="text-sm font-semibold text-slate-500 uppercase tracking-wider mb-4">Output Preview</h3>
|
| 43 |
+
<div id="outputContainer" class="aspect-video w-full bg-slate-900 rounded-xl border-2 border-dashed border-slate-800 flex items-center justify-center text-slate-600 overflow-hidden">
|
| 44 |
+
<p id="placeholderText">Results will appear here...</p>
|
| 45 |
+
<img id="resultImage" class="hidden w-full h-full object-cover" />
|
| 46 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
</div>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<script>
|
| 51 |
+
// PASTE YOUR HUGGING FACE TOKEN HERE
|
| 52 |
+
const HF_TOKEN = "aligned";
|
| 53 |
+
|
| 54 |
+
async function generateImage() {
|
| 55 |
+
const prompt = document.getElementById('promptInput').value;
|
| 56 |
+
const btn = document.getElementById('genBtn');
|
| 57 |
+
const btnText = document.getElementById('btnText');
|
| 58 |
+
const outputContainer = document.getElementById('outputContainer');
|
| 59 |
+
const placeholder = document.getElementById('placeholderText');
|
| 60 |
+
const resultImg = document.getElementById('resultImage');
|
| 61 |
+
|
| 62 |
+
if (!prompt) return alert("Please enter a prompt!");
|
| 63 |
+
|
| 64 |
+
// UI Loading State
|
| 65 |
+
btn.disabled = true;
|
| 66 |
+
btnText.innerText = "Generating... (may take 20s)";
|
| 67 |
+
outputContainer.classList.add('loading');
|
| 68 |
+
resultImg.classList.add('hidden');
|
| 69 |
+
placeholder.classList.remove('hidden');
|
| 70 |
+
placeholder.innerText = "AI is thinking...";
|
| 71 |
+
|
| 72 |
+
try {
|
| 73 |
+
const response = await fetch(
|
| 74 |
+
"https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5",
|
| 75 |
+
{
|
| 76 |
+
headers: { Authorization: `Bearer ${HF_TOKEN}` },
|
| 77 |
+
method: "POST",
|
| 78 |
+
body: JSON.stringify({ inputs: prompt }),
|
| 79 |
+
}
|
| 80 |
+
);
|
| 81 |
+
|
| 82 |
+
const blob = await response.blob();
|
| 83 |
+
const imageUrl = URL.createObjectURL(blob);
|
| 84 |
+
|
| 85 |
+
resultImg.src = imageUrl;
|
| 86 |
+
resultImg.classList.remove('hidden');
|
| 87 |
+
placeholder.classList.add('hidden');
|
| 88 |
+
} catch (error) {
|
| 89 |
+
console.error(error);
|
| 90 |
+
placeholder.innerText = "Error generating image. Check your token.";
|
| 91 |
+
} finally {
|
| 92 |
+
btn.disabled = false;
|
| 93 |
+
btnText.innerText = "Generate Image";
|
| 94 |
+
outputContainer.classList.remove('loading');
|
| 95 |
}
|
| 96 |
+
}
|
| 97 |
+
</script>
|
| 98 |
+
</body>
|
| 99 |
+
</html>
|