File size: 1,501 Bytes
967ec2e
c155fff
 
 
 
 
 
 
 
 
1a3e788
 
 
 
 
 
c155fff
 
 
 
1a3e788
 
 
 
 
c155fff
 
 
1a3e788
 
 
 
 
 
 
 
c155fff
 
 
 
 
967ec2e
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
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gradio Integration Example</title>
</head>
<body>
    <h1>Gradio Integration</h1>

    <input type="text" id="inputText" placeholder="Enter your text">
    <input type="file" id="inputImage" accept="image/*">
    <button id="predictButton">Predict</button>
    <p id="result"></p>

    <!-- Votre balise script pour le code JavaScript -->
    <script type="module">
        import { client } from "@gradio/client";

        const inputText = document.getElementById('inputText');
        const inputImage = document.getElementById('inputImage');
        const predictButton = document.getElementById('predictButton');
        const resultElement = document.getElementById('result');

        async function runExample() {
            const app = await client("https://docfile-mariam-physique1.hf.space/--replicas/ptlbx/");

            predictButton.addEventListener('click', async () => {
                const text = inputText.value;
                const imageFile = inputImage.files[0];
                const imageData = await imageFile.arrayBuffer();

                const result = await app.predict("/predict", [text, imageData]);
                resultElement.textContent = JSON.stringify(result.data);
            });
        }

        runExample();
    </script>
</body>
</html>