Update templates/index.html
Browse files- templates/index.html +7 -18
templates/index.html
CHANGED
|
@@ -146,6 +146,7 @@
|
|
| 146 |
.gpu-error-message-container .error-content ul { list-style-type: "▫️ "; padding-right: 20px; margin-top: 10px; }
|
| 147 |
.gpu-error-message-container .error-content li { margin-bottom: 6px; }
|
| 148 |
.gpu-error-actions { display: flex; gap: 15px; margin-top: 25px; }
|
|
|
|
| 149 |
.gpu-error-actions .action-button.back-button { background-color: var(--panel-bg); color: var(--text-tertiary); border: 1px solid var(--panel-border); flex-grow: 0.45; }
|
| 150 |
.gpu-error-actions .action-button.retry-button { background: linear-gradient(60deg, var(--igadlm-alpha-color-primary) 0%, var(--igadlm-alpha-color-secondary) 100%); color: white; flex-grow: 1; }
|
| 151 |
|
|
@@ -430,7 +431,7 @@
|
|
| 430 |
const TRANSLATION_TIMEOUT = 20000;
|
| 431 |
|
| 432 |
let lastAttemptedVideoPayload = null;
|
| 433 |
-
let eventSource = null;
|
| 434 |
|
| 435 |
const generateSessionHash = () => Math.random().toString(36).substring(2, 13);
|
| 436 |
|
|
@@ -663,12 +664,10 @@
|
|
| 663 |
console.warn("Translation failed:", e.message);
|
| 664 |
addStatusMessage('ترجمه ناموفق بود. با متن فارسی ادامه میدهیم.', 'error');
|
| 665 |
}
|
| 666 |
-
|
| 667 |
-
// === START: ROBUST DIRECT API INTERACTION ===
|
| 668 |
const sessionHash = generateSessionHash();
|
| 669 |
|
| 670 |
try {
|
| 671 |
-
// Step 1: Upload File
|
| 672 |
setAiLoaderText("۱/۳: در حال آپلود عکس...");
|
| 673 |
const formData = new FormData();
|
| 674 |
formData.append('files', imageFile);
|
|
@@ -677,19 +676,11 @@
|
|
| 677 |
const uploadedFiles = await uploadResponse.json();
|
| 678 |
const serverFilePath = uploadedFiles[0];
|
| 679 |
|
| 680 |
-
// Step 2: Join Queue
|
| 681 |
setAiLoaderText("۲/۳: ارسال درخواست به صف...");
|
| 682 |
const joinPayload = {
|
| 683 |
"data": [
|
| 684 |
{"path": serverFilePath, "url": `${VIDEO_SPACE_URL}gradio_api/file=${serverFilePath}`},
|
| 685 |
-
promptForVideo,
|
| 686 |
-
6, // steps
|
| 687 |
-
DEFAULT_NEGATIVE_PROMPT,
|
| 688 |
-
duration,
|
| 689 |
-
1, // guidance_scale
|
| 690 |
-
1, // guidance_scale_2
|
| 691 |
-
0, // seed (0 = random)
|
| 692 |
-
true // randomize_seed
|
| 693 |
],
|
| 694 |
"fn_index": 0, "session_hash": sessionHash
|
| 695 |
};
|
|
@@ -698,13 +689,12 @@
|
|
| 698 |
});
|
| 699 |
if (!joinResponse.ok) throw new Error(`خطا در اتصال به صف: ${joinResponse.statusText}`);
|
| 700 |
|
| 701 |
-
// Step 3: Listen for Data
|
| 702 |
setAiLoaderText("۳/۳: منتظر دریافت نتیجه...");
|
| 703 |
eventSource = new EventSource(`${VIDEO_SPACE_URL}gradio_api/queue/data?session_hash=${sessionHash}`);
|
| 704 |
|
| 705 |
-
eventSource.onmessage = (event) => {
|
| 706 |
const data = JSON.parse(event.data);
|
| 707 |
-
console.log(data);
|
| 708 |
|
| 709 |
switch (data.msg) {
|
| 710 |
case 'estimation':
|
|
@@ -734,7 +724,7 @@
|
|
| 734 |
if (data.success) {
|
| 735 |
setProgressBar(100);
|
| 736 |
setAiLoaderText("پردازش کامل شد!");
|
| 737 |
-
handleSuccessfulVideoGeneration(data.output);
|
| 738 |
} else {
|
| 739 |
const errorMessage = data.output?.error || "یک خطای نامشخص رخ داد.";
|
| 740 |
const isGpuQuotaError = /exceeded your gpu quota/i.test(errorMessage);
|
|
@@ -757,7 +747,6 @@
|
|
| 757 |
showCriticalError(`خطای اولیه: ${errorCaught.message}`);
|
| 758 |
generateButton.disabled = false;
|
| 759 |
}
|
| 760 |
-
// === END: ROBUST DIRECT API INTERACTION ===
|
| 761 |
};
|
| 762 |
|
| 763 |
generateButton.addEventListener('click', async () => {
|
|
|
|
| 146 |
.gpu-error-message-container .error-content ul { list-style-type: "▫️ "; padding-right: 20px; margin-top: 10px; }
|
| 147 |
.gpu-error-message-container .error-content li { margin-bottom: 6px; }
|
| 148 |
.gpu-error-actions { display: flex; gap: 15px; margin-top: 25px; }
|
| 149 |
+
.gpu-error-actions .action-button { padding: 0.8rem 1.5rem; border-radius: var(--igadlm-alpha-border-radius-md); border: none; cursor: pointer; font-family: var(--app-font); font-weight: 600; font-size: 1rem; transition: var(--transition-smooth); display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
|
| 150 |
.gpu-error-actions .action-button.back-button { background-color: var(--panel-bg); color: var(--text-tertiary); border: 1px solid var(--panel-border); flex-grow: 0.45; }
|
| 151 |
.gpu-error-actions .action-button.retry-button { background: linear-gradient(60deg, var(--igadlm-alpha-color-primary) 0%, var(--igadlm-alpha-color-secondary) 100%); color: white; flex-grow: 1; }
|
| 152 |
|
|
|
|
| 431 |
const TRANSLATION_TIMEOUT = 20000;
|
| 432 |
|
| 433 |
let lastAttemptedVideoPayload = null;
|
| 434 |
+
let eventSource = null;
|
| 435 |
|
| 436 |
const generateSessionHash = () => Math.random().toString(36).substring(2, 13);
|
| 437 |
|
|
|
|
| 664 |
console.warn("Translation failed:", e.message);
|
| 665 |
addStatusMessage('ترجمه ناموفق بود. با متن فارسی ادامه میدهیم.', 'error');
|
| 666 |
}
|
| 667 |
+
|
|
|
|
| 668 |
const sessionHash = generateSessionHash();
|
| 669 |
|
| 670 |
try {
|
|
|
|
| 671 |
setAiLoaderText("۱/۳: در حال آپلود عکس...");
|
| 672 |
const formData = new FormData();
|
| 673 |
formData.append('files', imageFile);
|
|
|
|
| 676 |
const uploadedFiles = await uploadResponse.json();
|
| 677 |
const serverFilePath = uploadedFiles[0];
|
| 678 |
|
|
|
|
| 679 |
setAiLoaderText("۲/۳: ارسال درخواست به صف...");
|
| 680 |
const joinPayload = {
|
| 681 |
"data": [
|
| 682 |
{"path": serverFilePath, "url": `${VIDEO_SPACE_URL}gradio_api/file=${serverFilePath}`},
|
| 683 |
+
promptForVideo, 6, DEFAULT_NEGATIVE_PROMPT, duration, 1, 1, 0, true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
],
|
| 685 |
"fn_index": 0, "session_hash": sessionHash
|
| 686 |
};
|
|
|
|
| 689 |
});
|
| 690 |
if (!joinResponse.ok) throw new Error(`خطا در اتصال به صف: ${joinResponse.statusText}`);
|
| 691 |
|
|
|
|
| 692 |
setAiLoaderText("۳/۳: منتظر دریافت نتیجه...");
|
| 693 |
eventSource = new EventSource(`${VIDEO_SPACE_URL}gradio_api/queue/data?session_hash=${sessionHash}`);
|
| 694 |
|
| 695 |
+
eventSource.onmessage = async (event) => {
|
| 696 |
const data = JSON.parse(event.data);
|
| 697 |
+
console.log(data);
|
| 698 |
|
| 699 |
switch (data.msg) {
|
| 700 |
case 'estimation':
|
|
|
|
| 724 |
if (data.success) {
|
| 725 |
setProgressBar(100);
|
| 726 |
setAiLoaderText("پردازش کامل شد!");
|
| 727 |
+
await handleSuccessfulVideoGeneration(data.output);
|
| 728 |
} else {
|
| 729 |
const errorMessage = data.output?.error || "یک خطای نامشخص رخ داد.";
|
| 730 |
const isGpuQuotaError = /exceeded your gpu quota/i.test(errorMessage);
|
|
|
|
| 747 |
showCriticalError(`خطای اولیه: ${errorCaught.message}`);
|
| 748 |
generateButton.disabled = false;
|
| 749 |
}
|
|
|
|
| 750 |
};
|
| 751 |
|
| 752 |
generateButton.addEventListener('click', async () => {
|