File size: 816 Bytes
1e5f3d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
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
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
    <title>VQA App</title>
</head>
<body>

<h2>Visual Question Answering</h2>

<input type="file" id="image"><br><br>
<input type="text" id="question" placeholder="Ask a question"><br><br>

<button onclick="send()">Submit</button>

<h3 id="result"></h3>

<script>
async function send() {
    const file = document.getElementById("image").files[0];
    const question = document.getElementById("question").value;

    let formData = new FormData();
    formData.append("file", file);
    formData.append("question", question);

    const res = await fetch("http://127.0.0.1:8000/predict", {
        method: "POST",
        body: formData
    });

    const data = await res.json();
    document.getElementById("result").innerText = data.answer || data.error;
}
</script>

</body>
</html>