ras1992 commited on
Commit
034abd9
·
verified ·
1 Parent(s): 659bea4

Align logo with the text beneath it

Browse files
app.py CHANGED
@@ -916,14 +916,25 @@ preload_model()
916
 
917
 
918
  CSS = f"""
919
- .dm-header {{ margin: 2px 0 10px; }}
 
 
 
 
 
 
 
920
  .dm-tagline {{
921
- margin: 0;
922
  font-size: 15px;
923
  font-weight: 600;
924
  line-height: 1.35;
925
  }}
926
- .dm-intro p {{ max-width: 74ch; }}
 
 
 
 
927
  .dm-inline-action {{ align-self: flex-end; margin-bottom: 0; }}
928
  body, .gradio-container, .gradio-container * {{
929
  font-family: {FONT_STACK} !important;
@@ -946,40 +957,35 @@ BLOCKS_KWARGS = {} if _LAUNCH_ACCEPTS_THEME else {"theme": _THEME, "css": CSS}
946
 
947
 
948
  with gr.Blocks(title="DeepMutate-3D", **BLOCKS_KWARGS) as demo:
949
- # One header block, left-aligned to match every other element on the page.
950
- # The logo carries the wordmark, so it IS the heading rather than sitting
951
- # above a duplicate text title; wrapping it in an <h1> with alt text keeps
952
- # the document outline a screen reader expects while the name appears once
953
- # on screen. The tagline sits immediately beneath it on the same left edge,
954
- # so the two read as a single unit instead of two competing axes.
 
 
 
 
955
  if LOGO_DATA_URI:
956
  gr.HTML(
957
  '<div class="dm-header">'
958
- '<h1 style="margin:0 0 8px">'
959
- f'<img src="{LOGO_DATA_URI}" alt="DeepMutate-3D" '
960
- 'style="max-width:340px;width:100%;height:auto;display:block"></h1>'
961
  '<p class="dm-tagline">Protein language model mutation scanning, '
962
  "painted onto the AlphaFold fold.</p>"
 
963
  "</div>"
964
  )
965
  else:
966
- gr.Markdown(
967
- "# DeepMutate-3D\n"
968
- "**Protein language model mutation scanning, painted onto the "
969
- "AlphaFold fold.**"
 
 
 
970
  )
971
 
972
- # The explanation of how to read the colours is guidance, not identity, so
973
- # it is set below the header in muted body text rather than competing with
974
- # the tagline for emphasis.
975
- gr.Markdown(
976
- "ESM-2 scores every possible point mutation as a log-likelihood ratio "
977
- "against the wildtype residue. Positions the model refuses to change "
978
- "are evolutionarily constrained, likely structural or functional cores, "
979
- "and glow **red**. Positions it happily swaps glow **blue**.",
980
- elem_classes="dm-intro",
981
- )
982
-
983
  with gr.Row(equal_height=True):
984
  example_dropdown = gr.Dropdown(
985
  choices=list(EXAMPLE_PROTEINS.keys()),
 
916
 
917
 
918
  CSS = f"""
919
+ .dm-header {{ margin: 2px 0 14px; }}
920
+ .dm-header h1 {{ margin: 0 0 10px; }}
921
+ .dm-header h1 img {{
922
+ max-width: 340px;
923
+ width: 100%;
924
+ height: auto;
925
+ display: block;
926
+ }}
927
  .dm-tagline {{
928
+ margin: 0 0 10px;
929
  font-size: 15px;
930
  font-weight: 600;
931
  line-height: 1.35;
932
  }}
933
+ .dm-intro {{
934
+ margin: 0;
935
+ max-width: 74ch;
936
+ line-height: 1.55;
937
+ }}
938
  .dm-inline-action {{ align-self: flex-end; margin-bottom: 0; }}
939
  body, .gradio-container, .gradio-container * {{
940
  font-family: {FONT_STACK} !important;
 
957
 
958
 
959
  with gr.Blocks(title="DeepMutate-3D", **BLOCKS_KWARGS) as demo:
960
+ # Logo, tagline and intro live in ONE html block. Splitting them across a
961
+ # gr.HTML and a gr.Markdown gave each its own container padding, so the
962
+ # three lines started at three different left edges. One block, one edge.
963
+ intro = (
964
+ "ESM-2 scores every possible point mutation as a log-likelihood ratio "
965
+ "against the wildtype residue. Positions the model refuses to change "
966
+ "are evolutionarily constrained, likely structural or functional cores, "
967
+ "and glow <strong>red</strong>. Positions it happily swaps glow "
968
+ "<strong>blue</strong>."
969
+ )
970
  if LOGO_DATA_URI:
971
  gr.HTML(
972
  '<div class="dm-header">'
973
+ '<h1><img src="' + LOGO_DATA_URI + '" alt="DeepMutate-3D"></h1>'
 
 
974
  '<p class="dm-tagline">Protein language model mutation scanning, '
975
  "painted onto the AlphaFold fold.</p>"
976
+ f'<p class="dm-intro">{intro}</p>'
977
  "</div>"
978
  )
979
  else:
980
+ gr.HTML(
981
+ '<div class="dm-header">'
982
+ "<h1>DeepMutate-3D</h1>"
983
+ '<p class="dm-tagline">Protein language model mutation scanning, '
984
+ "painted onto the AlphaFold fold.</p>"
985
+ f'<p class="dm-intro">{intro}</p>'
986
+ "</div>"
987
  )
988
 
 
 
 
 
 
 
 
 
 
 
 
989
  with gr.Row(equal_height=True):
990
  example_dropdown = gr.Dropdown(
991
  choices=list(EXAMPLE_PROTEINS.keys()),
docs/assets/icon.png CHANGED

Git LFS Details

  • SHA256: c4032fa3b63da728f2d4ae0468e366097627478b485326bd9213815ba45d595d
  • Pointer size: 131 Bytes
  • Size of remote file: 335 kB

Git LFS Details

  • SHA256: 6e22c052c77365a59d20e4d7bf04a3a8262a037c32cbdcafa5322e843e0f65d5
  • Pointer size: 131 Bytes
  • Size of remote file: 448 kB
docs/assets/logo-banner.png CHANGED

Git LFS Details

  • SHA256: d35b676d5fcb5d75c41f9d0b1c8dc221565e1099f4c22b8971e6dfb71070f77f
  • Pointer size: 131 Bytes
  • Size of remote file: 277 kB

Git LFS Details

  • SHA256: d664628c777125fd292b6a24fda9f322d84517d990682938863cf9f10884c2fc
  • Pointer size: 131 Bytes
  • Size of remote file: 299 kB
docs/assets/logo-dark.png CHANGED

Git LFS Details

  • SHA256: 1bb03930bd747cfc74debda398851439403d64caddb24e6bc7532426a934d00e
  • Pointer size: 131 Bytes
  • Size of remote file: 203 kB

Git LFS Details

  • SHA256: 6eae017a2bcf5f49494f37b56304b1239168b6f1144f000142af1642b6fffe0c
  • Pointer size: 131 Bytes
  • Size of remote file: 206 kB
docs/assets/logo-header.png CHANGED

Git LFS Details

  • SHA256: ab111326e317e82e7712eeb63c3774cf17c5a93f434fb905392d4815018934e7
  • Pointer size: 131 Bytes
  • Size of remote file: 107 kB

Git LFS Details

  • SHA256: c52dbd6fc9796adea11628bcca52271bebfec51a22445b8ce86827f1897fed00
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
scripts/make_logo_assets.py CHANGED
@@ -33,8 +33,13 @@ HEADER_CSS_WIDTH = 340
33
  BANNER_CSS_WIDTH = 620
34
 
35
 
36
- def content_box(rgb: np.ndarray, background: np.ndarray, pad: int = 40) -> tuple:
37
- """Bounding box of everything meaningfully different from the backdrop."""
 
 
 
 
 
38
  diff = np.abs(rgb.astype(int) - background.astype(int)).sum(axis=2)
39
  ys, xs = np.where(diff > 30)
40
  h, w, _ = rgb.shape
@@ -79,9 +84,11 @@ def main() -> int:
79
  # The dark artwork sits on near-black, so brightness alone finds the content.
80
  lum = np.array(dark_src).sum(axis=2)
81
  ys, xs = np.where(lum > 120)
82
- dark = dark_src.crop((max(int(xs.min()) - 40, 0), max(int(ys.min()) - 40, 0),
83
- min(int(xs.max()) + 40, dark_src.width),
84
- min(int(ys.max()) + 40, dark_src.height)))
 
 
85
 
86
  written = []
87
  for name, img, width in [
 
33
  BANNER_CSS_WIDTH = 620
34
 
35
 
36
+ def content_box(rgb: np.ndarray, background: np.ndarray, pad: int = 0) -> tuple:
37
+ """Bounding box of everything meaningfully different from the backdrop.
38
+
39
+ `pad` defaults to 0 deliberately. Padding baked into a transparent asset is
40
+ invisible but still occupies layout width, which indents the artwork
41
+ relative to the text beneath it.
42
+ """
43
  diff = np.abs(rgb.astype(int) - background.astype(int)).sum(axis=2)
44
  ys, xs = np.where(diff > 30)
45
  h, w, _ = rgb.shape
 
84
  # The dark artwork sits on near-black, so brightness alone finds the content.
85
  lum = np.array(dark_src).sum(axis=2)
86
  ys, xs = np.where(lum > 120)
87
+ # The dark variant keeps a small margin: its backdrop is opaque, so the
88
+ # padding reads as part of the panel rather than as dead space.
89
+ dark = dark_src.crop((max(int(xs.min()) - 30, 0), max(int(ys.min()) - 30, 0),
90
+ min(int(xs.max()) + 30, dark_src.width),
91
+ min(int(ys.max()) + 30, dark_src.height)))
92
 
93
  written = []
94
  for name, img, width in [