Spaces:
Runtime error
Runtime error
stanley
commited on
Commit
·
e27bb44
1
Parent(s):
0589bd5
temp UI/UX update
Browse files- app.py +5 -2
- index.html +359 -63
app.py
CHANGED
@@ -1233,9 +1233,12 @@ except:
|
|
1233 |
pass
|
1234 |
|
1235 |
if RUN_IN_SPACE:
|
1236 |
-
demo.launch(
|
1237 |
elif args.debug:
|
1238 |
launch_kwargs["server_name"] = "0.0.0.0"
|
1239 |
demo.queue().launch(**launch_kwargs)
|
|
|
|
|
1240 |
else:
|
1241 |
-
demo.queue().launch(**launch_kwargs)
|
|
|
|
1233 |
pass
|
1234 |
|
1235 |
if RUN_IN_SPACE:
|
1236 |
+
demo.launch()
|
1237 |
elif args.debug:
|
1238 |
launch_kwargs["server_name"] = "0.0.0.0"
|
1239 |
demo.queue().launch(**launch_kwargs)
|
1240 |
+
# demo.queue().launch(share=True)
|
1241 |
+
|
1242 |
else:
|
1243 |
+
demo.queue().launch(**launch_kwargs)
|
1244 |
+
# demo.queue().launch(share=True)
|
index.html
CHANGED
@@ -1,15 +1,18 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
-
<title>
|
5 |
<meta charset="utf-8">
|
6 |
|
7 |
-
|
8 |
-
<
|
9 |
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/lkwq007/stablediffusion-infinity@v0.1.2/js/w2ui.min.js"></script>
|
10 |
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
|
11 |
-
<script src="https://cdn.jsdelivr.net/gh/
|
12 |
-
<script defer src="https://cdn.jsdelivr.net/gh/
|
|
|
|
|
|
|
|
|
13 |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
|
14 |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
|
15 |
|
@@ -42,11 +45,12 @@ html, body {
|
|
42 |
}
|
43 |
.control {
|
44 |
display: none;
|
|
|
45 |
}
|
46 |
#outer_container {
|
47 |
width: 100%;
|
48 |
height: 100vh;
|
49 |
-
|
50 |
}
|
51 |
|
52 |
#hamburger-menu {
|
@@ -135,11 +139,6 @@ html, body {
|
|
135 |
background-position: 0% 50%;
|
136 |
}
|
137 |
}
|
138 |
-
#toolbar {
|
139 |
-
display: none;
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
|
144 |
.generate-button {
|
145 |
background-color: #f1f1f1;
|
@@ -155,6 +154,104 @@ html, body {
|
|
155 |
border-radius: 4px;
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
|
160 |
|
@@ -162,55 +259,57 @@ html, body {
|
|
162 |
|
163 |
</head>
|
164 |
<body>
|
165 |
-
<div>
|
166 |
-
|
167 |
-
<button type="button" class="control" id="export">Export</button>
|
168 |
-
<button type="button" class="control" id="undo">Undo</button>
|
169 |
-
<button type="button" class="control" id="commit">Commit</button>
|
170 |
-
<button type="button" class="control" id="transfer">Transfer</button>
|
171 |
-
<button type="button" class="control" id="upload">Upload</button>
|
172 |
-
<button type="button" class="control" id="draw">Draw</button>
|
173 |
-
<input type="text" id="mode" value="selection" class="control">
|
174 |
-
<input type="text" id="setup" value="0" class="control">
|
175 |
-
<input type="text" id="upload_content" value="0" class="control">
|
176 |
-
<textarea rows="1" id="selbuffer" name="selbuffer" class="control"></textarea>
|
177 |
-
<fieldset class="control">
|
178 |
<div>
|
179 |
-
|
180 |
-
|
181 |
</div>
|
182 |
-
<
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
</div>
|
186 |
-
<div>
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
</div>
|
190 |
-
|
191 |
-
|
192 |
-
<div
|
193 |
-
<i class="fa-solid fa-bars"></i>
|
194 |
-
</div>
|
195 |
-
<button type="button"id="outpaint">Outpaint</button>
|
196 |
-
<div id = "outer_container">
|
197 |
-
<div style="position: relative;">
|
198 |
<div id="toolbar" style></div>
|
199 |
-
|
200 |
-
<div id
|
201 |
-
|
202 |
-
|
203 |
-
<canvas id = "canvas2"></canvas>
|
204 |
-
<canvas id = "canvas3"></canvas>
|
205 |
-
<canvas id = "canvas4"></canvas>
|
206 |
-
<div id="overlay_container" style="pointer-events: none">
|
207 |
-
<canvas id = "overlay_canvas" width="1" height="1"></canvas>
|
208 |
-
</div>
|
209 |
-
</div>
|
210 |
-
<input type="file" name="file" id="upload_file" accept="image/*" hidden>
|
211 |
-
<input type="file" name="state" id="upload_state" accept=".sdinf" hidden>
|
212 |
|
213 |
-
</div>
|
214 |
</div>
|
215 |
|
216 |
|
@@ -218,7 +317,11 @@ html, body {
|
|
218 |
|
219 |
|
220 |
|
221 |
-
|
|
|
|
|
|
|
|
|
222 |
|
223 |
function toggleToolbar() {
|
224 |
console.log("Hamburger menu button clicked");
|
@@ -288,7 +391,7 @@ html, body {
|
|
288 |
|
289 |
const uploadTask = storageRef.put(blob);
|
290 |
|
291 |
-
alert("sucessful upload to
|
292 |
// Replace the successful upload handler with this:
|
293 |
uploadTask.on("state_changed", (snapshot) => {
|
294 |
// Handle the progress of the upload
|
@@ -308,10 +411,187 @@ html, body {
|
|
308 |
});
|
309 |
});
|
310 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
-
|
313 |
document.getElementById("hamburger-menu").addEventListener("click", toggleToolbar);
|
314 |
-
|
315 |
</script>
|
316 |
|
317 |
<py-env>
|
@@ -355,11 +635,15 @@ from js import (
|
|
355 |
uploadImageToFirebase,
|
356 |
firebase,
|
357 |
aws,
|
358 |
-
fetch
|
|
|
|
|
359 |
)
|
360 |
answer = aws("hello", 1, 2)
|
361 |
console.log(answer)
|
362 |
|
|
|
|
|
363 |
#addPhoto("demo")
|
364 |
|
365 |
# async def get_latest_image_from_firebase():
|
@@ -444,7 +728,7 @@ history = History()
|
|
444 |
|
445 |
base_lst = [None]
|
446 |
async def draw_canvas() -> None:
|
447 |
-
|
448 |
width=1024
|
449 |
height=700
|
450 |
canvas=InfCanvas(1024,700)
|
@@ -470,7 +754,7 @@ async def draw_canvas() -> None:
|
|
470 |
|
471 |
|
472 |
async def draw_canvas_func(event):
|
473 |
-
|
474 |
try:
|
475 |
app=parent.document.querySelector("gradio-app")
|
476 |
if app.shadowRoot:
|
@@ -526,7 +810,8 @@ async def draw_canvas_func(event):
|
|
526 |
|
527 |
base_lst[0]=canvas
|
528 |
|
529 |
-
|
|
|
530 |
|
531 |
|
532 |
import js
|
@@ -550,6 +835,7 @@ async def export_func(event):
|
|
550 |
link.href = "data:image/png;base64," + base64_str
|
551 |
link.click()
|
552 |
console.log(f"Canvas saved to {filename}.png")
|
|
|
553 |
|
554 |
img_candidate_lst=[None,0]
|
555 |
|
@@ -576,6 +862,9 @@ async def outpaint_func(event):
|
|
576 |
arr=base.base64_to_numpy(lst[idx%len(lst)])
|
577 |
base.fill_selection(arr)
|
578 |
base.draw_selection_box()
|
|
|
|
|
|
|
579 |
|
580 |
async def undo_func(event):
|
581 |
base=base_lst[0]
|
@@ -603,6 +892,7 @@ async def commit_func(event):
|
|
603 |
# Call the JavaScript function to upload the image to Firebase storage
|
604 |
await js.uploadImageToFirebase(base64_str, time_str)
|
605 |
|
|
|
606 |
|
607 |
async def history_undo_func(event):
|
608 |
base=base_lst[0]
|
@@ -643,6 +933,7 @@ async def transfer_func(event):
|
|
643 |
app=app.shadowRoot
|
644 |
app.querySelector("#input textarea").value=sel_buffer_str
|
645 |
app.querySelector("#proceed").click()
|
|
|
646 |
|
647 |
async def upload_func(event):
|
648 |
base=base_lst[0]
|
@@ -722,6 +1013,7 @@ async def zoom_in_func(event):
|
|
722 |
base.update_scale(scale)
|
723 |
scale=base.scale
|
724 |
update_scale(f"{base.width}x{base.height} ({round(100/scale)}%)")
|
|
|
725 |
|
726 |
async def zoom_out_func(event):
|
727 |
base=base_lst[0]
|
@@ -735,11 +1027,14 @@ async def zoom_out_func(event):
|
|
735 |
base.update_scale(scale)
|
736 |
scale=base.scale
|
737 |
update_scale(f"{base.width}x{base.height} ({round(100/scale)}%)")
|
|
|
738 |
|
739 |
async def sync_func(event):
|
740 |
base=base_lst[0]
|
741 |
base.sync_to_buffer()
|
742 |
base.canvas[2].clear()
|
|
|
|
|
743 |
|
744 |
async def eraser_size_func(event):
|
745 |
base=base_lst[0]
|
@@ -812,6 +1107,7 @@ async def message_func(event):
|
|
812 |
await upload_func(event)
|
813 |
elif event.data[0]=="outpaint":
|
814 |
await outpaint_func(event)
|
|
|
815 |
elif event.data[0]=="mode":
|
816 |
if event.data[1]!="selection":
|
817 |
await sync_func(event)
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
+
<title>stanley capstone</title>
|
5 |
<meta charset="utf-8">
|
6 |
|
7 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/stanleywalker1/capstone-studio-2@main/css/w2ui.min.css">
|
8 |
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/stanleywalker1/capstone-studio-2@main/js/w2ui.min.js"></script>
|
|
|
9 |
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
|
10 |
+
<script src="https://cdn.jsdelivr.net/gh/stanleywalker1/capstone-studio-2@main/js/fabric.min.js"></script>
|
11 |
+
<script defer src="https://cdn.jsdelivr.net/gh/stanleywalker1/capstone-studio-2@latest/js/toolbar5.js"></script>
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
|
17 |
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
|
18 |
|
|
|
45 |
}
|
46 |
.control {
|
47 |
display: none;
|
48 |
+
background-color: aliceblue;
|
49 |
}
|
50 |
#outer_container {
|
51 |
width: 100%;
|
52 |
height: 100vh;
|
53 |
+
|
54 |
}
|
55 |
|
56 |
#hamburger-menu {
|
|
|
139 |
background-position: 0% 50%;
|
140 |
}
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
.generate-button {
|
144 |
background-color: #f1f1f1;
|
|
|
154 |
border-radius: 4px;
|
155 |
}
|
156 |
|
157 |
+
#hamburger-menu {
|
158 |
+
position: fixed;
|
159 |
+
top: 10px;
|
160 |
+
right: 10px;
|
161 |
+
width: 50px;
|
162 |
+
height: 50px;
|
163 |
+
background-color: #f1f1f1;
|
164 |
+
border-radius: 50%;
|
165 |
+
display: flex;
|
166 |
+
justify-content: center;
|
167 |
+
align-items: center;
|
168 |
+
cursor: pointer;
|
169 |
+
z-index: 1000;
|
170 |
+
overflow: hidden;
|
171 |
+
}
|
172 |
+
|
173 |
+
#hamburger-menu::before {
|
174 |
+
content: "";
|
175 |
+
position: absolute;
|
176 |
+
top: -50%;
|
177 |
+
left: -50%;
|
178 |
+
width: 200%;
|
179 |
+
height: 200%;
|
180 |
+
background-image: radial-gradient(circle, #00ff00, #00ffff, #ff00ff, #ff0000, #ffff00, #00ff00);
|
181 |
+
background-size: 300% 300%;
|
182 |
+
animation: gradient-animation 6s linear infinite;
|
183 |
+
z-index: -1;
|
184 |
+
}
|
185 |
+
|
186 |
+
|
187 |
+
#hamburger-menu i {
|
188 |
+
font-size: 24px;
|
189 |
+
position: relative;
|
190 |
+
z-index: 1;
|
191 |
+
}
|
192 |
+
|
193 |
+
.fa-bars {
|
194 |
+
position: relative;
|
195 |
+
display: inline-block;
|
196 |
+
width: 24px;
|
197 |
+
height: 2px;
|
198 |
+
background-color: currentColor;
|
199 |
+
transition: background-color 0.3s ease;
|
200 |
+
}
|
201 |
+
|
202 |
+
.fa-bars::before,
|
203 |
+
.fa-bars::after {
|
204 |
+
content: "";
|
205 |
+
position: absolute;
|
206 |
+
left: 0;
|
207 |
+
width: 100%;
|
208 |
+
height: 2px;
|
209 |
+
background-color: currentColor;
|
210 |
+
transition: transform 0.3s ease, opacity 0.3s ease;
|
211 |
+
}
|
212 |
+
|
213 |
+
.fa-bars::before {
|
214 |
+
top: -6px;
|
215 |
+
}
|
216 |
+
|
217 |
+
.fa-bars::after {
|
218 |
+
bottom: -6px;
|
219 |
+
}
|
220 |
+
|
221 |
+
.open .fa-bars {
|
222 |
+
background-color: transparent;
|
223 |
+
}
|
224 |
+
|
225 |
+
.open .fa-bars::before {
|
226 |
+
transform: translateY(6px) rotate(45deg);
|
227 |
+
}
|
228 |
+
|
229 |
+
.open .fa-bars::after {
|
230 |
+
transform: translateY(-6px) rotate(-45deg);
|
231 |
+
}
|
232 |
+
|
233 |
+
@keyframes gradient-animation {
|
234 |
+
0% {
|
235 |
+
background-position: 0% 50%;
|
236 |
+
}
|
237 |
+
50% {
|
238 |
+
background-position: 100% 50%;
|
239 |
+
}
|
240 |
+
100% {
|
241 |
+
background-position: 0% 50%;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
#toolbar {
|
246 |
+
display: block;
|
247 |
+
height: 200px;
|
248 |
+
background: #0C0F19;
|
249 |
+
}
|
250 |
+
|
251 |
+
.w2ui-toolbar .w2ui-scroll-wrapper .w2ui-tb-button-hover {
|
252 |
+
background-color: #713870; /* Change this to the desired hover background color */
|
253 |
+
}
|
254 |
+
|
255 |
|
256 |
|
257 |
|
|
|
259 |
|
260 |
</head>
|
261 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
<div>
|
263 |
+
<div id="hamburger-menu">
|
264 |
+
<i class="fa-solid fa-bars"></i>
|
265 |
</div>
|
266 |
+
<button type="button" class="control" id="export">Export</button>
|
267 |
+
<button type="button" class="control" id="outpaint">Outpaint</button>
|
268 |
+
<button type="button" class="control" id="undo">Undo</button>
|
269 |
+
<button type="button" class="control" id="commit">Commit</button>
|
270 |
+
<button type="button" class="control" id="transfer">Transfer</button>
|
271 |
+
<button type="button" class="control" id="upload">Upload</button>
|
272 |
+
<button type="button" class="control" id="draw">Draw</button>
|
273 |
+
<input type="text" id="mode" value="selection" class="control">
|
274 |
+
<input type="text" id="setup" value="0" class="control">
|
275 |
+
<input type="text" id="upload_content" value="0" class="control">
|
276 |
+
<textarea rows="1" id="selbuffer" name="selbuffer" class="control"></textarea>
|
277 |
+
<fieldset class="control">
|
278 |
+
<div>
|
279 |
+
<input type="radio" id="mode0" name="mode" value="0" checked>
|
280 |
+
<label for="mode0">SelBox</label>
|
281 |
+
</div>
|
282 |
+
<div>
|
283 |
+
<input type="radio" id="mode1" name="mode" value="1">
|
284 |
+
<label for="mode1">Image</label>
|
285 |
+
</div>
|
286 |
+
<div>
|
287 |
+
<input type="radio" id="mode2" name="mode" value="2">
|
288 |
+
<label for="mode2">Brush</label>
|
289 |
+
</div>
|
290 |
+
</fieldset>
|
291 |
</div>
|
292 |
+
<div id = "outer_container">
|
293 |
+
<div id = "container">
|
294 |
+
<canvas id = "canvas0"></canvas>
|
295 |
+
<canvas id = "canvas1"></canvas>
|
296 |
+
<canvas id = "canvas2"></canvas>
|
297 |
+
<canvas id = "canvas3"></canvas>
|
298 |
+
<canvas id = "canvas4"></canvas>
|
299 |
+
<div id="overlay_container" style="pointer-events: none">
|
300 |
+
<canvas id = "overlay_canvas" width="1" height="1"></canvas>
|
301 |
+
</div>
|
302 |
</div>
|
303 |
+
<input type="file" name="file" id="upload_file" accept="image/*" hidden>
|
304 |
+
<input type="file" name="state" id="upload_state" accept=".sdinf" hidden>
|
305 |
+
<div style="position: relative;">
|
|
|
|
|
|
|
|
|
|
|
306 |
<div id="toolbar" style></div>
|
307 |
+
<!--
|
308 |
+
<div id="toolbar_container">
|
309 |
+
<div id="toolbar" style></div>
|
310 |
+
</div> -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
+
</div>
|
313 |
</div>
|
314 |
|
315 |
|
|
|
317 |
|
318 |
|
319 |
|
320 |
+
alert("starting js");
|
321 |
+
|
322 |
+
|
323 |
+
|
324 |
+
|
325 |
|
326 |
function toggleToolbar() {
|
327 |
console.log("Hamburger menu button clicked");
|
|
|
391 |
|
392 |
const uploadTask = storageRef.put(blob);
|
393 |
|
394 |
+
alert("sucessful upload to firebae");
|
395 |
// Replace the successful upload handler with this:
|
396 |
uploadTask.on("state_changed", (snapshot) => {
|
397 |
// Handle the progress of the upload
|
|
|
411 |
});
|
412 |
});
|
413 |
}
|
414 |
+
|
415 |
+
function overrideW2uiStyles() {
|
416 |
+
const toolbar = document.querySelector(".w2ui-toolbar");
|
417 |
+
|
418 |
+
if (!toolbar) {
|
419 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
420 |
+
return;
|
421 |
+
}
|
422 |
+
toolbar.style.backgroundColor = "#0C0F19";
|
423 |
+
|
424 |
+
|
425 |
+
|
426 |
+
|
427 |
+
const toolbarButtons = document.querySelectorAll(".w2ui-toolbar .w2ui-scroll-wrapper .w2ui-tb-button");
|
428 |
+
|
429 |
+
toolbarButtons.forEach(button => {
|
430 |
+
button.style.border = "4px solid rgb(67, 55, 201)";
|
431 |
+
button.style.backgroundColor = "#1F2937";
|
432 |
+
button.style.color = "#ffffff";
|
433 |
+
button.style.fontSize = "16px";
|
434 |
+
button.style.fontWeight = 600;
|
435 |
+
|
436 |
+
|
437 |
+
const nestedText = button.querySelector("div.w2ui-tb-text:nth-child(1)");
|
438 |
+
if (nestedText) {
|
439 |
+
nestedText.style.color = "rgb(255, 255, 255)";
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
// Add event listeners for mouseover and mouseout events
|
444 |
+
button.addEventListener("mouseenter", () => {
|
445 |
+
button.style.backgroundColor = "#4B5563";
|
446 |
+
});
|
447 |
+
button.addEventListener("mouseleave", () => {
|
448 |
+
button.style.backgroundColor = "#1F2937";
|
449 |
+
});
|
450 |
+
});
|
451 |
+
|
452 |
+
const outpaintElement = document.getElementById("tb_toolbar_item_outpaint");
|
453 |
+
if (!outpaintElement) {
|
454 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
455 |
+
return;
|
456 |
+
}
|
457 |
+
|
458 |
+
const nestedDiv1 = outpaintElement.querySelector("#tb_toolbar_item_outpaint > div:nth-child(2)");
|
459 |
+
const nestedDiv2 = outpaintElement.querySelector("div.w2ui-tb-icon span.fa-solid.fa-wand-magic-sparkles");
|
460 |
+
|
461 |
+
if (nestedDiv1) {
|
462 |
+
nestedDiv1.style.color = "white";
|
463 |
+
}
|
464 |
+
|
465 |
+
if (nestedDiv2) {
|
466 |
+
nestedDiv2.style.fontSize = "30px";
|
467 |
+
}
|
468 |
+
|
469 |
+
outpaintElement.style.height = "70px";
|
470 |
+
outpaintElement.style.border = "4px solid rgb(67, 55, 201)";
|
471 |
+
outpaintElement.style.backgroundColor = "rgb(31, 41, 55)";
|
472 |
+
outpaintElement.style.color = "rgb(255, 255, 255)";
|
473 |
+
outpaintElement.style.fontSize = "16px";
|
474 |
+
outpaintElement.style.fontWeight = "600";
|
475 |
+
outpaintElement.style.width = "200px";
|
476 |
+
outpaintElement.style.lineHeight = "50px";
|
477 |
+
outpaintElement.style.textAlign = "center";
|
478 |
+
outpaintElement.style.borderRadius = "40px";
|
479 |
+
outpaintElement.style.display = "flex";
|
480 |
+
outpaintElement.style.alignItems = "center";
|
481 |
+
outpaintElement.style.justifyContent = "center";
|
482 |
+
|
483 |
+
const devButtonElement = document.getElementById("tb_toolbar_item_developer_options");
|
484 |
+
|
485 |
+
if (!devButtonElement) {
|
486 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
487 |
+
return;
|
488 |
+
}
|
489 |
+
devButtonElement.style.height = "40px";
|
490 |
+
devButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
|
491 |
+
devButtonElement.style.color = "rgb(255, 255, 255)";
|
492 |
+
devButtonElement.style.fontSize = "16px";
|
493 |
+
devButtonElement.style.fontWeight = "600";
|
494 |
+
devButtonElement.style.width = "200px";
|
495 |
+
devButtonElement.style.lineHeight = "50px";
|
496 |
+
devButtonElement.style.textAlign = "center";
|
497 |
+
devButtonElement.style.borderRadius = "40px";
|
498 |
+
devButtonElement.style.display = "flex";
|
499 |
+
devButtonElement.style.alignItems = "center";
|
500 |
+
devButtonElement.style.justifyContent = "center";
|
501 |
+
|
502 |
+
|
503 |
+
const zoomOutButtonElement = document.getElementById("tb_toolbar_item_zoom_out");
|
504 |
+
if (!zoomOutButtonElement) {
|
505 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
506 |
+
return;
|
507 |
+
}
|
508 |
+
zoomOutButtonElement.style.height = "45px";
|
509 |
+
zoomOutButtonElement.style.width = "45px";
|
510 |
+
zoomOutButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
|
511 |
+
zoomOutButtonElement.style.color = "rgb(255, 255, 255)";
|
512 |
+
zoomOutButtonElement.style.fontSize = "16px";
|
513 |
+
zoomOutButtonElement.style.fontWeight = "600";
|
514 |
+
zoomOutButtonElement.style.lineHeight = "50px";
|
515 |
+
zoomOutButtonElement.style.textAlign = "center";
|
516 |
+
zoomOutButtonElement.style.borderRadius = "40px";
|
517 |
+
zoomOutButtonElement.style.display = "flex";
|
518 |
+
zoomOutButtonElement.style.alignItems = "center";
|
519 |
+
zoomOutButtonElement.style.justifyContent = "center";
|
520 |
+
|
521 |
+
|
522 |
+
const zoomInButtonElement = document.getElementById("tb_toolbar_item_zoom_in");
|
523 |
+
if (!zoomInButtonElement) {
|
524 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
525 |
+
return;
|
526 |
+
}
|
527 |
+
zoomInButtonElement.style.height = "45px";
|
528 |
+
zoomInButtonElement.style.width = "45px";
|
529 |
+
zoomInButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
|
530 |
+
zoomInButtonElement.style.color = "rgb(255, 255, 255)";
|
531 |
+
zoomInButtonElement.style.fontSize = "16px";
|
532 |
+
zoomInButtonElement.style.fontWeight = "600";
|
533 |
+
zoomInButtonElement.style.lineHeight = "50px";
|
534 |
+
zoomInButtonElement.style.textAlign = "center";
|
535 |
+
zoomInButtonElement.style.borderRadius = "40px";
|
536 |
+
zoomInButtonElement.style.display = "flex";
|
537 |
+
zoomInButtonElement.style.alignItems = "center";
|
538 |
+
zoomInButtonElement.style.justifyContent = "center";
|
539 |
+
|
540 |
+
|
541 |
+
// html body div#outer_container div div#toolbar.w2ui-reset.w2ui-toolbar div.w2ui-tb-line div.w2ui-scroll-wrapper.w2ui-eaction div#tb_toolbar_item_accept.w2ui-tb-button
|
542 |
+
// html body div#outer_container div div#toolbar.w2ui-reset.w2ui-toolbar div.w2ui-tb-line div.w2ui-scroll-wrapper.w2ui-eaction div#tb_toolbar_item_accept.w2ui-tb-button.disabled.hidden
|
543 |
+
const acceptButtonElement = document.getElementById("tb_toolbar_item_accept");
|
544 |
+
if (!acceptButtonElement) {
|
545 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
546 |
+
return;
|
547 |
+
}
|
548 |
+
acceptButtonElement.style.height = "45px";
|
549 |
+
acceptButtonElement.style.width = "100px";
|
550 |
+
acceptButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
|
551 |
+
acceptButtonElement.style.color = "rgb(255, 255, 255)";
|
552 |
+
acceptButtonElement.style.fontSize = "16px";
|
553 |
+
acceptButtonElement.style.fontWeight = "600";
|
554 |
+
acceptButtonElement.style.lineHeight = "50px";
|
555 |
+
acceptButtonElement.style.textAlign = "center";
|
556 |
+
acceptButtonElement.style.borderRadius = "40px";
|
557 |
+
acceptButtonElement.style.display = "flex";
|
558 |
+
acceptButtonElement.style.alignItems = "center";
|
559 |
+
acceptButtonElement.style.justifyContent = "center";
|
560 |
+
//html body div#outer_container div div#toolbar.w2ui-reset.w2ui-toolbar div.w2ui-tb-line div.w2ui-scroll-wrapper.w2ui-eaction div#tb_toolbar_item_cancel.w2ui-tb-button
|
561 |
+
//html body div#outer_container div div#toolbar.w2ui-reset.w2ui-toolbar div.w2ui-tb-line div.w2ui-scroll-wrapper.w2ui-eaction div#tb_toolbar_item_cancel.w2ui-tb-button.hidden
|
562 |
+
|
563 |
+
// #tb_toolbar_item_cancel
|
564 |
+
// html body div#outer_container div div#toolbar.w2ui-reset.w2ui-toolbar div.w2ui-tb-line div.w2ui-scroll-wrapper.w2ui-eaction div#tb_toolbar_item_cancel.w2ui-tb-button
|
565 |
+
const cancelButtonElement = document.getElementById("tb_toolbar_item_cancel");
|
566 |
+
if (!cancelButtonElement) {
|
567 |
+
setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
|
568 |
+
return;
|
569 |
+
}
|
570 |
+
cancelButtonElement.style.height = "45px";
|
571 |
+
cancelButtonElement.style.width = "100px";
|
572 |
+
cancelButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
|
573 |
+
cancelButtonElement.style.color = "rgb(255, 255, 255)";
|
574 |
+
cancelButtonElement.style.fontSize = "16px";
|
575 |
+
cancelButtonElement.style.fontWeight = "600";
|
576 |
+
cancelButtonElement.style.lineHeight = "50px";
|
577 |
+
cancelButtonElement.style.textAlign = "center";
|
578 |
+
cancelButtonElement.style.borderRadius = "40px";
|
579 |
+
cancelButtonElement.style.display = "flex";
|
580 |
+
cancelButtonElement.style.alignItems = "center";
|
581 |
+
cancelButtonElement.style.justifyContent = "center";
|
582 |
+
|
583 |
+
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
|
589 |
+
// Execute style function to start checking
|
590 |
+
overrideW2uiStyles();
|
591 |
|
592 |
+
//window.addEventListener("applyCustomStyles", overrideW2uiStyles);
|
593 |
document.getElementById("hamburger-menu").addEventListener("click", toggleToolbar);
|
594 |
+
alert("js loaded");
|
595 |
</script>
|
596 |
|
597 |
<py-env>
|
|
|
635 |
uploadImageToFirebase,
|
636 |
firebase,
|
637 |
aws,
|
638 |
+
fetch,
|
639 |
+
overrideW2uiStyles
|
640 |
+
|
641 |
)
|
642 |
answer = aws("hello", 1, 2)
|
643 |
console.log(answer)
|
644 |
|
645 |
+
|
646 |
+
|
647 |
#addPhoto("demo")
|
648 |
|
649 |
# async def get_latest_image_from_firebase():
|
|
|
728 |
|
729 |
base_lst = [None]
|
730 |
async def draw_canvas() -> None:
|
731 |
+
alert("draw_canvas called")
|
732 |
width=1024
|
733 |
height=700
|
734 |
canvas=InfCanvas(1024,700)
|
|
|
754 |
|
755 |
|
756 |
async def draw_canvas_func(event):
|
757 |
+
alert("draw_canvas gradio called")
|
758 |
try:
|
759 |
app=parent.document.querySelector("gradio-app")
|
760 |
if app.shadowRoot:
|
|
|
810 |
|
811 |
base_lst[0]=canvas
|
812 |
|
813 |
+
alert("made it to end of draw_canvas gradio")
|
814 |
+
|
815 |
|
816 |
|
817 |
import js
|
|
|
835 |
link.href = "data:image/png;base64," + base64_str
|
836 |
link.click()
|
837 |
console.log(f"Canvas saved to {filename}.png")
|
838 |
+
|
839 |
|
840 |
img_candidate_lst=[None,0]
|
841 |
|
|
|
862 |
arr=base.base64_to_numpy(lst[idx%len(lst)])
|
863 |
base.fill_selection(arr)
|
864 |
base.draw_selection_box()
|
865 |
+
js.overrideW2uiStyles()
|
866 |
+
|
867 |
+
|
868 |
|
869 |
async def undo_func(event):
|
870 |
base=base_lst[0]
|
|
|
892 |
# Call the JavaScript function to upload the image to Firebase storage
|
893 |
await js.uploadImageToFirebase(base64_str, time_str)
|
894 |
|
895 |
+
|
896 |
|
897 |
async def history_undo_func(event):
|
898 |
base=base_lst[0]
|
|
|
933 |
app=app.shadowRoot
|
934 |
app.querySelector("#input textarea").value=sel_buffer_str
|
935 |
app.querySelector("#proceed").click()
|
936 |
+
|
937 |
|
938 |
async def upload_func(event):
|
939 |
base=base_lst[0]
|
|
|
1013 |
base.update_scale(scale)
|
1014 |
scale=base.scale
|
1015 |
update_scale(f"{base.width}x{base.height} ({round(100/scale)}%)")
|
1016 |
+
js.overrideW2uiStyles()
|
1017 |
|
1018 |
async def zoom_out_func(event):
|
1019 |
base=base_lst[0]
|
|
|
1027 |
base.update_scale(scale)
|
1028 |
scale=base.scale
|
1029 |
update_scale(f"{base.width}x{base.height} ({round(100/scale)}%)")
|
1030 |
+
js.overrideW2uiStyles()
|
1031 |
|
1032 |
async def sync_func(event):
|
1033 |
base=base_lst[0]
|
1034 |
base.sync_to_buffer()
|
1035 |
base.canvas[2].clear()
|
1036 |
+
js.overrideW2uiStyles()
|
1037 |
+
|
1038 |
|
1039 |
async def eraser_size_func(event):
|
1040 |
base=base_lst[0]
|
|
|
1107 |
await upload_func(event)
|
1108 |
elif event.data[0]=="outpaint":
|
1109 |
await outpaint_func(event)
|
1110 |
+
js.overrideW2uiStyles()
|
1111 |
elif event.data[0]=="mode":
|
1112 |
if event.data[1]!="selection":
|
1113 |
await sync_func(event)
|