prithivMLmods commited on
Commit
d73aead
·
verified ·
1 Parent(s): 7b2b6fa

update UI + [theme & bug fix]

Browse files
Files changed (1) hide show
  1. index.html +1143 -0
index.html ADDED
@@ -0,0 +1,1143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Qwen3.8 Studio · Object Detection</title>
7
+ <style>
8
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
9
+ *{box-sizing:border-box;margin:0;padding:0}
10
+ :root{
11
+ --bg:#0a0a0c;--panel:#131316;--panel2:#0e0e11;--canvas:#08080a;
12
+ --border:#2a1c16;--border2:#3f2820;
13
+ --text:#e4e4e7;--muted:#a1a1aa;--dim:#6b6b75;--faint:#4a4a52;
14
+ --accent:#FF4500;--accent2:#FF6A20;--accent3:#FF9966;
15
+ --menubar-h:48px;--statusbar-h:30px;--rail-w:52px;--inspector-w:360px;--filmstrip-h:132px;
16
+ }
17
+ html,body{height:100%}
18
+ body{
19
+ background:var(--bg);font-family:'Inter',system-ui,-apple-system,sans-serif;
20
+ font-size:13px;color:var(--text);overflow:hidden;
21
+ }
22
+
23
+ /* ══ Layout grid ══ */
24
+ .studio{
25
+ display:grid;height:100vh;
26
+ grid-template-rows:var(--menubar-h) 1fr var(--statusbar-h);
27
+ grid-template-columns:var(--rail-w) 1fr var(--inspector-w);
28
+ grid-template-areas:
29
+ "menubar menubar menubar"
30
+ "rail workspace inspector"
31
+ "statusbar statusbar statusbar";
32
+ }
33
+
34
+ /* ══ Menu bar ══ */
35
+ .menubar{
36
+ grid-area:menubar;display:flex;align-items:center;gap:14px;
37
+ background:var(--panel);border-bottom:1px solid var(--border);
38
+ padding:0 16px;z-index:50;
39
+ }
40
+ .menubar-logo{
41
+ width:28px;height:28px;background:linear-gradient(135deg,#FF4500,#FF6A20,#FF9966);
42
+ border-radius:8px;display:flex;align-items:center;justify-content:center;
43
+ box-shadow:0 2px 8px rgba(255,69,0,.35);flex-shrink:0;
44
+ }
45
+ .menubar-logo svg{width:15px;height:15px;fill:#fff}
46
+ .menubar-title{font-size:14px;font-weight:700;letter-spacing:-.2px;white-space:nowrap}
47
+ .menubar-title span{color:var(--dim);font-weight:500}
48
+ .menubar-badge{
49
+ font-size:10px;font-weight:700;padding:2px 8px;border-radius:12px;
50
+ background:rgba(255,69,0,.14);color:var(--accent2);border:1px solid rgba(255,69,0,.25);
51
+ letter-spacing:.4px;white-space:nowrap;
52
+ }
53
+ .menubar-badge.fast{background:rgba(34,197,94,.12);color:#4ade80;border-color:rgba(34,197,94,.25)}
54
+ .menubar-spacer{flex:1}
55
+ .menubar-status{
56
+ display:flex;align-items:center;gap:7px;font-family:'JetBrains Mono',monospace;
57
+ font-size:11px;color:var(--dim);
58
+ }
59
+ .menubar-status .dot{width:7px;height:7px;border-radius:50%;background:#4ade80;box-shadow:0 0 6px rgba(74,222,128,.6)}
60
+ .menubar-status .dot.off{background:#f87171;box-shadow:0 0 6px rgba(248,113,113,.5)}
61
+ .gh-btn{
62
+ display:inline-flex;align-items:center;gap:6px;
63
+ padding:5px 13px;border-radius:7px;text-decoration:none;
64
+ font-size:12px;font-weight:600;background:var(--accent);color:#fff;
65
+ border:1px solid rgba(255,255,255,.15);
66
+ transition:all .15s ease;flex-shrink:0;
67
+ }
68
+ .gh-btn:hover{background:var(--accent2)}
69
+ .gh-btn svg{fill:#fff;width:13px;height:13px}
70
+
71
+ /* ══ Left icon rail ══ */
72
+ .rail{
73
+ grid-area:rail;background:var(--panel);border-right:1px solid var(--border);
74
+ display:flex;flex-direction:column;align-items:center;padding:10px 0;gap:4px;
75
+ overflow-y:auto;z-index:40;
76
+ }
77
+ .rail-btn{
78
+ width:38px;height:38px;border-radius:9px;border:1px solid transparent;
79
+ background:transparent;color:var(--dim);cursor:pointer;
80
+ display:flex;align-items:center;justify-content:center;
81
+ transition:all .15s ease;position:relative;
82
+ }
83
+ .rail-btn:hover:not(:disabled){background:rgba(255,69,0,.12);color:var(--accent3);border-color:rgba(255,69,0,.25)}
84
+ .rail-btn.active{background:rgba(255,69,0,.2);color:var(--accent2);border-color:rgba(255,69,0,.4)}
85
+ .rail-btn:disabled{opacity:.3;cursor:not-allowed}
86
+ .rail-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
87
+ .rail-btn svg.fill{fill:currentColor;stroke:none}
88
+ .rail-sep{width:24px;height:1px;background:var(--border);margin:6px 0}
89
+ .rail-label{
90
+ font-size:8px;font-weight:700;color:var(--faint);letter-spacing:1px;
91
+ text-transform:uppercase;margin:8px 0 2px;user-select:none;
92
+ }
93
+
94
+ /* ══ Workspace ══ */
95
+ .workspace{
96
+ grid-area:workspace;display:flex;flex-direction:column;min-width:0;min-height:0;
97
+ background:var(--canvas);
98
+ }
99
+ .canvas-head{
100
+ display:flex;align-items:center;gap:10px;padding:8px 16px;
101
+ border-bottom:1px solid var(--border);background:var(--panel2);flex-shrink:0;
102
+ }
103
+ .seg-control{
104
+ display:inline-flex;background:var(--panel);border:1px solid var(--border);
105
+ border-radius:8px;padding:2px;gap:2px;
106
+ }
107
+ .seg-btn{
108
+ padding:4px 14px;font-size:11px;font-weight:600;color:var(--dim);
109
+ background:transparent;border:none;border-radius:6px;cursor:pointer;
110
+ font-family:'Inter',sans-serif;transition:all .15s;letter-spacing:.2px;
111
+ }
112
+ .seg-btn:hover:not(.active){color:var(--muted)}
113
+ .seg-btn.active{background:rgba(255,69,0,.18);color:var(--accent2)}
114
+ .canvas-meta{
115
+ font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--faint);
116
+ overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;
117
+ }
118
+ .canvas-actions{display:flex;align-items:center;gap:6px}
119
+ .out-seed-chip{
120
+ display:none;font-family:'JetBrains Mono',monospace;font-size:10px;font-weight:500;
121
+ color:var(--dim);background:var(--panel);border:1px solid var(--border);
122
+ border-radius:6px;padding:4px 9px;cursor:pointer;transition:all .15s;
123
+ }
124
+ .out-seed-chip.visible{display:inline-flex}
125
+ .out-seed-chip:hover{color:var(--accent3);border-color:rgba(255,69,0,.35)}
126
+
127
+ .canvas-stage{
128
+ flex:1;position:relative;overflow:hidden;min-height:0;
129
+ display:flex;align-items:center;justify-content:center;
130
+ background:
131
+ repeating-conic-gradient(#0c0c0f 0% 25%, #08080a 0% 50%) 0 0/24px 24px;
132
+ }
133
+ .canvas-stage img.modern-out-img{
134
+ max-width:calc(100% - 48px);max-height:calc(100% - 48px);
135
+ box-shadow:0 12px 48px rgba(0,0,0,.7),0 0 0 1px var(--border);
136
+ border-radius:4px;cursor:zoom-in;image-rendering:auto;
137
+ animation:canvasIn .3s ease;
138
+ }
139
+ @keyframes canvasIn{from{opacity:0;transform:scale(.985)}to{opacity:1;transform:scale(1)}}
140
+ .canvas-placeholder{
141
+ text-align:center;color:var(--faint);user-select:none;
142
+ display:flex;flex-direction:column;align-items:center;gap:14px;padding:24px;
143
+ }
144
+ .canvas-placeholder svg{width:72px;height:72px;opacity:.5}
145
+ .canvas-placeholder .cp-title{font-size:15px;font-weight:600;color:var(--dim)}
146
+ .canvas-placeholder .cp-sub{font-size:12px;line-height:1.7;max-width:340px}
147
+ .canvas-placeholder kbd{
148
+ padding:1px 6px;background:var(--panel);border:1px solid var(--border2);
149
+ border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--muted);
150
+ }
151
+
152
+ /* Loader */
153
+ .modern-loader{
154
+ display:none;position:absolute;inset:0;background:rgba(8,8,10,.9);
155
+ z-index:15;flex-direction:column;align-items:center;justify-content:center;gap:16px;backdrop-filter:blur(5px);
156
+ }
157
+ .modern-loader.active{display:flex}
158
+ .loader-spinner{
159
+ width:38px;height:38px;border:3px solid var(--border);border-top-color:var(--accent);
160
+ border-radius:50%;animation:spin .8s linear infinite;
161
+ }
162
+ @keyframes spin{to{transform:rotate(360deg)}}
163
+ .loader-text{font-size:13px;color:var(--muted);font-weight:500;text-align:center;padding:0 16px}
164
+ .loader-bar-track{width:220px;height:4px;background:var(--border);border-radius:2px;overflow:hidden}
165
+ .loader-bar-fill{
166
+ height:100%;width:100%;background:linear-gradient(90deg,#FF4500,#FF6A20,#FF4500);
167
+ background-size:200% 100%;animation:shimmer 1.5s ease-in-out infinite;border-radius:2px;
168
+ transition:width .3s ease;
169
+ }
170
+ .loader-bar-fill.determinate{animation:none;background:var(--accent)}
171
+ @keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
172
+
173
+ /* ══ Filmstrip ══ */
174
+ .filmstrip{
175
+ height:var(--filmstrip-h);flex-shrink:0;background:var(--panel);
176
+ border-top:1px solid var(--border);display:flex;min-height:0;overflow:hidden;
177
+ }
178
+ .filmstrip-section{
179
+ display:flex;flex-direction:column;min-width:0;padding:8px 0 8px 14px;
180
+ flex:1;
181
+ }
182
+ .filmstrip-label{
183
+ font-size:9px;font-weight:700;color:var(--faint);letter-spacing:1.2px;
184
+ text-transform:uppercase;margin-bottom:6px;display:flex;align-items:center;gap:8px;
185
+ user-select:none;flex-shrink:0;
186
+ }
187
+ .filmstrip-label .count{
188
+ font-family:'JetBrains Mono',monospace;font-weight:500;color:var(--dim);
189
+ background:var(--panel2);border:1px solid var(--border);border-radius:4px;padding:0 5px;font-size:9px;
190
+ }
191
+ .filmstrip-row{
192
+ display:flex;gap:8px;overflow-x:auto;overflow-y:hidden;flex:1;
193
+ align-items:flex-start;padding-bottom:4px;padding-right:14px;
194
+ }
195
+ .filmstrip-row::-webkit-scrollbar{height:5px}
196
+ .filmstrip-row::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
197
+ .fs-thumb{
198
+ position:relative;flex-shrink:0;width:76px;height:76px;border-radius:8px;overflow:hidden;
199
+ border:2px solid var(--border);cursor:pointer;transition:all .15s;background:var(--panel2);
200
+ animation:thumbIn .25s ease;
201
+ }
202
+ @keyframes thumbIn{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:scale(1)}}
203
+ .fs-thumb:hover{border-color:var(--border2);transform:translateY(-2px)}
204
+ .fs-thumb.selected{border-color:var(--accent);box-shadow:0 0 0 2px rgba(255,69,0,.25)}
205
+ .fs-thumb img{width:100%;height:100%;object-fit:cover}
206
+ .fs-badge{
207
+ position:absolute;bottom:4px;left:4px;background:rgba(0,0,0,.75);color:#fff;
208
+ padding:1px 6px;border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:9px;font-weight:600;
209
+ }
210
+ .fs-remove{
211
+ position:absolute;top:4px;right:4px;width:20px;height:20px;background:rgba(0,0,0,.8);
212
+ color:#fff;border:1px solid rgba(255,255,255,.2);border-radius:50%;cursor:pointer;
213
+ display:none;align-items:center;justify-content:center;font-size:10px;transition:all .15s;line-height:1;
214
+ }
215
+ .fs-thumb:hover .fs-remove{display:flex}
216
+ .fs-remove:hover{background:#ef4444;border-color:#ef4444}
217
+ .fs-add{
218
+ flex-shrink:0;width:76px;height:76px;border-radius:8px;border:2px dashed var(--border2);
219
+ display:flex;flex-direction:column;align-items:center;justify-content:center;
220
+ cursor:pointer;transition:all .2s;background:rgba(255,69,0,.03);gap:3px;
221
+ }
222
+ .fs-add:hover{border-color:var(--accent);background:rgba(255,69,0,.08)}
223
+ .fs-add .add-icon{font-size:22px;color:var(--dim);font-weight:300}
224
+ .fs-add .add-text{font-size:9px;color:var(--dim);font-weight:600;text-transform:uppercase;letter-spacing:.5px}
225
+ .fs-empty{
226
+ flex-shrink:0;display:flex;align-items:center;height:76px;
227
+ color:var(--faint);font-size:11px;font-style:italic;padding-right:12px;
228
+ }
229
+
230
+ /* ══ Inspector ══ */
231
+ .inspector{
232
+ grid-area:inspector;background:var(--panel);border-left:1px solid var(--border);
233
+ display:flex;flex-direction:column;min-height:0;z-index:40;
234
+ }
235
+ .inspector-tabs{
236
+ display:flex;border-bottom:1px solid var(--border);flex-shrink:0;
237
+ }
238
+ .insp-tab{
239
+ flex:1;padding:11px 8px;font-size:11px;font-weight:700;color:var(--dim);
240
+ background:transparent;border:none;border-bottom:2px solid transparent;
241
+ cursor:pointer;font-family:'Inter',sans-serif;text-transform:uppercase;letter-spacing:.8px;
242
+ transition:all .15s;
243
+ }
244
+ .insp-tab:hover:not(.active){color:var(--muted)}
245
+ .insp-tab.active{color:var(--accent2);border-bottom-color:var(--accent)}
246
+ .insp-page{display:none;flex:1;overflow-y:auto;min-height:0;flex-direction:column}
247
+ .insp-page.active{display:flex}
248
+
249
+ .insp-section{border-bottom:1px solid var(--border);padding:14px 18px}
250
+ .insp-section-title{
251
+ font-size:10px;font-weight:700;color:var(--dim);text-transform:uppercase;
252
+ letter-spacing:1px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;
253
+ }
254
+ .char-count{font-size:9px;font-weight:500;color:var(--faint);font-family:'JetBrains Mono',monospace;text-transform:none;letter-spacing:0}
255
+ .modern-textarea{
256
+ width:100%;background:var(--panel2);border:1px solid var(--border);border-radius:8px;
257
+ padding:10px 13px;font-family:'Inter',sans-serif;font-size:13px;color:var(--text);
258
+ resize:vertical;outline:none;min-height:64px;transition:border-color .2s;line-height:1.55;
259
+ }
260
+ .modern-textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(255,69,0,.15)}
261
+ .modern-textarea::placeholder{color:var(--faint)}
262
+ .modern-textarea.error-flash{
263
+ border-color:#ef4444!important;box-shadow:0 0 0 3px rgba(239,68,68,.2)!important;animation:shake .4s ease;
264
+ }
265
+ @keyframes shake{0%,100%{transform:translateX(0)}20%,60%{transform:translateX(-4px)}40%,80%{transform:translateX(4px)}}
266
+
267
+ .lora-native-select{
268
+ width:100%;background:var(--panel2);
269
+ border:1px solid var(--border2);border-radius:8px;
270
+ padding:9px 34px 9px 13px;
271
+ font-family:'Inter',sans-serif;font-size:12px;font-weight:600;color:var(--text);
272
+ outline:none;appearance:none;-webkit-appearance:none;
273
+ background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23FF4500' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
274
+ background-repeat:no-repeat;background-position:right 11px center;
275
+ cursor:pointer;transition:border-color .2s;color-scheme:dark;
276
+ }
277
+ .lora-native-select:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(255,69,0,.15)}
278
+ .lora-native-select option{background:var(--panel);color:var(--text)}
279
+
280
+ .btn-run{
281
+ display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
282
+ background:linear-gradient(135deg,#FF4500,#CC3000);border:none;border-radius:9px;
283
+ padding:12px 24px;cursor:pointer;font-size:14px;font-weight:700;font-family:'Inter',sans-serif;
284
+ color:#fff;transition:all .2s ease;letter-spacing:-.2px;
285
+ box-shadow:0 4px 16px rgba(255,69,0,.3),inset 0 1px 0 rgba(255,255,255,.1);
286
+ }
287
+ .btn-run:hover:not(:disabled){
288
+ background:linear-gradient(135deg,#FF6A20,#FF4500);transform:translateY(-1px);
289
+ box-shadow:0 6px 24px rgba(255,69,0,.45),inset 0 1px 0 rgba(255,255,255,.15);
290
+ }
291
+ .btn-run:active:not(:disabled){transform:translateY(0)}
292
+ .btn-run:disabled{opacity:.55;cursor:not-allowed}
293
+ .btn-cancel{
294
+ display:flex;align-items:center;justify-content:center;gap:6px;width:100%;
295
+ margin-top:8px;background:transparent;border:1px solid var(--border2);border-radius:9px;
296
+ padding:8px 24px;cursor:pointer;font-size:12px;font-weight:600;font-family:'Inter',sans-serif;
297
+ color:var(--muted);transition:all .15s;
298
+ }
299
+ .btn-cancel:hover{border-color:#ef4444;color:#ef4444;background:rgba(239,68,68,.08)}
300
+ .run-hint{
301
+ text-align:center;font-size:10px;color:var(--faint);margin-top:8px;
302
+ font-family:'JetBrains Mono',monospace;
303
+ }
304
+
305
+ .slider-row{display:flex;align-items:center;gap:9px;min-height:26px;margin-bottom:10px}
306
+ .slider-row:last-child{margin-bottom:0}
307
+ .slider-row label{font-size:12px;font-weight:500;color:var(--muted);min-width:64px;flex-shrink:0}
308
+ .slider-row input[type="range"]{
309
+ flex:1;-webkit-appearance:none;appearance:none;height:5px;background:var(--border);
310
+ border-radius:3px;outline:none;min-width:0;
311
+ }
312
+ .slider-row input[type="range"]::-webkit-slider-thumb{
313
+ -webkit-appearance:none;width:14px;height:14px;background:linear-gradient(135deg,#FF4500,#CC3000);
314
+ border-radius:50%;cursor:pointer;box-shadow:0 2px 6px rgba(255,69,0,.4);transition:transform .15s;
315
+ }
316
+ .slider-row input[type="range"]::-webkit-slider-thumb:hover{transform:scale(1.2)}
317
+ .slider-row input[type="range"]::-moz-range-thumb{
318
+ width:14px;height:14px;background:linear-gradient(135deg,#FF4500,#CC3000);
319
+ border-radius:50%;cursor:pointer;border:none;box-shadow:0 2px 6px rgba(255,69,0,.4);
320
+ }
321
+ .slider-val{
322
+ min-width:48px;text-align:right;font-family:'JetBrains Mono',monospace;font-size:11px;
323
+ font-weight:500;padding:2px 7px;background:var(--panel2);border:1px solid var(--border);
324
+ border-radius:5px;color:var(--muted);flex-shrink:0;
325
+ }
326
+
327
+ /* Examples page */
328
+ .examples-list{padding:12px 14px;display:flex;flex-direction:column;gap:10px}
329
+ .example-card{
330
+ background:var(--panel2);border:1px solid var(--border);
331
+ border-radius:10px;overflow:hidden;cursor:pointer;transition:all .2s ease;flex-shrink:0;
332
+ display:flex;align-items:stretch;
333
+ }
334
+ .example-card:hover{border-color:var(--accent);box-shadow:0 4px 14px rgba(255,69,0,.15)}
335
+ .example-card.loading{opacity:.5;pointer-events:none}
336
+ .example-thumb-wrap{width:96px;flex-shrink:0;background:var(--panel);overflow:hidden;display:flex}
337
+ .example-thumb-wrap img{width:100%;height:100%;object-fit:cover}
338
+ .example-thumb-placeholder{
339
+ width:100%;height:100%;display:flex;align-items:center;justify-content:center;
340
+ background:var(--panel);color:var(--border2);font-size:10px;
341
+ }
342
+ .example-meta{padding:6px 10px 2px;display:flex;align-items:center;gap:5px;flex-wrap:wrap}
343
+ .example-lora-badge{
344
+ display:inline-flex;padding:2px 7px;background:rgba(255,69,0,.1);border-radius:4px;
345
+ font-size:9px;font-weight:600;color:var(--accent2);font-family:'JetBrains Mono',monospace;
346
+ white-space:nowrap;border:1px solid rgba(255,69,0,.25);
347
+ }
348
+ .example-body{flex:1;display:flex;flex-direction:column;justify-content:center;min-width:0}
349
+ .example-prompt-text{
350
+ padding:4px 10px 9px;font-size:11px;color:var(--muted);line-height:1.45;
351
+ display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
352
+ }
353
+
354
+ /* ══ Status bar ══ */
355
+ .statusbar{
356
+ grid-area:statusbar;background:var(--panel);border-top:1px solid var(--border);
357
+ display:flex;align-items:center;gap:4px;padding:0 14px;font-size:11px;z-index:50;
358
+ }
359
+ .statusbar .sb-section{
360
+ padding:0 10px;display:flex;align-items:center;font-family:'JetBrains Mono',monospace;
361
+ font-size:11px;color:var(--faint);overflow:hidden;white-space:nowrap;gap:6px;
362
+ }
363
+ .statusbar .sb-right{margin-left:auto;display:flex;align-items:center;gap:10px}
364
+ .sb-pill{
365
+ padding:2px 12px;border-radius:5px;font-weight:600;font-size:10px;
366
+ background:rgba(255,69,0,.1);color:var(--accent2);
367
+ }
368
+ .sb-pill.error{background:rgba(239,68,68,.12);color:#f87171}
369
+ .sb-pill.done{background:rgba(34,197,94,.12);color:#4ade80}
370
+ .sb-link{color:var(--faint);text-decoration:none;font-family:'JetBrains Mono',monospace;font-size:10px}
371
+ .sb-link:hover{color:var(--accent3)}
372
+
373
+ /* ══ Toast ══ */
374
+ .toast-notification{
375
+ position:fixed;top:60px;left:50%;transform:translateX(-50%) translateY(-140%);
376
+ z-index:9999;padding:10px 22px;border-radius:9px;font-family:'Inter',sans-serif;
377
+ font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;
378
+ box-shadow:0 8px 24px rgba(0,0,0,.5);
379
+ transition:transform .35s cubic-bezier(.34,1.56,.64,1),opacity .35s ease;opacity:0;pointer-events:none;
380
+ }
381
+ .toast-notification.visible{transform:translateX(-50%) translateY(0);opacity:1;pointer-events:auto}
382
+ .toast-notification.error{background:linear-gradient(135deg,#dc2626,#b91c1c);color:#fff;border:1px solid rgba(255,255,255,.15)}
383
+ .toast-notification.warning{background:linear-gradient(135deg,#d97706,#b45309);color:#fff;border:1px solid rgba(255,255,255,.15)}
384
+ .toast-notification.info{background:linear-gradient(135deg,#FF4500,#CC3000);color:#fff;border:1px solid rgba(255,255,255,.15)}
385
+ .toast-notification .toast-icon{font-size:15px;line-height:1}
386
+
387
+ /* ══ Lightbox ══ */
388
+ .lightbox{
389
+ position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:10000;
390
+ display:none;align-items:center;justify-content:center;cursor:zoom-out;
391
+ backdrop-filter:blur(6px);animation:fadeIn .2s ease;
392
+ }
393
+ .lightbox.visible{display:flex}
394
+ .lightbox img{max-width:94vw;max-height:94vh;border-radius:6px;box-shadow:0 20px 60px rgba(0,0,0,.8)}
395
+ @keyframes fadeIn{from{opacity:0}to{opacity:1}}
396
+
397
+ /* ══ Drop overlay ══ */
398
+ .drop-overlay{
399
+ position:fixed;inset:0;z-index:9000;background:rgba(8,8,10,.85);
400
+ display:none;align-items:center;justify-content:center;pointer-events:none;
401
+ backdrop-filter:blur(3px);
402
+ }
403
+ .drop-overlay.visible{display:flex}
404
+ .drop-overlay-inner{
405
+ border:3px dashed var(--accent);border-radius:22px;padding:56px 76px;
406
+ font-size:19px;font-weight:700;color:var(--accent2);background:rgba(255,69,0,.06);
407
+ }
408
+
409
+ /* ══ Scrollbars ══ */
410
+ ::-webkit-scrollbar{width:8px;height:8px}
411
+ ::-webkit-scrollbar-track{background:transparent}
412
+ ::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}
413
+ ::-webkit-scrollbar-thumb:hover{background:var(--border2)}
414
+
415
+ /* ══ Touch devices ══ */
416
+ @media (pointer:coarse){
417
+ .fs-remove{display:flex}
418
+ .rail-btn{width:44px;height:44px}
419
+ .rail-btn svg{width:19px;height:19px}
420
+ }
421
+
422
+ /* ══ Responsive ══ */
423
+ @media(max-width:960px){
424
+ html,body{height:auto}
425
+ body{overflow:auto!important}
426
+ .studio{
427
+ display:flex;flex-direction:column;height:auto;min-height:100vh;
428
+ }
429
+ .menubar{
430
+ flex-wrap:wrap;gap:8px;padding:10px 12px;min-height:var(--menubar-h);
431
+ position:sticky;top:0;
432
+ }
433
+ .menubar-title{font-size:13px}
434
+ .menubar-status{display:none}
435
+ .menubar-spacer{flex:1}
436
+ .gh-btn{padding:6px 10px}
437
+ .gh-btn span{display:none}
438
+ .rail{
439
+ flex-direction:row;justify-content:flex-start;flex-wrap:nowrap;
440
+ overflow-x:auto;overflow-y:hidden;border-right:none;
441
+ border-bottom:1px solid var(--border);padding:6px 10px;gap:6px;
442
+ }
443
+ .rail-sep{width:1px;height:26px;margin:0 4px;flex-shrink:0}
444
+ .rail-label{display:none}
445
+ .rail-btn{flex-shrink:0}
446
+ .workspace{min-height:0}
447
+ .canvas-head{flex-wrap:wrap;gap:8px;padding:8px 12px}
448
+ .canvas-meta{flex-basis:100%;order:3;font-size:10px}
449
+ .canvas-stage{min-height:42vh}
450
+ .canvas-stage img.modern-out-img{max-width:calc(100% - 20px);max-height:52vh}
451
+ .canvas-placeholder .cp-sub{font-size:11px;max-width:280px}
452
+ .filmstrip{flex-direction:column;height:auto;max-height:none}
453
+ .filmstrip-section{padding:8px 0 8px 12px}
454
+ .fs-thumb{width:68px;height:68px}
455
+ .fs-add{width:68px;height:68px}
456
+ .fs-empty{height:68px}
457
+ .inspector{border-left:none;border-top:1px solid var(--border)}
458
+ .inspector-tabs{position:sticky;top:0;background:var(--panel);z-index:30}
459
+ .insp-tab{padding:13px 8px;font-size:12px}
460
+ .insp-page{overflow-y:visible}
461
+ .insp-section{padding:14px 16px}
462
+ .modern-textarea{font-size:16px}
463
+ .btn-run{padding:14px 24px;font-size:15px}
464
+ .statusbar{flex-wrap:wrap;height:auto;min-height:var(--statusbar-h);padding:4px 10px;gap:2px}
465
+ .sb-link{display:none}
466
+ .toast-notification{max-width:calc(100vw - 32px);font-size:12px;padding:10px 16px}
467
+ .drop-overlay-inner{padding:32px 28px;font-size:15px;border-radius:16px;margin:0 16px}
468
+ .example-card{flex-direction:column}
469
+ .example-thumb-wrap{width:100%;height:96px}
470
+ }
471
+
472
+ @media(max-width:400px){
473
+ .menubar-badge.fast{display:none}
474
+ .seg-btn{padding:4px 12px}
475
+ .canvas-stage{min-height:36vh}
476
+ }
477
+ </style>
478
+ </head>
479
+ <body>
480
+ <div class="studio">
481
+
482
+ <!-- ══ Menu bar ══ -->
483
+ <div class="menubar">
484
+ <div class="menubar-logo">
485
+ <svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg>
486
+ </div>
487
+ <div class="menubar-title">Qwen3.8 Studio <span>/ Object Detection</span></div>
488
+ <span class="menubar-badge">27B</span>
489
+ <span class="menubar-badge fast">VISION</span>
490
+ <div class="menubar-spacer"></div>
491
+ <div class="menubar-status"><span class="dot" id="conn-dot"></span><span id="conn-text">connecting…</span></div>
492
+ <a href="https://github.com/PRITHIVSAKTHIUR/Qwen3.8-27B-Object-Detection"
493
+ target="_blank" rel="noopener" class="gh-btn">
494
+ <svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
495
+ <span>GitHub</span>
496
+ </a>
497
+ </div>
498
+
499
+ <!-- ══ Left icon rail ══ -->
500
+ <div class="rail">
501
+ <div class="rail-label">Input</div>
502
+ <button class="rail-btn" id="tb-upload" title="Upload image">
503
+ <svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
504
+ </button>
505
+ <button class="rail-btn" id="tb-remove" title="Remove image" disabled>
506
+ <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
507
+ </button>
508
+ <button class="rail-btn" id="tb-clear" title="Clear image" disabled>
509
+ <svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>
510
+ </button>
511
+ <div class="rail-sep"></div>
512
+ <div class="rail-label">Result</div>
513
+ <button class="rail-btn" id="dl-btn-output" title="Download result" disabled>
514
+ <svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
515
+ </button>
516
+ <button class="rail-btn" id="zoom-btn" title="Zoom result" disabled>
517
+ <svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
518
+ </button>
519
+ </div>
520
+
521
+ <!-- ══ Workspace ══ -->
522
+ <div class="workspace">
523
+ <div class="canvas-head">
524
+ <div class="seg-control">
525
+ <button class="seg-btn active" id="seg-result">Result</button>
526
+ <button class="seg-btn" id="seg-input">Input</button>
527
+ </div>
528
+ <div class="canvas-meta" id="canvas-meta">No image loaded</div>
529
+ </div>
530
+
531
+ <div class="canvas-stage" id="output-image-container">
532
+ <div class="modern-loader" id="output-loader">
533
+ <div class="loader-spinner"></div>
534
+ <div class="loader-text" id="loader-text">Running inference&hellip;</div>
535
+ <div class="loader-bar-track"><div class="loader-bar-fill" id="loader-bar-fill"></div></div>
536
+ </div>
537
+
538
+ <div class="canvas-placeholder" id="output-placeholder">
539
+ <svg viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
540
+ <rect x="8" y="14" width="64" height="52" rx="6" fill="none" stroke="#3f2820" stroke-width="2" stroke-dasharray="4 3"/>
541
+ <polygon points="12,62 30,40 42,50 54,34 68,62" fill="rgba(255,69,0,0.1)" stroke="#3f2820" stroke-width="1.5"/>
542
+ <circle cx="28" cy="30" r="6" fill="rgba(255,69,0,0.12)" stroke="#3f2820" stroke-width="1.5"/>
543
+ </svg>
544
+ <div class="cp-title">Canvas is empty</div>
545
+ <div class="cp-sub">
546
+ Drop an image anywhere, paste with <kbd>⌘/Ctrl+V</kbd>, or use the rail to upload.
547
+ Then write an instruction and press <kbd>⌘/Ctrl</kbd>+<kbd>↵</kbd>.
548
+ </div>
549
+ </div>
550
+ </div>
551
+
552
+ <!-- Filmstrip -->
553
+ <div class="filmstrip">
554
+ <div class="filmstrip-section inputs">
555
+ <div class="filmstrip-label">Input <span class="count" id="tb-image-count">0</span></div>
556
+ <div class="filmstrip-row" id="image-gallery-grid"></div>
557
+ </div>
558
+ </div>
559
+ </div>
560
+
561
+ <!-- ══ Inspector ══ -->
562
+ <div class="inspector">
563
+ <div class="inspector-tabs">
564
+ <button class="insp-tab active" id="tab-edit">Inference</button>
565
+ <button class="insp-tab" id="tab-examples">Examples</button>
566
+ </div>
567
+
568
+ <!-- Edit page -->
569
+ <div class="insp-page active" id="page-edit">
570
+ <div class="insp-section">
571
+ <div class="insp-section-title"><span>Instruction</span><span class="char-count" id="char-count">0</span></div>
572
+ <textarea id="custom-prompt-input" class="modern-textarea" rows="3"
573
+ placeholder="e.g., Detect all cars, point to the tip of the pen…"></textarea>
574
+ </div>
575
+
576
+ <div class="insp-section">
577
+ <div class="insp-section-title"><span>Detection Mode</span></div>
578
+ <select id="custom-mode-select" class="lora-native-select">
579
+ <option value="Detect">Object Detection</option>
580
+ <option value="Point">Point Localization</option>
581
+ <option value="Spatial">Spatial Guidance</option>
582
+ </select>
583
+ </div>
584
+
585
+ <div class="insp-section">
586
+ <button id="custom-run-btn" class="btn-run">
587
+ <span id="run-btn-label">Run Inference</span>
588
+ </button>
589
+ <button id="custom-cancel-btn" class="btn-cancel" style="display:none;">Cancel</button>
590
+ <div class="run-hint">⌘/Ctrl + Enter</div>
591
+ </div>
592
+
593
+ <div class="insp-section">
594
+ <div class="insp-section-title"><span>Advanced</span></div>
595
+ <div class="slider-row">
596
+ <label>Radius</label>
597
+ <input type="range" id="custom-radius" min="2" max="20" step="1" value="6">
598
+ <span class="slider-val" id="custom-radius-val">6</span>
599
+ </div>
600
+ <div class="slider-row">
601
+ <label>Thickness</label>
602
+ <input type="range" id="custom-thickness" min="1" max="8" step="1" value="2">
603
+ <span class="slider-val" id="custom-thickness-val">2</span>
604
+ </div>
605
+ <div class="slider-row">
606
+ <label>Text Scale</label>
607
+ <input type="range" id="custom-text-scale" min="0.2" max="1.5" step="0.05" value="0.5">
608
+ <span class="slider-val" id="custom-text-scale-val">0.5</span>
609
+ </div>
610
+ </div>
611
+
612
+ <div class="insp-section" style="flex:1; overflow-y:auto;">
613
+ <div class="insp-section-title"><span>Result Data</span></div>
614
+ <textarea id="text-output" class="modern-textarea" rows="8" placeholder="JSON/Summary output will appear here..." readonly style="resize:none; height:100%; font-family: 'JetBrains Mono', monospace; font-size: 11px; background:#08080a;"></textarea>
615
+ </div>
616
+ </div>
617
+
618
+ <!-- Examples page -->
619
+ <div class="insp-page" id="page-examples">
620
+ <div class="examples-list" id="examples-scroll"></div>
621
+ </div>
622
+ </div>
623
+
624
+ <!-- ══ Status bar ══ -->
625
+ <div class="statusbar">
626
+ <div class="sb-section" id="sb-image-count">No input</div>
627
+ <div class="sb-right">
628
+ <a class="sb-link" href="https://huggingface.co/Qwen/Qwen3.8-27B" target="_blank" rel="noopener">Qwen3.8-27B</a>
629
+ <span class="sb-pill" id="sb-status">Ready</span>
630
+ </div>
631
+ </div>
632
+
633
+ </div>
634
+
635
+ <input id="custom-file-input" type="file" accept="image/*" style="display:none;" />
636
+
637
+ <!-- Lightbox -->
638
+ <div class="lightbox" id="lightbox"><img id="lightbox-img" alt="zoom"></div>
639
+
640
+ <!-- Global drop overlay -->
641
+ <div class="drop-overlay" id="drop-overlay"><div class="drop-overlay-inner">Drop image to upload</div></div>
642
+
643
+ <script type="module">
644
+ import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
645
+
646
+ /* ── DOM refs ── */
647
+ const galleryGrid = document.getElementById('image-gallery-grid');
648
+ const fileInput = document.getElementById('custom-file-input');
649
+ const btnUpload = document.getElementById('tb-upload');
650
+ const btnRemove = document.getElementById('tb-remove');
651
+ const btnClear = document.getElementById('tb-clear');
652
+ const promptInput = document.getElementById('custom-prompt-input');
653
+ const charCount = document.getElementById('char-count');
654
+ const modeSelect = document.getElementById('custom-mode-select');
655
+ const runBtn = document.getElementById('custom-run-btn');
656
+ const runBtnLabel = document.getElementById('run-btn-label');
657
+ const cancelBtn = document.getElementById('custom-cancel-btn');
658
+ const imgCountTb = document.getElementById('tb-image-count');
659
+ const imgCountSb = document.getElementById('sb-image-count');
660
+ const sbStatus = document.getElementById('sb-status');
661
+ const loader = document.getElementById('output-loader');
662
+ const loaderText = document.getElementById('loader-text');
663
+ const loaderFill = document.getElementById('loader-bar-fill');
664
+ const outBody = document.getElementById('output-image-container');
665
+ const outPh = document.getElementById('output-placeholder');
666
+ const dlBtn = document.getElementById('dl-btn-output');
667
+ const zoomBtn = document.getElementById('zoom-btn');
668
+ const textOutput = document.getElementById('text-output');
669
+ const radiusSlider = document.getElementById('custom-radius');
670
+ const radiusVal = document.getElementById('custom-radius-val');
671
+ const thicknessSlider = document.getElementById('custom-thickness');
672
+ const thicknessVal = document.getElementById('custom-thickness-val');
673
+ const textScaleSlider = document.getElementById('custom-text-scale');
674
+ const textScaleVal = document.getElementById('custom-text-scale-val');
675
+ const lightbox = document.getElementById('lightbox');
676
+ const lightboxImg = document.getElementById('lightbox-img');
677
+ const dropOverlay = document.getElementById('drop-overlay');
678
+ const canvasMeta = document.getElementById('canvas-meta');
679
+ const segResult = document.getElementById('seg-result');
680
+ const segInput = document.getElementById('seg-input');
681
+ const connDot = document.getElementById('conn-dot');
682
+ const connText = document.getElementById('conn-text');
683
+
684
+ /* ── State ── */
685
+ let currentImage = null; // {b64, name}
686
+ let toastTimer = null;
687
+ let running = false;
688
+ let currentJob = null;
689
+ let currentResult = null; // {b64}
690
+ let viewMode = 'result'; // 'result' | 'input'
691
+
692
+ /* ── Toast ── */
693
+ function showToast(message, type) {
694
+ let toast = document.getElementById('app-toast');
695
+ if (!toast) {
696
+ toast = document.createElement('div');
697
+ toast.id = 'app-toast';
698
+ toast.className = 'toast-notification';
699
+ toast.innerHTML = '<span class="toast-icon"></span><span class="toast-text"></span>';
700
+ document.body.appendChild(toast);
701
+ }
702
+ const icon = toast.querySelector('.toast-icon');
703
+ const text = toast.querySelector('.toast-text');
704
+ toast.className = 'toast-notification ' + (type || 'error');
705
+ icon.textContent = type === 'warning' ? '⚠' : type === 'info' ? 'ℹ' : '✗';
706
+ text.textContent = message;
707
+ if (toastTimer) clearTimeout(toastTimer);
708
+ void toast.offsetWidth;
709
+ toast.classList.add('visible');
710
+ toastTimer = setTimeout(() => toast.classList.remove('visible'), 3500);
711
+ }
712
+
713
+ function flashPromptError() {
714
+ promptInput.classList.add('error-flash');
715
+ promptInput.focus();
716
+ setTimeout(() => promptInput.classList.remove('error-flash'), 800);
717
+ }
718
+
719
+ function setStatus(text, cls) {
720
+ sbStatus.textContent = text;
721
+ sbStatus.className = 'sb-pill' + (cls ? ' ' + cls : '');
722
+ }
723
+
724
+ /* ── View mode ── */
725
+ function setViewMode(mode) {
726
+ viewMode = mode;
727
+ segResult.classList.toggle('active', mode === 'result');
728
+ segInput.classList.toggle('active', mode === 'input');
729
+ renderCanvas();
730
+ }
731
+ segResult.addEventListener('click', () => setViewMode('result'));
732
+ segInput.addEventListener('click', () => setViewMode('input'));
733
+
734
+ function renderCanvas() {
735
+ outBody.querySelectorAll('img.modern-out-img').forEach(e => e.remove());
736
+
737
+ const showResult = viewMode === 'result' && currentResult;
738
+ const showInput = viewMode === 'input' && currentImage;
739
+
740
+ if (showResult || showInput) {
741
+ outPh.style.display = 'none';
742
+
743
+ const img = document.createElement('img');
744
+ img.className = 'modern-out-img';
745
+ img.addEventListener('click', () => {
746
+ lightboxImg.src = img.src; lightbox.classList.add('visible');
747
+ });
748
+ outBody.appendChild(img);
749
+
750
+ if (showResult) {
751
+ img.src = currentResult.b64;
752
+ canvasMeta.textContent = 'result';
753
+ } else {
754
+ img.src = currentImage.b64;
755
+ canvasMeta.textContent = 'input · ' + (currentImage.name || 'image');
756
+ }
757
+ } else {
758
+ outPh.style.display = '';
759
+ canvasMeta.textContent = currentImage
760
+ ? 'input ready — run an inference'
761
+ : 'No image loaded';
762
+ }
763
+ updateRailState();
764
+ }
765
+
766
+ function updateRailState() {
767
+ const hasResult = !!currentResult;
768
+ dlBtn.disabled = !hasResult;
769
+ zoomBtn.disabled = !hasResult && !currentImage;
770
+ btnRemove.disabled = !currentImage;
771
+ btnClear.disabled = !currentImage;
772
+ }
773
+
774
+ /* ── Inputs filmstrip ── */
775
+ function updateCounts() {
776
+ const n = currentImage ? 1 : 0;
777
+ imgCountTb.textContent = n;
778
+ imgCountSb.textContent = n > 0 ? '1 input ready' : 'No input';
779
+ }
780
+
781
+ function setImage(b64, name) {
782
+ currentImage = { b64, name: name || 'image' };
783
+ renderFilmstrip();
784
+ updateCounts();
785
+ if (!currentResult || viewMode === 'input') renderCanvas();
786
+ else setViewMode('input');
787
+ }
788
+
789
+ function removeImage() {
790
+ currentImage = null;
791
+ renderFilmstrip();
792
+ updateCounts();
793
+ renderCanvas();
794
+ }
795
+
796
+ function clearAll() {
797
+ currentImage = null;
798
+ renderFilmstrip();
799
+ updateCounts();
800
+ renderCanvas();
801
+ }
802
+
803
+ function renderFilmstrip() {
804
+ galleryGrid.innerHTML = '';
805
+ if (!currentImage) {
806
+ const empty = document.createElement('div');
807
+ empty.className = 'fs-empty';
808
+ empty.textContent = 'Drop or paste an image…';
809
+ galleryGrid.appendChild(empty);
810
+ } else {
811
+ const t = document.createElement('div');
812
+ t.className = 'fs-thumb selected';
813
+ t.innerHTML = '<img src="' + currentImage.b64 + '" alt="">' +
814
+ '<span class="fs-badge">input</span>' +
815
+ '<button class="fs-remove">✕</button>';
816
+ t.addEventListener('click', (e) => {
817
+ if (e.target.closest('.fs-remove')) return;
818
+ setViewMode('input');
819
+ });
820
+ t.querySelector('.fs-remove').addEventListener('click', (e) => {
821
+ e.stopPropagation(); removeImage();
822
+ });
823
+ galleryGrid.appendChild(t);
824
+ }
825
+ const add = document.createElement('div');
826
+ add.className = 'fs-add';
827
+ add.innerHTML = '<span class="add-icon">+</span><span class="add-text">' + (currentImage ? 'Replace' : 'Add') + '</span>';
828
+ add.addEventListener('click', () => fileInput.click());
829
+ galleryGrid.appendChild(add);
830
+ updateRailState();
831
+ }
832
+
833
+ function processFiles(files) {
834
+ const file = files && files[0];
835
+ if (!file || !file.type.startsWith('image/')) return 0;
836
+ const reader = new FileReader();
837
+ reader.onload = (e) => setImage(e.target.result, file.name);
838
+ reader.readAsDataURL(file);
839
+ return 1;
840
+ }
841
+
842
+ fileInput.addEventListener('change', (e) => { processFiles(e.target.files); e.target.value = ''; });
843
+ btnUpload.addEventListener('click', () => fileInput.click());
844
+ btnRemove.addEventListener('click', removeImage);
845
+ btnClear.addEventListener('click', clearAll);
846
+
847
+ /* ── Drop anywhere ── */
848
+ let dragDepth = 0;
849
+ window.addEventListener('dragenter', (e) => {
850
+ if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
851
+ e.preventDefault();
852
+ dragDepth++;
853
+ dropOverlay.classList.add('visible');
854
+ });
855
+ window.addEventListener('dragleave', (e) => {
856
+ if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
857
+ dragDepth = Math.max(0, dragDepth - 1);
858
+ if (dragDepth === 0) dropOverlay.classList.remove('visible');
859
+ });
860
+ window.addEventListener('dragover', (e) => { e.preventDefault(); });
861
+ window.addEventListener('drop', (e) => {
862
+ e.preventDefault();
863
+ dragDepth = 0;
864
+ dropOverlay.classList.remove('visible');
865
+ if (e.dataTransfer.files.length) {
866
+ const n = processFiles(e.dataTransfer.files);
867
+ if (n > 0) showToast('Image loaded', 'info');
868
+ }
869
+ });
870
+
871
+ /* ── Paste ── */
872
+ document.addEventListener('paste', (e) => {
873
+ if (e.target === promptInput) return;
874
+ const items = e.clipboardData && e.clipboardData.items;
875
+ if (!items) return;
876
+ for (const item of items) {
877
+ if (item.kind === 'file' && item.type.startsWith('image/')) {
878
+ const f = item.getAsFile();
879
+ if (f) {
880
+ e.preventDefault();
881
+ processFiles([f]);
882
+ showToast('Pasted image', 'info');
883
+ return;
884
+ }
885
+ }
886
+ }
887
+ });
888
+
889
+ /* ── Inspector tabs ── */
890
+ const tabEdit = document.getElementById('tab-edit');
891
+ const tabExamples = document.getElementById('tab-examples');
892
+ const pageEdit = document.getElementById('page-edit');
893
+ const pageExamples = document.getElementById('page-examples');
894
+ tabEdit.addEventListener('click', () => {
895
+ tabEdit.classList.add('active'); tabExamples.classList.remove('active');
896
+ pageEdit.classList.add('active'); pageExamples.classList.remove('active');
897
+ });
898
+ tabExamples.addEventListener('click', () => {
899
+ tabExamples.classList.add('active'); tabEdit.classList.remove('active');
900
+ pageExamples.classList.add('active'); pageEdit.classList.remove('active');
901
+ });
902
+
903
+ /* ── Sliders ── */
904
+ function bindSlider(id, suffix='') {
905
+ const slider = document.getElementById(id);
906
+ const valSpan = document.getElementById(id + '-val');
907
+ slider.addEventListener('input', () => { valSpan.textContent = slider.value + suffix; });
908
+ }
909
+ bindSlider('custom-radius');
910
+ bindSlider('custom-thickness');
911
+ bindSlider('custom-text-scale');
912
+
913
+ function updateCharCount() { charCount.textContent = promptInput.value.length; }
914
+ promptInput.addEventListener('input', updateCharCount);
915
+ updateCharCount();
916
+
917
+ /* ── Loader ── */
918
+ function showLoader(text) {
919
+ loaderText.textContent = text || 'Running inference…';
920
+ loaderFill.classList.remove('determinate');
921
+ loaderFill.style.width = '100%';
922
+ loader.classList.add('active');
923
+ setStatus('Processing…');
924
+ }
925
+ function setLoaderProgress(text, frac) {
926
+ loaderText.textContent = text;
927
+ if (frac != null && frac >= 0 && frac <= 1) {
928
+ loaderFill.classList.add('determinate');
929
+ loaderFill.style.width = Math.max(4, Math.round(frac * 100)) + '%';
930
+ }
931
+ }
932
+ function hideLoader(statusText, cls) {
933
+ loader.classList.remove('active');
934
+ setStatus(statusText || 'Done', cls || 'done');
935
+ }
936
+
937
+ /* ── Lightbox ── */
938
+ lightbox.addEventListener('click', () => lightbox.classList.remove('visible'));
939
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') lightbox.classList.remove('visible'); });
940
+ zoomBtn.addEventListener('click', () => {
941
+ const src = (viewMode === 'result' && currentResult) ? currentResult.b64
942
+ : (currentImage ? currentImage.b64 : null);
943
+ if (src) { lightboxImg.src = src; lightbox.classList.add('visible'); }
944
+ });
945
+
946
+ /* ── Download ── */
947
+ dlBtn.addEventListener('click', () => {
948
+ if (currentResult && currentResult.b64) {
949
+ const a = document.createElement('a');
950
+ a.href = currentResult.b64;
951
+ a.download = 'qwen_inference_output.png';
952
+ document.body.appendChild(a); a.click(); document.body.removeChild(a);
953
+ }
954
+ });
955
+
956
+ /* ── Backend connection ── */
957
+ let client = null;
958
+ try {
959
+ client = await Client.connect(window.location.origin);
960
+ setStatus('Ready');
961
+ connDot.classList.remove('off');
962
+ connText.textContent = 'connected';
963
+ } catch (e) {
964
+ console.error('Failed to connect to Gradio backend:', e);
965
+ setStatus('Offline', 'error');
966
+ connDot.classList.add('off');
967
+ connText.textContent = 'offline';
968
+ showToast('Could not connect to the backend API', 'error');
969
+ }
970
+
971
+ /* ── Config: examples ── */
972
+ function renderConfig(cfg) {
973
+ const list = document.getElementById('examples-scroll');
974
+ list.innerHTML = '';
975
+ cfg.examples.forEach(ex => {
976
+ const card = document.createElement('div');
977
+ card.className = 'example-card';
978
+ const thumbHtml = ex.thumb
979
+ ? '<img src="' + ex.thumb + '" alt="">'
980
+ : '<div class="example-thumb-placeholder">Preview</div>';
981
+ const promptShort = ex.prompt.length > 90 ? ex.prompt.slice(0, 90) + '…' : ex.prompt;
982
+ card.innerHTML =
983
+ '<div class="example-thumb-wrap">' + thumbHtml + '</div>'
984
+ + '<div class="example-body">'
985
+ + '<div class="example-meta"><span class="example-lora-badge">' + ex.mode + '</span></div>'
986
+ + '<div class="example-prompt-text"></div>'
987
+ + '</div>';
988
+ card.querySelector('.example-prompt-text').textContent = promptShort;
989
+ card.addEventListener('click', () => loadExample(card, ex.idx));
990
+ list.appendChild(card);
991
+ });
992
+ }
993
+
994
+ async function loadExample(card, idx) {
995
+ if (!client) { showToast('Backend not connected', 'error'); return; }
996
+ document.querySelectorAll('.example-card.loading').forEach(c => c.classList.remove('loading'));
997
+ card.classList.add('loading');
998
+ showToast('Loading example…', 'info');
999
+ try {
1000
+ const result = await client.predict('/load_example', { idx: idx });
1001
+ const data = result.data[0];
1002
+ if (data && data.status === 'ok' && data.image) {
1003
+ if (data.prompt) { promptInput.value = data.prompt; updateCharCount(); }
1004
+ if (data.mode) {
1005
+ modeSelect.value = data.mode;
1006
+ }
1007
+ setImage(data.image, data.name || 'example.jpg');
1008
+ tabEdit.click();
1009
+ showToast('Example loaded', 'info');
1010
+ } else {
1011
+ showToast('Could not load example image', 'error');
1012
+ }
1013
+ } catch (e) {
1014
+ console.error('Example load error:', e);
1015
+ showToast('Could not load example image', 'error');
1016
+ } finally {
1017
+ card.classList.remove('loading');
1018
+ }
1019
+ }
1020
+
1021
+ try {
1022
+ const cfg = await fetch('api/config').then(r => r.json());
1023
+ renderConfig(cfg);
1024
+ } catch (e) {
1025
+ console.error('Failed to load config:', e);
1026
+ }
1027
+
1028
+ /* ── Run ── */
1029
+ function validateBeforeRun() {
1030
+ const promptVal = promptInput.value.trim();
1031
+ const hasImage = !!currentImage;
1032
+ if (!hasImage && !promptVal) { showToast('Please upload an image and enter a prompt', 'error'); flashPromptError(); return false; }
1033
+ if (!hasImage) { showToast('Please upload an image', 'error'); return false; }
1034
+ if (!promptVal) { showToast('Please enter a prompt', 'warning'); flashPromptError(); return false; }
1035
+ return true;
1036
+ }
1037
+
1038
+ function setRunningUI(on) {
1039
+ running = on;
1040
+ runBtn.disabled = on;
1041
+ runBtnLabel.textContent = on ? 'Running…' : 'Run Inference';
1042
+ cancelBtn.style.display = on ? 'flex' : 'none';
1043
+ }
1044
+
1045
+ async function runEdit() {
1046
+ if (running) return;
1047
+ if (!client) { showToast('Backend not connected', 'error'); return; }
1048
+ if (!validateBeforeRun()) return;
1049
+
1050
+ setRunningUI(true);
1051
+ setViewMode('result');
1052
+ showLoader('Submitting to queue…');
1053
+ textOutput.value = '';
1054
+
1055
+ const usedPrompt = promptInput.value;
1056
+
1057
+ const payload = {
1058
+ image_b64: currentImage ? currentImage.b64 : '',
1059
+ mode: modeSelect.value,
1060
+ prompt: usedPrompt,
1061
+ point_radius: parseInt(radiusSlider.value) || 6,
1062
+ box_thickness: parseInt(thicknessSlider.value) || 2,
1063
+ text_scale: parseFloat(textScaleSlider.value) || 0.5
1064
+ };
1065
+
1066
+ try {
1067
+ currentJob = client.submit('/run_inference', payload);
1068
+ for await (const msg of currentJob) {
1069
+ if (msg.type === 'status') {
1070
+ if (msg.status === 'pending') {
1071
+ const pos = (msg.position != null && msg.position >= 0)
1072
+ ? 'In queue — position ' + (msg.position + 1) + (msg.queue_size ? ' of ' + msg.queue_size : '')
1073
+ : 'Waiting in queue…';
1074
+ setLoaderProgress(pos, null);
1075
+ setStatus('Queued');
1076
+ } else if (msg.status === 'generating') {
1077
+ setStatus('Processing…');
1078
+ const pd = msg.progress_data;
1079
+ if (pd && pd.length > 0) {
1080
+ const p = pd[pd.length - 1];
1081
+ if (p.index != null && p.length) {
1082
+ const pct = Math.round((p.index / p.length) * 100);
1083
+ setLoaderProgress('Generating… ' + p.index + '/' + p.length + ' (' + pct + '%)', p.index / p.length);
1084
+ } else {
1085
+ setLoaderProgress('Generating…', null);
1086
+ }
1087
+ } else {
1088
+ setLoaderProgress('Running inference…', null);
1089
+ }
1090
+ } else if (msg.status === 'error') {
1091
+ throw new Error(msg.message || 'Generation failed');
1092
+ }
1093
+ } else if (msg.type === 'data') {
1094
+ const out = msg.data && msg.data[0];
1095
+ if (out && out.image) {
1096
+ currentResult = { b64: out.image };
1097
+ if (out.text) {
1098
+ textOutput.value = out.text;
1099
+ }
1100
+ hideLoader('Done', 'done');
1101
+ showToast('Inference completed successfully', 'info');
1102
+ renderCanvas();
1103
+ } else {
1104
+ hideLoader('Done', 'done');
1105
+ }
1106
+ }
1107
+ }
1108
+ } catch (e) {
1109
+ console.error('Edit error:', e);
1110
+ hideLoader('Error', 'error');
1111
+ const msg = (e && e.message) ? e.message : 'Generation failed';
1112
+ showToast(msg.length > 120 ? msg.slice(0, 120) + '…' : msg, 'error');
1113
+ } finally {
1114
+ setRunningUI(false);
1115
+ currentJob = null;
1116
+ }
1117
+ }
1118
+
1119
+ runBtn.addEventListener('click', runEdit);
1120
+
1121
+ cancelBtn.addEventListener('click', async () => {
1122
+ if (currentJob) {
1123
+ try { await currentJob.cancel(); } catch (e) { console.warn('Cancel error:', e); }
1124
+ currentJob = null;
1125
+ }
1126
+ setRunningUI(false);
1127
+ hideLoader('Cancelled');
1128
+ showToast('Generation cancelled', 'warning');
1129
+ });
1130
+
1131
+ document.addEventListener('keydown', (e) => {
1132
+ if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
1133
+ e.preventDefault();
1134
+ runEdit();
1135
+ }
1136
+ });
1137
+
1138
+ renderFilmstrip();
1139
+ updateCounts();
1140
+ renderCanvas();
1141
+ </script>
1142
+ </body>
1143
+ </html>