Spaces:
Running
Running
Update index.html
Browse files- index.html +32 -6
index.html
CHANGED
|
@@ -19,6 +19,8 @@
|
|
| 19 |
.error-block h3 { margin: 0 0 10px 0; color: #dc2626; font-size: 16px; }
|
| 20 |
.error-block .code { background: #1f2937; color: #f9fafb; padding: 10px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 13px; overflow-x: auto; }
|
| 21 |
.info { background: #dbeafe; border: 1px solid #3b82f6; border-radius: 6px; padding: 10px; margin-bottom: 15px; font-size: 14px; }
|
|
|
|
|
|
|
| 22 |
</style>
|
| 23 |
</head>
|
| 24 |
<body>
|
|
@@ -33,11 +35,18 @@
|
|
| 33 |
|
| 34 |
<label for="modelSelect">Модель:</label>
|
| 35 |
<select id="modelSelect">
|
| 36 |
-
<option value="black-forest-labs/FLUX.1-dev">FLUX.1-dev (
|
| 37 |
-
<option value="black-forest-labs/FLUX.
|
| 38 |
-
<option value="
|
|
|
|
|
|
|
| 39 |
</select>
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
<label for="prompt">Промпт:</label>
|
| 42 |
<textarea id="prompt" rows="3" placeholder="A cinematic shot of a cyberpunk city..."></textarea>
|
| 43 |
|
|
@@ -48,15 +57,25 @@
|
|
| 48 |
<img id="outputImage" alt="Result">
|
| 49 |
|
| 50 |
<script>
|
| 51 |
-
// НИКАКИХ IMPORT'ОВ — чистый JS
|
| 52 |
const btn = document.getElementById('generateBtn');
|
| 53 |
const tokenInput = document.getElementById('hf-token');
|
| 54 |
const modelSelect = document.getElementById('modelSelect');
|
|
|
|
|
|
|
| 55 |
const promptInput = document.getElementById('prompt');
|
| 56 |
const statusText = document.getElementById('statusText');
|
| 57 |
const errorContainer = document.getElementById('errorContainer');
|
| 58 |
const outputImage = document.getElementById('outputImage');
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
function showFullError(title, details) {
|
| 61 |
errorContainer.innerHTML = `
|
| 62 |
<div class="error-block">
|
|
@@ -72,8 +91,16 @@
|
|
| 72 |
|
| 73 |
btn.addEventListener('click', async () => {
|
| 74 |
const token = tokenInput.value.trim();
|
| 75 |
-
const model = modelSelect.value;
|
| 76 |
const prompt = promptInput.value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
clearError();
|
| 79 |
|
|
@@ -88,7 +115,6 @@
|
|
| 88 |
}
|
| 89 |
|
| 90 |
try {
|
| 91 |
-
// ПРЯМОЙ URL К РОУТЕРУ С ПРОВАЙДЕРОМ fal-ai
|
| 92 |
const apiUrl = `https://router.huggingface.co/fal-ai/models/${model}`;
|
| 93 |
|
| 94 |
statusText.textContent = `Запрос к: ${apiUrl}`;
|
|
|
|
| 19 |
.error-block h3 { margin: 0 0 10px 0; color: #dc2626; font-size: 16px; }
|
| 20 |
.error-block .code { background: #1f2937; color: #f9fafb; padding: 10px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 13px; overflow-x: auto; }
|
| 21 |
.info { background: #dbeafe; border: 1px solid #3b82f6; border-radius: 6px; padding: 10px; margin-bottom: 15px; font-size: 14px; }
|
| 22 |
+
.custom-model { display: none; margin-top: 10px; }
|
| 23 |
+
.custom-model.active { display: block; }
|
| 24 |
</style>
|
| 25 |
</head>
|
| 26 |
<body>
|
|
|
|
| 35 |
|
| 36 |
<label for="modelSelect">Модель:</label>
|
| 37 |
<select id="modelSelect">
|
| 38 |
+
<option value="black-forest-labs/FLUX.1-dev">FLUX.1-dev (Рекомендуется)</option>
|
| 39 |
+
<option value="black-forest-labs/FLUX.1-schnell">FLUX.1-schnell (Быстрая)</option>
|
| 40 |
+
<option value="stabilityai/stable-diffusion-3.5-large">Stable Diffusion 3.5 Large</option>
|
| 41 |
+
<option value="runwayml/stable-diffusion-v1-5">Stable Diffusion 1.5 (Классика)</option>
|
| 42 |
+
<option value="custom">✏️ Ввести ID модели вручную</option>
|
| 43 |
</select>
|
| 44 |
|
| 45 |
+
<div id="customModelBlock" class="custom-model">
|
| 46 |
+
<label for="customModel">ID модели (например: black-forest-labs/FLUX.1-dev):</label>
|
| 47 |
+
<input type="text" id="customModel" placeholder="owner/model-name">
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
<label for="prompt">Промпт:</label>
|
| 51 |
<textarea id="prompt" rows="3" placeholder="A cinematic shot of a cyberpunk city..."></textarea>
|
| 52 |
|
|
|
|
| 57 |
<img id="outputImage" alt="Result">
|
| 58 |
|
| 59 |
<script>
|
|
|
|
| 60 |
const btn = document.getElementById('generateBtn');
|
| 61 |
const tokenInput = document.getElementById('hf-token');
|
| 62 |
const modelSelect = document.getElementById('modelSelect');
|
| 63 |
+
const customModelBlock = document.getElementById('customModelBlock');
|
| 64 |
+
const customModelInput = document.getElementById('customModel');
|
| 65 |
const promptInput = document.getElementById('prompt');
|
| 66 |
const statusText = document.getElementById('statusText');
|
| 67 |
const errorContainer = document.getElementById('errorContainer');
|
| 68 |
const outputImage = document.getElementById('outputImage');
|
| 69 |
|
| 70 |
+
// Показ/скрытие поля для ручной модели
|
| 71 |
+
modelSelect.addEventListener('change', () => {
|
| 72 |
+
if (modelSelect.value === 'custom') {
|
| 73 |
+
customModelBlock.classList.add('active');
|
| 74 |
+
} else {
|
| 75 |
+
customModelBlock.classList.remove('active');
|
| 76 |
+
}
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
function showFullError(title, details) {
|
| 80 |
errorContainer.innerHTML = `
|
| 81 |
<div class="error-block">
|
|
|
|
| 91 |
|
| 92 |
btn.addEventListener('click', async () => {
|
| 93 |
const token = tokenInput.value.trim();
|
|
|
|
| 94 |
const prompt = promptInput.value.trim();
|
| 95 |
+
|
| 96 |
+
// Определяем модель
|
| 97 |
+
let model;
|
| 98 |
+
if (modelSelect.value === 'custom') {
|
| 99 |
+
model = customModelInput.value.trim();
|
| 100 |
+
if (!model) return showFullError('Ошибка валидации', 'Введи ID модели!');
|
| 101 |
+
} else {
|
| 102 |
+
model = modelSelect.value;
|
| 103 |
+
}
|
| 104 |
|
| 105 |
clearError();
|
| 106 |
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
try {
|
|
|
|
| 118 |
const apiUrl = `https://router.huggingface.co/fal-ai/models/${model}`;
|
| 119 |
|
| 120 |
statusText.textContent = `Запрос к: ${apiUrl}`;
|