unikei commited on
Commit
531dcfc
1 Parent(s): ff1487e

Wrap and truncate text in dataframe

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,25 +1,31 @@
1
  import gradio as gr
2
  import pandas as pd
3
 
4
- text = "This app displays protein similarity captured in the model " \
5
- "[unikei/bert-base-proteins](https://huggingface.co/unikei/bert-base-proteins)."
6
-
7
  image_path = "data/protein_dendrogram.png"
8
 
9
  protein_clusters = pd.read_excel('data/protein_clusters.xlsx')
 
 
 
 
 
10
 
11
  with gr.Blocks() as demo:
12
  gr.Markdown("# Protein similarity from BERT point of view")
13
- gr.Markdown(text)
 
14
 
15
  gr.Image(image_path,
16
  label="Right click to zoom in new tab.",
17
  container=True
18
  )
19
 
 
 
20
  gr.DataFrame(protein_clusters,
21
- interactive=True,
22
- wrap=False,
23
  column_widths=[5, 5, 30, 30, 30])
 
24
 
25
  demo.launch()
 
1
  import gradio as gr
2
  import pandas as pd
3
 
 
 
 
4
  image_path = "data/protein_dendrogram.png"
5
 
6
  protein_clusters = pd.read_excel('data/protein_clusters.xlsx')
7
+ max_length = 500
8
+ protein_clusters['proteins'] = protein_clusters['proteins'].apply(lambda x: x[:max_length] + ('...' if len(x) > max_length else ''))
9
+ protein_clusters['protein groups'] = protein_clusters['protein groups'].apply(lambda x: x[:max_length] + ('...' if len(x) > max_length else ''))
10
+ protein_clusters['protein features'] = protein_clusters['protein features'].apply(lambda x: x[:max_length] + ('...' if len(x) > max_length else ''))
11
+
12
 
13
  with gr.Blocks() as demo:
14
  gr.Markdown("# Protein similarity from BERT point of view")
15
+ gr.Markdown("This app displays protein similarity captured in the model [unikei/bert-base-proteins]("
16
+ "https://huggingface.co/unikei/bert-base-proteins).")
17
 
18
  gr.Image(image_path,
19
  label="Right click to zoom in new tab.",
20
  container=True
21
  )
22
 
23
+ gr.Markdown("\n")
24
+ gr.Markdown("Click on the [link](https://huggingface.co/spaces/unikei/proteins-from-bert-point-of-view/blob/main/data/protein_clusters.xlsx) to download the spreadsheet.")
25
  gr.DataFrame(protein_clusters,
26
+ interactive=False,
27
+ wrap=True,
28
  column_widths=[5, 5, 30, 30, 30])
29
+ #
30
 
31
  demo.launch()