stanley commited on
Commit
363c036
·
1 Parent(s): 0a648c0

updated UI/UX

Browse files
Files changed (2) hide show
  1. app.py +19 -19
  2. index.html +59 -162
app.py CHANGED
@@ -47,20 +47,8 @@ if os.path.exists(".env"):
47
  os.environ[name] = value
48
 
49
 
50
- access_token = os.environ.get("HF_ACCESS_TOKEN")
51
- print("access_token from HF 1:", access_token)
52
-
53
-
54
-
55
- def query(payload, model_id, api_token):
56
- headers = {"Authorization": f"Bearer {api_token}"}
57
- API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
58
- response = requests.post(API_URL, headers=headers, json=payload)
59
- return response.json()
60
-
61
- model_id = "stabilityai/stable-diffusion-2-inpainting"
62
- api_token = "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" # get yours at hf.co/settings/tokens
63
- data = query("The goal of life is [MASK].", model_id, api_token)
64
 
65
  try:
66
  abspath = os.path.abspath(__file__)
@@ -215,13 +203,21 @@ if args.auth is not None:
215
 
216
  model = {}
217
 
 
 
 
 
 
 
 
 
 
218
 
219
  def get_token():
220
- token = "{access_token}"
221
  if os.path.exists(".token"):
222
  with open(".token", "r") as f:
223
  token = f.read()
224
- print("get_token called", token)
225
  token = os.environ.get("hftoken", token)
226
  return token
227
 
@@ -347,9 +343,9 @@ class StableDiffusionInpaint:
347
  )
348
  else:
349
  inpaint = StableDiffusionInpaintPipeline.from_pretrained(
350
- model_name, use_auth_token=access_token, vae=vae
351
  )
352
- print(f"access_token from HF:", access_token)
353
  if os.path.exists("./embeddings"):
354
  print("Note that StableDiffusionInpaintPipeline + embeddings is untested")
355
  for item in os.listdir("./embeddings"):
@@ -463,6 +459,10 @@ class StableDiffusionInpaint:
463
  init_image = Image.fromarray(img)
464
  mask_image = Image.fromarray(mask)
465
  # mask_image=mask_image.filter(ImageFilter.GaussianBlur(radius = 8))
 
 
 
 
466
  if True:
467
  images = inpaint_func(
468
  prompt=prompt,
@@ -1012,7 +1012,7 @@ with blocks as demo:
1012
  sd_prompt = gr.Textbox(
1013
  label="Prompt", placeholder="input your prompt here!", lines=2
1014
  )
1015
- with gr.Accordion("developer tools", open=False):
1016
  with gr.Row(elem_id="setup_row"):
1017
  with gr.Column(scale=4, min_width=350):
1018
  token = gr.Textbox(
 
47
  os.environ[name] = value
48
 
49
 
50
+ # access_token = os.environ.get("HF_ACCESS_TOKEN")
51
+ # print("access_token from HF 1:", access_token)
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  try:
54
  abspath = os.path.abspath(__file__)
 
203
 
204
  model = {}
205
 
206
+ # HF function for token
207
+ # def get_token():
208
+ # token = "{access_token}"
209
+ # if os.path.exists(".token"):
210
+ # with open(".token", "r") as f:
211
+ # token = f.read()
212
+ # print("get_token called", token)
213
+ # token = os.environ.get("hftoken", token)
214
+ # return token
215
 
216
  def get_token():
217
+ token = ""
218
  if os.path.exists(".token"):
219
  with open(".token", "r") as f:
220
  token = f.read()
 
221
  token = os.environ.get("hftoken", token)
222
  return token
223
 
 
343
  )
344
  else:
345
  inpaint = StableDiffusionInpaintPipeline.from_pretrained(
346
+ model_name, use_auth_token=token, vae=vae
347
  )
348
+ # print(f"access_token from HF:", access_token)
349
  if os.path.exists("./embeddings"):
350
  print("Note that StableDiffusionInpaintPipeline + embeddings is untested")
351
  for item in os.listdir("./embeddings"):
 
459
  init_image = Image.fromarray(img)
460
  mask_image = Image.fromarray(mask)
461
  # mask_image=mask_image.filter(ImageFilter.GaussianBlur(radius = 8))
462
+
463
+ # Cast input image and mask to float32
464
+ # init_image = init_image.convert("RGB").to(torch.float32)
465
+ # mask_image = mask_image.convert("L").to(torch.float32)
466
  if True:
467
  images = inpaint_func(
468
  prompt=prompt,
 
1012
  sd_prompt = gr.Textbox(
1013
  label="Prompt", placeholder="input your prompt here!", lines=2
1014
  )
1015
+ with gr.Accordion("machine learning tools", open=False):
1016
  with gr.Row(elem_id="setup_row"):
1017
  with gr.Column(scale=4, min_width=350):
1018
  token = gr.Textbox(
index.html CHANGED
@@ -8,7 +8,7 @@
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
 
@@ -52,108 +52,6 @@ html, body {
52
  height: 100vh;
53
 
54
  }
55
-
56
- #hamburger-menu {
57
- position: fixed;
58
- top: 10px;
59
- right: 10px;
60
- width: 50px;
61
- height: 50px;
62
- background-color: #f1f1f1;
63
- border-radius: 50%;
64
- display: flex;
65
- justify-content: center;
66
- align-items: center;
67
- cursor: pointer;
68
- z-index: 1000;
69
- overflow: hidden;
70
- }
71
-
72
- #hamburger-menu::before {
73
- content: "";
74
- position: absolute;
75
- top: -50%;
76
- left: -50%;
77
- width: 200%;
78
- height: 200%;
79
- background-image: radial-gradient(circle, #00ff00, #00ffff, #ff00ff, #ff0000, #ffff00, #00ff00);
80
- background-size: 300% 300%;
81
- animation: gradient-animation 6s linear infinite;
82
- z-index: -1;
83
- }
84
-
85
- #hamburger-menu i {
86
- font-size: 24px;
87
- position: relative;
88
- z-index: 1;
89
- }
90
-
91
- .fa-bars {
92
- position: relative;
93
- display: inline-block;
94
- width: 24px;
95
- height: 2px;
96
- background-color: currentColor;
97
- transition: background-color 0.3s ease;
98
- }
99
-
100
- .fa-bars::before,
101
- .fa-bars::after {
102
- content: "";
103
- position: absolute;
104
- left: 0;
105
- width: 100%;
106
- height: 2px;
107
- background-color: currentColor;
108
- transition: transform 0.3s ease, opacity 0.3s ease;
109
- }
110
-
111
- .fa-bars::before {
112
- top: -6px;
113
- }
114
-
115
- .fa-bars::after {
116
- bottom: -6px;
117
- }
118
-
119
- .open .fa-bars {
120
- background-color: transparent;
121
- }
122
-
123
- .open .fa-bars::before {
124
- transform: translateY(6px) rotate(45deg);
125
- }
126
-
127
- .open .fa-bars::after {
128
- transform: translateY(-6px) rotate(-45deg);
129
- }
130
-
131
- @keyframes gradient-animation {
132
- 0% {
133
- background-position: 0% 50%;
134
- }
135
- 50% {
136
- background-position: 100% 50%;
137
- }
138
- 100% {
139
- background-position: 0% 50%;
140
- }
141
- }
142
-
143
- .generate-button {
144
- background-color: #f1f1f1;
145
- border: none;
146
- color: #333;
147
- padding: 10px 20px;
148
- text-align: center;
149
- text-decoration: none;
150
- display: inline-block;
151
- font-size: 16px;
152
- margin: 4px 2px;
153
- cursor: pointer;
154
- border-radius: 4px;
155
- }
156
-
157
  #hamburger-menu {
158
  position: fixed;
159
  top: 10px;
@@ -190,44 +88,33 @@ html, body {
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 {
@@ -261,7 +148,7 @@ html, body {
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>
@@ -317,19 +204,6 @@ html, body {
317
 
318
  // alert("starting js");
319
 
320
- function toggleToolbar() {
321
- console.log("Hamburger menu button clicked");
322
- const toolbar = document.getElementById("toolbar");
323
- const hamburgerMenu = document.getElementById("hamburger-menu");
324
- if (toolbar.style.display === "none" || toolbar.style.display === "") {
325
- toolbar.style.display = "block";
326
- hamburgerMenu.classList.add("open");
327
- } else {
328
- toolbar.style.display = "none";
329
- hamburgerMenu.classList.remove("open");
330
- }
331
- }
332
-
333
  function aws(name, x, y) {
334
  return `coming from javascript ${name} ${x} ${y}`;
335
  }
@@ -352,7 +226,7 @@ html, body {
352
  const fireapp = initializeApp(firebaseConfig);
353
  function uploadImageToFirebase(base64_str, time_str) {
354
  return new Promise((resolve, reject) => {
355
- alert("starting to upload");
356
  const atob = (str) => {
357
  return window.atob(str);
358
  };
@@ -370,7 +244,7 @@ html, body {
370
  const storageRef = firebase.storage().ref(`images/${time_str}.png`);
371
  const uploadTask = storageRef.put(blob);
372
 
373
- alert("sucessful upload to firebae");
374
  // Replace the successful upload handler with this:
375
  uploadTask.on("state_changed", (snapshot) => {
376
  // Handle the progress of the upload
@@ -391,6 +265,7 @@ html, body {
391
  });
392
  }
393
 
 
394
  function overrideW2uiStyles() {
395
  const toolbar = document.querySelector(".w2ui-toolbar");
396
 
@@ -399,7 +274,9 @@ function overrideW2uiStyles() {
399
  return;
400
  }
401
  toolbar.style.backgroundColor = "#0C0F19";
 
402
  const toolbarButtons = document.querySelectorAll(".w2ui-toolbar .w2ui-scroll-wrapper .w2ui-tb-button");
 
403
  toolbarButtons.forEach(button => {
404
  button.style.border = "4px solid rgb(67, 55, 201)";
405
  button.style.backgroundColor = "#1F2937";
@@ -407,10 +284,13 @@ function overrideW2uiStyles() {
407
  button.style.fontSize = "16px";
408
  button.style.fontWeight = 600;
409
 
 
410
  const nestedText = button.querySelector("div.w2ui-tb-text:nth-child(1)");
411
  if (nestedText) {
412
  nestedText.style.color = "rgb(255, 255, 255)";
413
  }
 
 
414
  // Add event listeners for mouseover and mouseout events
415
  button.addEventListener("mouseenter", () => {
416
  button.style.backgroundColor = "#4B5563";
@@ -425,7 +305,7 @@ function overrideW2uiStyles() {
425
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
426
  return;
427
  }
428
-
429
  const nestedDiv1 = outpaintElement.querySelector("#tb_toolbar_item_outpaint > div:nth-child(2)");
430
  const nestedDiv2 = outpaintElement.querySelector("div.w2ui-tb-icon span.fa-solid.fa-wand-magic-sparkles");
431
 
@@ -508,14 +388,19 @@ function overrideW2uiStyles() {
508
  zoomInButtonElement.style.alignItems = "center";
509
  zoomInButtonElement.style.justifyContent = "center";
510
 
511
-
512
- // 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
513
- // 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
514
  const acceptButtonElement = document.getElementById("tb_toolbar_item_accept");
 
 
 
515
  if (!acceptButtonElement) {
516
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
517
  return;
518
  }
 
 
 
 
 
519
  acceptButtonElement.style.height = "45px";
520
  acceptButtonElement.style.width = "100px";
521
  acceptButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
@@ -528,16 +413,23 @@ function overrideW2uiStyles() {
528
  acceptButtonElement.style.display = "flex";
529
  acceptButtonElement.style.alignItems = "center";
530
  acceptButtonElement.style.justifyContent = "center";
531
- //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
532
- //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
533
-
534
- // #tb_toolbar_item_cancel
535
- // 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
536
  const cancelButtonElement = document.getElementById("tb_toolbar_item_cancel");
537
  if (!cancelButtonElement) {
538
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
539
  return;
540
  }
 
 
 
 
 
 
 
541
  cancelButtonElement.style.height = "45px";
542
  cancelButtonElement.style.width = "100px";
543
  cancelButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
@@ -550,14 +442,17 @@ function overrideW2uiStyles() {
550
  cancelButtonElement.style.display = "flex";
551
  cancelButtonElement.style.alignItems = "center";
552
  cancelButtonElement.style.justifyContent = "center";
 
 
 
 
553
  }
554
 
555
  // Execute style function to start checking
556
  overrideW2uiStyles();
557
 
558
  //window.addEventListener("applyCustomStyles", overrideW2uiStyles);
559
- document.getElementById("hamburger-menu").addEventListener("click", toggleToolbar);
560
- alert("js loaded");
561
  </script>
562
 
563
  <py-env>
@@ -694,7 +589,7 @@ history = History()
694
 
695
  base_lst = [None]
696
  async def draw_canvas() -> None:
697
- alert("draw_canvas called")
698
  width=1024
699
  height=700
700
  canvas=InfCanvas(1024,700)
@@ -725,7 +620,7 @@ async def draw_canvas() -> None:
725
  from PIL import ImageOps
726
 
727
  async def draw_canvas_func(event):
728
- alert("draw_canvas gradio called")
729
 
730
  database_url = "https://nyucapstone-7c22c-default-rtdb.firebaseio.com"
731
  image_data, latest_image_name = await fetch_latest_image_url(database_url)
@@ -750,7 +645,8 @@ async def draw_canvas_func(event):
750
  # Set the canvas dimensions to match the desired display dimensions
751
  width = display_width
752
  height = display_height
753
- selection_size = min(width, height) // 2
 
754
 
755
  document.querySelector("#container").style.width = f"{width}px"
756
  document.querySelector("#container").style.height = f"{height}px"
@@ -776,13 +672,13 @@ async def draw_canvas_func(event):
776
 
777
  base_lst[0] = canvas
778
 
779
- alert("made it to end of draw_canvas gradio")
780
 
781
 
782
 
783
  # original draw_canvas
784
  async def test_canvas_func(event):
785
- alert("draw_canvas gradio called")
786
  try:
787
  app=parent.document.querySelector("gradio-app")
788
  if app.shadowRoot:
@@ -836,7 +732,7 @@ async def test_canvas_func(event):
836
 
837
  base_lst[0]=canvas
838
 
839
- alert("made it to end of draw_canvas gradio")
840
 
841
 
842
 
@@ -1125,6 +1021,7 @@ async def message_func(event):
1125
  await history_undo_func(event)
1126
  elif event.data[1]=="history":
1127
  await history_setup_func(event)
 
1128
  elif event.data[0]=="sync":
1129
  await sync_func(event)
1130
  elif event.data[0]=="load":
 
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/toolbar6.js"></script>
12
 
13
 
14
 
 
52
  height: 100vh;
53
 
54
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  #hamburger-menu {
56
  position: fixed;
57
  top: 10px;
 
88
  z-index: 1;
89
  }
90
 
91
+ .eye-icon {
92
  position: relative;
93
  display: inline-block;
94
  width: 24px;
95
+ height: 12px;
96
+ background-color: transparent;
 
97
  }
98
 
99
+ .eye-icon::before,
100
+ .eye-icon::after {
101
  content: "";
102
  position: absolute;
103
+ width: 8px;
104
+ height: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  background-color: transparent;
106
+ border: 2px solid black;
107
+ border-radius: 50%;
108
  }
109
 
110
+ .eye-icon::before {
111
+ left: 4px;
112
+ top: 2px;
113
  }
114
 
115
+ .eye-icon::after {
116
+ right: 4px;
117
+ top: 2px;
118
  }
119
 
120
  @keyframes gradient-animation {
 
148
  <body>
149
  <div>
150
  <div id="hamburger-menu">
151
+ <i class="fa fa-eye" aria-hidden="true"></i>
152
  </div>
153
  <button type="button" class="control" id="export">Export</button>
154
  <button type="button" class="control" id="outpaint">Outpaint</button>
 
204
 
205
  // alert("starting js");
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  function aws(name, x, y) {
208
  return `coming from javascript ${name} ${x} ${y}`;
209
  }
 
226
  const fireapp = initializeApp(firebaseConfig);
227
  function uploadImageToFirebase(base64_str, time_str) {
228
  return new Promise((resolve, reject) => {
229
+ //alert("starting to upload");
230
  const atob = (str) => {
231
  return window.atob(str);
232
  };
 
244
  const storageRef = firebase.storage().ref(`images/${time_str}.png`);
245
  const uploadTask = storageRef.put(blob);
246
 
247
+ alert("saved to cloud");
248
  // Replace the successful upload handler with this:
249
  uploadTask.on("state_changed", (snapshot) => {
250
  // Handle the progress of the upload
 
265
  });
266
  }
267
 
268
+ // UI patch, aim to remove this and replace all elements with pure Gradio
269
  function overrideW2uiStyles() {
270
  const toolbar = document.querySelector(".w2ui-toolbar");
271
 
 
274
  return;
275
  }
276
  toolbar.style.backgroundColor = "#0C0F19";
277
+
278
  const toolbarButtons = document.querySelectorAll(".w2ui-toolbar .w2ui-scroll-wrapper .w2ui-tb-button");
279
+
280
  toolbarButtons.forEach(button => {
281
  button.style.border = "4px solid rgb(67, 55, 201)";
282
  button.style.backgroundColor = "#1F2937";
 
284
  button.style.fontSize = "16px";
285
  button.style.fontWeight = 600;
286
 
287
+
288
  const nestedText = button.querySelector("div.w2ui-tb-text:nth-child(1)");
289
  if (nestedText) {
290
  nestedText.style.color = "rgb(255, 255, 255)";
291
  }
292
+
293
+
294
  // Add event listeners for mouseover and mouseout events
295
  button.addEventListener("mouseenter", () => {
296
  button.style.backgroundColor = "#4B5563";
 
305
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
306
  return;
307
  }
308
+
309
  const nestedDiv1 = outpaintElement.querySelector("#tb_toolbar_item_outpaint > div:nth-child(2)");
310
  const nestedDiv2 = outpaintElement.querySelector("div.w2ui-tb-icon span.fa-solid.fa-wand-magic-sparkles");
311
 
 
388
  zoomInButtonElement.style.alignItems = "center";
389
  zoomInButtonElement.style.justifyContent = "center";
390
 
 
 
 
391
  const acceptButtonElement = document.getElementById("tb_toolbar_item_accept");
392
+
393
+ const acceptNestedText = acceptButtonElement.querySelector(".w2ui-tb-button.disabled.hidden div.w2ui-tb-text");
394
+
395
  if (!acceptButtonElement) {
396
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
397
  return;
398
  }
399
+
400
+ if (!acceptNestedText) {
401
+ setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
402
+ return;
403
+ }
404
  acceptButtonElement.style.height = "45px";
405
  acceptButtonElement.style.width = "100px";
406
  acceptButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
 
413
  acceptButtonElement.style.display = "flex";
414
  acceptButtonElement.style.alignItems = "center";
415
  acceptButtonElement.style.justifyContent = "center";
416
+
417
+
418
+
419
+ acceptNestedText.style.color = "rgb(255, 255, 255)";
420
+ acceptNestedText.style.marginLeft = "0";
421
  const cancelButtonElement = document.getElementById("tb_toolbar_item_cancel");
422
  if (!cancelButtonElement) {
423
  setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
424
  return;
425
  }
426
+
427
+ const cancelNestedText = cancelButtonElement.querySelector("div.w2ui-tb-text");
428
+
429
+ if (!cancelNestedText) {
430
+ setTimeout(overrideW2uiStyles, 200); // Check again after 200ms
431
+ return;
432
+ }
433
  cancelButtonElement.style.height = "45px";
434
  cancelButtonElement.style.width = "100px";
435
  cancelButtonElement.style.backgroundColor = "rgb(31, 41, 55)";
 
442
  cancelButtonElement.style.display = "flex";
443
  cancelButtonElement.style.alignItems = "center";
444
  cancelButtonElement.style.justifyContent = "center";
445
+
446
+ cancelNestedText.style.color = "rgb(255, 255, 255)";
447
+ cancelNestedText.style.marginLeft = "0";
448
+
449
  }
450
 
451
  // Execute style function to start checking
452
  overrideW2uiStyles();
453
 
454
  //window.addEventListener("applyCustomStyles", overrideW2uiStyles);
455
+ // alert("js loaded");
 
456
  </script>
457
 
458
  <py-env>
 
589
 
590
  base_lst = [None]
591
  async def draw_canvas() -> None:
592
+ # alert("draw_canvas called")
593
  width=1024
594
  height=700
595
  canvas=InfCanvas(1024,700)
 
620
  from PIL import ImageOps
621
 
622
  async def draw_canvas_func(event):
623
+ # alert("draw_canvas gradio called")
624
 
625
  database_url = "https://nyucapstone-7c22c-default-rtdb.firebaseio.com"
626
  image_data, latest_image_name = await fetch_latest_image_url(database_url)
 
645
  # Set the canvas dimensions to match the desired display dimensions
646
  width = display_width
647
  height = display_height
648
+ # selection_size = min(width, height) // 2
649
+ selection_size = int(min(img_width, img_height) * 0.25)
650
 
651
  document.querySelector("#container").style.width = f"{width}px"
652
  document.querySelector("#container").style.height = f"{height}px"
 
672
 
673
  base_lst[0] = canvas
674
 
675
+ # alert("made it to end of draw_canvas gradio")
676
 
677
 
678
 
679
  # original draw_canvas
680
  async def test_canvas_func(event):
681
+ # alert("draw_canvas gradio called")
682
  try:
683
  app=parent.document.querySelector("gradio-app")
684
  if app.shadowRoot:
 
732
 
733
  base_lst[0]=canvas
734
 
735
+ # alert("made it to end of draw_canvas gradio")
736
 
737
 
738
 
 
1021
  await history_undo_func(event)
1022
  elif event.data[1]=="history":
1023
  await history_setup_func(event)
1024
+ js.overrideW2uiStyles()
1025
  elif event.data[0]=="sync":
1026
  await sync_func(event)
1027
  elif event.data[0]=="load":