Kortikov Mikhail commited on
Commit
5722f16
1 Parent(s): a940bc4
Files changed (3) hide show
  1. static/index.html +0 -36
  2. static/script.js +0 -17
  3. templates/index.html +45 -0
static/index.html DELETED
@@ -1,36 +0,0 @@
1
- <main>
2
- <section id="text-gen">
3
- <h2 class="relative group">
4
- <a
5
- id="text-generation-using-flan-t5"
6
- class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"
7
- href="#text-generation-using-flan-t5"
8
- >
9
- <span><IconCopyLink/></span>
10
- </a>
11
- <span>
12
- Text generation using Flan T5
13
- </span>
14
- </h2>
15
-
16
- <p>
17
- Model:
18
- <a
19
- href="https://huggingface.co/google/flan-t5-small"
20
- rel="noreferrer"
21
- target="_blank"
22
- >google/flan-t5-small
23
- </a>
24
- </p>
25
- <form class="text-gen-form">
26
- <label for="text-gen-input">Text prompt</label>
27
- <input
28
- id="text-gen-input"
29
- type="text"
30
- value="German: There are many ducks"
31
- />
32
- <button id="text-gen-submit">Submit</button>
33
- <p class="text-gen-output"></p>
34
- </form>
35
- </section>
36
- </main>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/script.js DELETED
@@ -1,17 +0,0 @@
1
- const textGenForm = document.querySelector(".text-gen-form");
2
-
3
- const translateText = async (text) => {
4
- const inferResponse = await fetch(`infer_t5?input=${text}`);
5
- const inferJson = await inferResponse.json();
6
-
7
- return inferJson.output;
8
- };
9
-
10
- textGenForm.addEventListener("submit", async (event) => {
11
- event.preventDefault();
12
-
13
- const textGenInput = document.getElementById("text-gen-input");
14
- const textGenParagraph = document.querySelector(".text-gen-output");
15
-
16
- textGenParagraph.textContent = await translateText(textGenInput.value);
17
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/index.html ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Fruit Recognition</title>
7
+ </head>
8
+ <body>
9
+ <h1>Fruit Recognition</h1>
10
+ <input type="file" id="inputImage" accept="image/*">
11
+ <button onclick="submitImage()">Predict</button>
12
+ <p id="result"></p>
13
+
14
+ <script>
15
+ async function submitImage() {
16
+ const inputImage = document.getElementById("inputImage");
17
+ const resultElement = document.getElementById("result");
18
+
19
+ if (inputImage.files.length > 0) {
20
+ const formData = new FormData();
21
+ formData.append("file", inputImage.files[0]);
22
+
23
+ try {
24
+ const response = await fetch("/predict/", {
25
+ method: "POST",
26
+ body: formData,
27
+ });
28
+
29
+ if (response.ok) {
30
+ const data = await response.json();
31
+ resultElement.innerText = `Predicted class: ${data.predicted_class}`;
32
+ } else {
33
+ const error = await response.json();
34
+ resultElement.innerText = `Error: ${error.error}`;
35
+ }
36
+ } catch (error) {
37
+ resultElement.innerText = `Error: ${error.message}`;
38
+ }
39
+ } else {
40
+ resultElement.innerText = "Please select an image.";
41
+ }
42
+ }
43
+ </script>
44
+ </body>
45
+ </html>