jaison2611 commited on
Commit
80396eb
·
verified ·
1 Parent(s): fe6196f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +67 -18
index.html CHANGED
@@ -1,19 +1,68 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
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>WebGPU Free AI Space</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.1"></script>
8
+ <style>
9
+ body { font-family: sans-serif; text-align: center; background: #121212; color: white; padding: 20px; }
10
+ .container { max-width: 600px; margin: auto; background: #1e1e1e; padding: 30px; border-radius: 15px; }
11
+ #output { margin-top: 20px; font-weight: bold; color: #00ffcc; }
12
+ button { background: #00ffcc; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-weight: bold; }
13
+ .status { color: #888; font-size: 0.8em; margin-top: 10px; }
14
+ </style>
15
+ </head>
16
+ <body>
17
+
18
+ <div class="container">
19
+ <h1>WebGPU AI Studio</h1>
20
+ <p>This runs entirely in your browser using your local GPU.</p>
21
+
22
+ <input type="file" id="upload" accept="image/*"><br><br>
23
+ <button id="process-btn">Analyze Image</button>
24
+
25
+ <div id="status" class="status">Model Status: Ready (WebGPU)</div>
26
+ <div id="output">Result will appear here...</div>
27
+ <img id="preview" style="max-width: 100%; margin-top: 20px; border-radius: 10px; display: none;">
28
+ </div>
29
+
30
+ <script type="module">
31
+ const status = document.getElementById('status');
32
+ const output = document.getElementById('output');
33
+ const upload = document.getElementById('upload');
34
+ const preview = document.getElementById('preview');
35
+ const btn = document.getElementById('process-btn');
36
+
37
+ // Load the pipeline from Transformers.js
38
+ let classifier;
39
+
40
+ async function init() {
41
+ status.textContent = "Loading Model (using WebGPU)...";
42
+ classifier = await window.Transformers.pipeline('image-classification', 'Xenova/vit-gpt2-image-captioning', {
43
+ device: 'webgpu'
44
+ });
45
+ status.textContent = "Model Loaded & WebGPU Active!";
46
+ }
47
+
48
+ upload.onchange = (e) => {
49
+ const file = e.target.files[0];
50
+ preview.src = URL.createObjectURL(file);
51
+ preview.style.display = 'block';
52
+ };
53
+
54
+ btn.onclick = async () => {
55
+ if (!classifier) await init();
56
+ if (!upload.files[0]) return alert("Please upload an image first!");
57
+
58
+ output.textContent = "Processing...";
59
+ const result = await classifier(preview.src);
60
+ output.textContent = "I see: " + result[0].label;
61
+ };
62
+
63
+ // Auto-init on load
64
+ init();
65
+ </script>
66
+
67
+ </body>
68
  </html>