File size: 2,643 Bytes
ab9f226
dd1b723
 
70f90b2
 
 
 
 
dd1b723
 
70f90b2
 
 
 
 
dd1b723
70f90b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd1b723
70f90b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd1b723
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Moondream2 Visual Assistant</title>
    <link rel="stylesheet" href="style.css">
    <meta name="description" content="AI-powered image description using Moondream2 and Transformers.js">
</head>
<body>
    <div class="container">
        <header>
            <h1>Moondream2 Visual Assistant</h1>
            <p>Upload an image and ask questions about it using AI</p>
        </header>

        <main>
            <div class="upload-section">
                <div class="upload-area" id="uploadArea">
                    <div class="upload-content">
                        <svg class="upload-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
                            <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                            <polyline points="7 10 12 15 17 10"></polyline>
                            <line x1="12" y1="15" x2="12" y2="3"></line>
                        </svg>
                        <p>Drop an image here or <span>browse</span></p>
                        <input type="file" id="fileInput" accept="image/*" hidden>
                    </div>
                </div>

                <div class="image-preview" id="imagePreview" style="display: none;">
                    <img id="previewImage" alt="Preview">
                    <button class="remove-btn" id="removeBtn">×</button>
                </div>
            </div>

            <div class="query-section" id="querySection" style="display: none;">
                <div class="input-group">
                    <input type="text" id="questionInput" placeholder="Ask a question about the image..." maxlength="200">
                    <button id="askBtn" disabled>Ask</button>
                </div>
            </div>

            <div class="response-section" id="responseSection" style="display: none;">
                <h2>Response</h2>
                <div class="response-content">
                    <div class="loading" id="loading" style="display: none;">
                        <div class="spinner"></div>
                        <p>Analyzing image...</p>
                    </div>
                    <div class="response-text" id="responseText"></div>
                </div>
            </div>
        </main>

        <footer>
            <p>Powered by <a href="https://huggingface.co/Xenova/moondream2" target="_blank">Moondream2</a> and Transformers.js</p>
        </footer>
    </div>

    <script type="module" src="index.js"></script>
</body>
</html>