Spaces:
Runtime error
Runtime error
Update static/index.html
Browse files- static/index.html +27 -14
static/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
form {
|
| 20 |
margin-bottom: 20px;
|
| 21 |
}
|
| 22 |
-
input[type="file"], input[type="text"], button {
|
| 23 |
display: block;
|
| 24 |
margin: 10px 0;
|
| 25 |
padding: 10px;
|
|
@@ -41,27 +41,31 @@
|
|
| 41 |
<h2>Document Summarization</h2>
|
| 42 |
<form id="summarizeForm">
|
| 43 |
<input type="file" id="document" name="document" accept=".pdf,.docx">
|
|
|
|
|
|
|
| 44 |
<button type="submit">Summarize</button>
|
| 45 |
</form>
|
| 46 |
<div class="result" id="summaryResult"></div>
|
| 47 |
|
| 48 |
-
<!-- Image Captioning -->
|
| 49 |
-
<h2>Image Captioning</h2>
|
| 50 |
-
<form id="captionForm">
|
| 51 |
-
<input type="file" id="image" name="image" accept=".jpg,.jpeg,.png">
|
| 52 |
-
<button type="submit">Generate Caption</button>
|
| 53 |
-
</form>
|
| 54 |
-
<div class="result" id="captionResult"></div>
|
| 55 |
-
|
| 56 |
<!-- Text-Based Question Answering -->
|
| 57 |
<h2>Text-Based Question Answering</h2>
|
| 58 |
<form id="qaForm">
|
| 59 |
<input type="file" id="qaDocument" name="document" accept=".pdf,.docx">
|
|
|
|
|
|
|
| 60 |
<input type="text" id="question" name="question" placeholder="Enter your question">
|
| 61 |
<button type="submit">Ask</button>
|
| 62 |
</form>
|
| 63 |
<div class="result" id="qaResult"></div>
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
<!-- Visual Question Answering -->
|
| 66 |
<h2>Visual Question Answering</h2>
|
| 67 |
<form id="vqaForm">
|
|
@@ -78,11 +82,20 @@
|
|
| 78 |
event.preventDefault();
|
| 79 |
const formData = new FormData();
|
| 80 |
const fileInput = event.target.querySelector('input[type="file"]');
|
| 81 |
-
const textInput = event.target.querySelector('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
formData.append("question", textInput.value);
|
| 86 |
}
|
| 87 |
|
| 88 |
const response = await fetch(endpoint, {
|
|
@@ -95,8 +108,8 @@
|
|
| 95 |
|
| 96 |
// Attach event listeners to forms
|
| 97 |
document.getElementById("summarizeForm").onsubmit = (e) => handleFormSubmit(e, "/summarize", "summaryResult");
|
| 98 |
-
document.getElementById("captionForm").onsubmit = (e) => handleFormSubmit(e, "/caption", "captionResult");
|
| 99 |
document.getElementById("qaForm").onsubmit = (e) => handleFormSubmit(e, "/answer", "qaResult");
|
|
|
|
| 100 |
document.getElementById("vqaForm").onsubmit = (e) => handleFormSubmit(e, "/vqa", "vqaResult");
|
| 101 |
</script>
|
| 102 |
</body>
|
|
|
|
| 19 |
form {
|
| 20 |
margin-bottom: 20px;
|
| 21 |
}
|
| 22 |
+
input[type="file"], input[type="text"], textarea, button {
|
| 23 |
display: block;
|
| 24 |
margin: 10px 0;
|
| 25 |
padding: 10px;
|
|
|
|
| 41 |
<h2>Document Summarization</h2>
|
| 42 |
<form id="summarizeForm">
|
| 43 |
<input type="file" id="document" name="document" accept=".pdf,.docx">
|
| 44 |
+
<p>Or</p>
|
| 45 |
+
<textarea id="manualText" name="text" placeholder="Enter text manually"></textarea>
|
| 46 |
<button type="submit">Summarize</button>
|
| 47 |
</form>
|
| 48 |
<div class="result" id="summaryResult"></div>
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
<!-- Text-Based Question Answering -->
|
| 51 |
<h2>Text-Based Question Answering</h2>
|
| 52 |
<form id="qaForm">
|
| 53 |
<input type="file" id="qaDocument" name="document" accept=".pdf,.docx">
|
| 54 |
+
<p>Or</p>
|
| 55 |
+
<textarea id="qaText" name="text" placeholder="Enter text manually"></textarea>
|
| 56 |
<input type="text" id="question" name="question" placeholder="Enter your question">
|
| 57 |
<button type="submit">Ask</button>
|
| 58 |
</form>
|
| 59 |
<div class="result" id="qaResult"></div>
|
| 60 |
|
| 61 |
+
<!-- Image Captioning -->
|
| 62 |
+
<h2>Image Captioning</h2>
|
| 63 |
+
<form id="captionForm">
|
| 64 |
+
<input type="file" id="image" name="image" accept=".jpg,.jpeg,.png">
|
| 65 |
+
<button type="submit">Generate Caption</button>
|
| 66 |
+
</form>
|
| 67 |
+
<div class="result" id="captionResult"></div>
|
| 68 |
+
|
| 69 |
<!-- Visual Question Answering -->
|
| 70 |
<h2>Visual Question Answering</h2>
|
| 71 |
<form id="vqaForm">
|
|
|
|
| 82 |
event.preventDefault();
|
| 83 |
const formData = new FormData();
|
| 84 |
const fileInput = event.target.querySelector('input[type="file"]');
|
| 85 |
+
const textInput = event.target.querySelector('textarea');
|
| 86 |
+
const questionInput = event.target.querySelector('input[type="text"]');
|
| 87 |
+
|
| 88 |
+
if (fileInput.files[0]) {
|
| 89 |
+
formData.append("file", fileInput.files[0]);
|
| 90 |
+
} else if (textInput && textInput.value) {
|
| 91 |
+
formData.append("text", textInput.value);
|
| 92 |
+
} else {
|
| 93 |
+
alert("Please upload a file or enter text manually.");
|
| 94 |
+
return;
|
| 95 |
+
}
|
| 96 |
|
| 97 |
+
if (questionInput) {
|
| 98 |
+
formData.append("question", questionInput.value);
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
const response = await fetch(endpoint, {
|
|
|
|
| 108 |
|
| 109 |
// Attach event listeners to forms
|
| 110 |
document.getElementById("summarizeForm").onsubmit = (e) => handleFormSubmit(e, "/summarize", "summaryResult");
|
|
|
|
| 111 |
document.getElementById("qaForm").onsubmit = (e) => handleFormSubmit(e, "/answer", "qaResult");
|
| 112 |
+
document.getElementById("captionForm").onsubmit = (e) => handleFormSubmit(e, "/caption", "captionResult");
|
| 113 |
document.getElementById("vqaForm").onsubmit = (e) => handleFormSubmit(e, "/vqa", "vqaResult");
|
| 114 |
</script>
|
| 115 |
</body>
|