-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
320 lines (296 loc) · 12.5 KB
/
index.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<!--
* Copyright (C) 2024 Intel Corporation. All rights reserved.
* Licensed under the Apache License 2.0. See LICENSE in the project root for license information.
* SPDX-License-Identifier: Apache-2.0
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="../../style/tailwind.css" rel="stylesheet" />
<link href="../../style/general.css" rel="stylesheet" />
<style>
select:focus,
textarea:focus {
outline: none;
border: 1px solid #000;
}
</style>
<title>Web AI - Image to text</title>
</head>
<body>
<div id="naviBar" class="sticky top-0 z-50"></div>
<div class="main-content container mx-auto w-full px-8 lg:px-20">
<div class="2xl:py-8 py-2">
<h1 class="text-shadow-sm">
<span
class="font-sans block text-4xl font-extrabold 2xl:text-5xl text-stone-50 text-center"
>Image to text
</span>
</h1>
</div>
<section
id="modelStatusPanel"
class="grid grid-rows 2xl:gap-2 gap-0.5 my-2 2xl:my-4"
>
<div
class="text-nowrap justify-self-center flex items-center text-stone-100 max-w-100 rounded-2xl backdrop-blur-xl px-2 font-mono gap-2 2xl:gap-4"
>
<div class="text-sm 2xl:text-md text-stone-50 font-semibold">
Model Status
</div>
<div class="flex flex-wrap items-center gap-2 2xl:gap-4">
<div
class="flex items-center justify-between imageDisplayEle text-xs 2xl:text-sm"
>
<span
class="rounded-l-md bg-stone-600 px-1 2xl:px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
encoder_model_quantized.onnx</span
>
<span
id="encoder_model_quantizedStatusBar"
class="rounded-r-md bg-neutral-400 2xl:min-h-[28px] 2xl:min-w-[68px] px-1 2xl:px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>unload
</span>
</div>
<div
class="flex items-center justify-between imageDisplayEle text-xs 2xl:text-sm"
>
<span
class="rounded-l-md bg-stone-600 px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
decoder_model_merged_quantized.onnx</span
>
<span
id="decoder_model_merged_quantizedStatusBar"
class="rounded-r-md bg-neutral-400 2xl:min-h-[28px] 2xl:min-w-[68px] px-1 2xl:px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>unload
</span>
</div>
</div>
</div>
<div
id="loadModelPromptContent"
class="justify-self-center italic text-stone-200/80 2xl:text-sm font-semibold text-xs"
>
[ Models will be loaded on first inference ]
</div>
</section>
<section id="modelsParams" class="grid grid-rows 2xl:gap-2 gap-0.5">
<div
class="text-nowrap justify-self-center flex items-center text-stone-100 max-w-100 rounded-2xl backdrop-blur-xl px-2 font-mono gap-2 2xl:gap-4"
>
<div class="text-stone-50 font-semibold 2xl:text-md text-sm">
Parameters
</div>
<div
class="flex flex-wrap items-center gap-2 2xl:gap-4 2xl:text-sm text-xs"
>
<div class="flex items-center justify-between">
<span
class="rounded-l-md bg-stone-600 px-1 2xl:px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
Max length</span
>
<input
id="max_new_tokens"
type="number"
class="rounded-r-md text-center bg-stone-50/60 2xl:min-h-[28px] max-w-[40px] 2xl:max-w-[60px] px-1 2xl:px-2 py-1 text-stone-800 ring-1 ring-inset ring-stone-500/10"
/>
</div>
</div>
<div
class="flex flex-wrap items-center gap-2 2xl:gap-4 2xl:text-sm text-xs"
>
<div class="flex items-center justify-between">
<span
class="rounded-l-md bg-stone-600 px-1 2xl:px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
No.beams
</span>
<input
id="num_beams"
type="number"
class="rounded-r-md text-center bg-stone-50/60 2xl:min-h-[28px] max-w-[40px] 2xl:max-w-[60px] px-1 2xl:px-2 py-1 text-stone-800 ring-1 ring-inset ring-stone-500/10"
/>
</div>
</div>
<div
class="flex flex-wrap items-center gap-2 2xl:gap-4 2xl:text-sm text-xs"
>
<div class="flex items-center justify-between">
<span
class="rounded-l-md bg-stone-600 px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
Temp.
</span>
<input
id="temperature"
type="number"
class="rounded-r-md text-center bg-stone-50/60 2xl:min-h-[28px] max-w-[40px] 2xl:max-w-[60px] px-1 2xl:px-2 py-1 text-stone-800 ring-1 ring-inset ring-stone-500/10"
/>
</div>
</div>
<div
class="flex flex-wrap items-center gap-2 2xl:gap-4 2xl:text-sm text-xs"
>
<div class="flex items-center justify-between">
<span
class="rounded-l-md bg-stone-600 px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
Top K
</span>
<input
id="top_k"
type="number"
class="rounded-r-md text-center bg-stone-50/60 2xl:min-h-[28px] max-w-[40px] 2xl:max-w-[60px] px-1 2xl:px-2 py-1 text-stone-800 ring-1 ring-inset ring-stone-500/10"
/>
</div>
</div>
<div
class="flex flex-wrap items-center gap-2 2xl:gap-4 2xl:text-sm text-xs"
>
<div class="flex items-center justify-between">
<span
class="rounded-l-md bg-stone-600 px-2 py-1 text-stone-50 ring-1 ring-inset ring-stone-500/10"
>
Sample</span
>
<select
id="do_sample"
class="w-[150px] bg-stone-50/60 px-1 2xl:px-2 2xl:py-1 rounded-r-md 2xl:min-h-[28px] min-h-[24px] max-w-[50px] 2xl:max-w-[80px] ring-1 ring-inset ring-stone-500/10 text-stone-800"
>
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</div>
</div>
</div>
<div
id="paramsPromptContent"
class="justify-self-center italic text-stone-200/80 2xl:text-sm font-semibold text-xs"
>
[ You can directly use the default values ]
</div>
</section>
<div class="grid gap-2 2xl:gap-6 mt-2 2xl:mt-8">
<div id="loadingModelText" class="hidden w-[720px] justify-self-center">
<div class="relative max-w-[280px] 2xl:my-2 min-h-[24px]">
<div class="absolute bottom-0 left-0">
<span
class="inline-flex items-center rounded-md bg-stone-50/60 px-2 py-1 font-semibold text-stone-700 ring-1 ring-inset ring-stone-500/10 text-xs 2xl:text-base"
>Downloading models ... (only once)</span
>
</div>
</div>
<div
id="progress"
class="justify-self-center items-center justify-center w-full"
></div>
</div>
<div
id="progressBar"
class="flex items-center justify-between font-mono justify-self-center relative hidden 2xl:rounded-2xl rounded-lg w-[720px] 2xl:min-h-[30px] min-h-[20px] bg-stone-200/40"
></div>
<div
class="2xl:grid justify-self-center 2xl:justify-normal justify-between flex justify-items-center 2xl:gap-6"
>
<div
class="w-[720px] flex justify-between 2xl:grid gap-2 2xl:gap-6 rounded-3xl"
>
<div
class="justify-self-center 2xl:flex 2xl:w-full 2xl:justify-between"
>
<div class="2xl:flex grid 2xl:gap-6 gap-2">
<div class="w-full flex gap-4 items-center">
<div class="relative">
<button
id="loadModelBtn"
class="w-[120px] control-entry bg-stone-500/50 hover:bg-stone-500 duration-200 text-stone-50 font-semibold p-2 rounded-md text-xs 2xl:text-base"
>
Load Models
</button>
<div
id="modelPopover"
class="transition-all ease-in-out delay-300 -z-50 opacity-0 absolute -top-[60px] left-[125px] 2xl:-top-[80px] backdrop-blur-xl"
>
<div
id="modelPanelWrapper"
class="w-screen max-w-[360px] 2xl:max-w-[420px] flex flex-col overflow-hidden rounded-2xl bg-stone-50/30 p-2"
></div>
</div>
</div>
</div>
<div class="flex gap-2 items-center">
<label
id="upload-button"
for="upload"
class="w-[120px] grid justify-center cursor-pointer control-entry transition ease-in-out bg-stone-500/50 2xl:hover:-translate-y-1 2xl:hover:translate-x-0 hover:translate-x-1 hover:bg-stone-500 duration-200 text-stone-50 font-semibold p-2 rounded-md text-xs 2xl:text-base"
>
<input
style="display: none"
type="file"
id="upload"
accept="image/*"
/>Upload image
</label>
</div>
<div>
<button
id="example"
class="w-[120px] cursor-pointer control-entry transition ease-in-out bg-blue-500 2xl:hover:-translate-y-1 2xl:hover:translate-x-0 hover:translate-x-1 hover:bg-indigo-500 duration-200 text-stone-50 font-semibold p-2 rounded-md text-xs 2xl:text-base"
>
Try example
</button>
</div>
</div>
<div
class="hidden rounded-md bg-stone-50/60 text-base font-semibold text-stone-500 mt-2 2xl:mt-0 text-xs 2xl:text-base"
>
<button id="status" class="p-2 w-[120px]" disabled></button>
</div>
</div>
<div
class="justify-self-center bg-stone-900/40 rounded-2xl w-[450px] 2xl:min-w-[720px] h-[300px] 2xl:min-h-[480px] overflow-hidden flex justify-center items-center"
id="image-wrapper"
>
<div id="generatingProgress">
<svg
width="80"
height="80"
viewBox="0 0 25 25"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill="#000"
d="M3.5 24.3a3 3 0 0 1-1.9-.8c-.5-.5-.8-1.2-.8-1.9V2.9c0-.7.3-1.3.8-1.9.6-.5 1.2-.7 2-.7h18.6c.7 0 1.3.2 1.9.7.5.6.7 1.2.7 2v18.6c0 .7-.2 1.4-.7 1.9a3 3 0 0 1-2 .8H3.6Zm0-2.7h18.7V2.9H3.5v18.7Zm2.7-2.7h13.3c.3 0 .5 0 .6-.3v-.7l-3.7-5a.6.6 0 0 0-.6-.2c-.2 0-.4 0-.5.3l-3.5 4.6-2.4-3.3a.6.6 0 0 0-.6-.3c-.2 0-.4.1-.5.3l-2.7 3.6c-.1.2-.2.4 0 .7.1.2.3.3.6.3Z"
></path>
</svg>
</div>
</div>
</div>
</div>
<div
class="justify-self-center flex items-center h-[30px] 2xl:h-[40px] w-[720px] bg-stone-900/40 backdrop-blur-md text-stone-50 rounded-md"
>
<textarea
readonly
class="w-full h-full text-sm 2xl:text-lg px-4 py-1 overflow-auto"
rows="1"
id="image2text-output-textbox"
style="
resize: none;
border-width: 0px;
background-color: transparent;
"
></textarea>
</div>
</div>
</div>
<footer id="footer"></footer>
</body>
<script type="module" src="./image_to_text.js"></script>
</html>