SharpMeow commited on
Commit
fc41ae9
路
verified 路
1 Parent(s): f0be2e8

Shorter picture title, legend under the picture, normals note only when they differ

Browse files
Files changed (2) hide show
  1. app.py +3 -4
  2. lasfield.py +7 -3
app.py CHANGED
@@ -246,7 +246,7 @@ def result_text(r):
246
  f"({fmt(same['normal_median_deg'], '掳')} over every voxel; medians). Control, the same field "
247
  f"{L.CONTROL_SHIFT} voxels away: cos r = {fmt(ctl.get('cos_r'))}, normals "
248
  f"{fmt(ctl.get('normal_median_deg_strong'), '掳')}. The same box should agree far better than the control.")
249
- if a.get("normals_note"):
250
  lines.append(f"\n{a['normals_note']}.")
251
  elif a.get("note") or a.get("error"):
252
  lines.append(f"\nCheck: {a.get('note') or a.get('error')}")
@@ -324,8 +324,7 @@ def make_field(volume: str, z: float, y: float, x: float, size: float = 256, mod
324
  with one_run(request):
325
  r = run_field(p, progress)
326
  c = p["centre_level0_zyx"]
327
- pic = L.compose(r["pictures"], f"{p['sample']} {p['volume']}, box of {p['size_zyx'][0]} around z {c[0]}, "
328
- f"y {c[1]}, x {c[2]}: villa lasagna, model output")
329
  return pic, r["receipt"], r["zip"]
330
 
331
 
@@ -445,7 +444,7 @@ CSS = """
445
  .lf-head { display:flex; align-items:center; gap:14px; padding:6px 2px 2px; }
446
  .lf-head .layers { width:30px; height:24px; border-radius:5px; flex:none;
447
  background:repeating-linear-gradient(180deg,#c2462b 0 4px,#e07a3f 4px 7px,#f3e2bf 7px 10px,#4f7a3a 10px 11px,#f3e2bf 11px 12px); }
448
- .lf-head h1 { font-family: Fraunces, Georgia, serif; font-weight:650; font-size:30px; margin:0; letter-spacing:-.01em; }
449
  .lf-head span { color: var(--body-text-color-subdued); font-size:15px; }
450
  .lf-guide iframe { width:100%; height:calc(100vh - 150px); min-height:640px; border:0; border-radius:12px;
451
  background:#f7f2ea; }
 
246
  f"({fmt(same['normal_median_deg'], '掳')} over every voxel; medians). Control, the same field "
247
  f"{L.CONTROL_SHIFT} voxels away: cos r = {fmt(ctl.get('cos_r'))}, normals "
248
  f"{fmt(ctl.get('normal_median_deg_strong'), '掳')}. The same box should agree far better than the control.")
249
+ if a.get("normals_note") and (same.get("normal_median_deg_strong") or 0) > 5:
250
  lines.append(f"\n{a['normals_note']}.")
251
  elif a.get("note") or a.get("error"):
252
  lines.append(f"\nCheck: {a.get('note') or a.get('error')}")
 
324
  with one_run(request):
325
  r = run_field(p, progress)
326
  c = p["centre_level0_zyx"]
327
+ pic = L.compose(r["pictures"], f"{p['sample']} 路 {p['size_zyx'][0]}鲁 box at z {c[0]}, y {c[1]}, x {c[2]}")
 
328
  return pic, r["receipt"], r["zip"]
329
 
330
 
 
444
  .lf-head { display:flex; align-items:center; gap:14px; padding:6px 2px 2px; }
445
  .lf-head .layers { width:30px; height:24px; border-radius:5px; flex:none;
446
  background:repeating-linear-gradient(180deg,#c2462b 0 4px,#e07a3f 4px 7px,#f3e2bf 7px 10px,#4f7a3a 10px 11px,#f3e2bf 11px 12px); }
447
+ .lf-head h1 { white-space:nowrap; font-family: Fraunces, Georgia, serif; font-weight:650; font-size:30px; margin:0; letter-spacing:-.01em; }
448
  .lf-head span { color: var(--body-text-color-subdued); font-size:15px; }
449
  .lf-guide iframe { width:100%; height:calc(100vh - 150px); min-height:640px; border:0; border-radius:12px;
450
  background:#f7f2ea; }
lasfield.py CHANGED
@@ -690,10 +690,11 @@ def picture(ct, arrays, boxes, axis=0):
690
  return np.concatenate(row, axis=1)
691
 
692
 
693
- PANELS = ("CT", "cos", "grad_mag", "normal (x red, y green, z blue)")
 
694
 
695
 
696
- def compose(pictures, title=""):
697
  """The three rows (z, y, x middle slices) under one header naming the panels, each row named on its left, on a
698
  white card. Text is sized for the card to be shown about 700 px wide. Returns an RGB uint8 array."""
699
  from PIL import Image, ImageDraw, ImageFont
@@ -708,7 +709,8 @@ def compose(pictures, title=""):
708
  pw = (w - 18) // 4
709
  left, gap = round(66 * k), round(8 * k)
710
  top = round(26 * k) + (round(30 * k) if title else 0)
711
- canvas = Image.new("RGB", (left + w + gap, top + 3 * h + 3 * gap), (255, 255, 255))
 
712
  d = ImageDraw.Draw(canvas)
713
  if title:
714
  d.text((left, round(6 * k)), title, fill=(35, 32, 28), font=bold)
@@ -718,6 +720,8 @@ def compose(pictures, title=""):
718
  y0 = top + i * (h + gap)
719
  canvas.paste(Image.fromarray(r), (left, y0))
720
  d.text((round(6 * k), y0 + h // 2 - round(8 * k)), name, fill=(93, 85, 75), font=font)
 
 
721
  return np.asarray(canvas)
722
 
723
 
 
690
  return np.concatenate(row, axis=1)
691
 
692
 
693
+ PANELS = ("CT", "cos", "grad_mag", "normal")
694
+ LEGEND = "normal as colour: x red, y green, z blue 路 villa lasagna, model output"
695
 
696
 
697
+ def compose(pictures, title="", note=LEGEND):
698
  """The three rows (z, y, x middle slices) under one header naming the panels, each row named on its left, on a
699
  white card. Text is sized for the card to be shown about 700 px wide. Returns an RGB uint8 array."""
700
  from PIL import Image, ImageDraw, ImageFont
 
709
  pw = (w - 18) // 4
710
  left, gap = round(66 * k), round(8 * k)
711
  top = round(26 * k) + (round(30 * k) if title else 0)
712
+ foot = round(26 * k) if note else 0
713
+ canvas = Image.new("RGB", (left + w + gap, top + 3 * h + 3 * gap + foot), (255, 255, 255))
714
  d = ImageDraw.Draw(canvas)
715
  if title:
716
  d.text((left, round(6 * k)), title, fill=(35, 32, 28), font=bold)
 
720
  y0 = top + i * (h + gap)
721
  canvas.paste(Image.fromarray(r), (left, y0))
722
  d.text((round(6 * k), y0 + h // 2 - round(8 * k)), name, fill=(93, 85, 75), font=font)
723
+ if note:
724
+ d.text((left, top + 3 * h + 2 * gap + round(4 * k)), note, fill=(93, 85, 75), font=font)
725
  return np.asarray(canvas)
726
 
727