File size: 1,460 Bytes
2de3774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
<html>
    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
        #wrapper{
            background-size: contain; /* scales the image */
            background-position: center; /* centers the image */
        }
        img{
            max-width: 100%;
            max-height: 100%;
            bottom: 0;
            left: 0;
            margin: auto;
            overflow: auto;
            position: fixed;
            right: 0;
            top: 0;
            -o-object-fit: contain;
            object-fit: contain;
            zoom: 10;
        }
    </style>
    <head>
        <script type="module">
            import { client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
            const app = await client(window.location.origin);
            async function getimage() {
                try {
                    var result = await app.predict("/last_image");    
                    document.getElementById("last_image").src = "/gradio_api/file=" + result.data;
                    result = null;
                    setTimeout(getimage, 3000);
                } catch (error) {
                    // Error... Wait a while
                    setTimeout(getimage, 20000);
                }
            }
            setTimeout(getimage, 1000);
        </script>
    </head>
    <body bgcolor=black>
            <img id="last_image">
    </body>
</html>