Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
|
4 |
-
def topn_tokens(sequence, n):
|
|
|
5 |
chars = list(sequence)
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
return df
|
9 |
|
10 |
demo = gr.Interface(
|
11 |
-
topn_tokens,
|
12 |
-
[
|
13 |
"text",
|
14 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
],
|
16 |
-
"dataframe",
|
17 |
-
description="Choose a number between 1-20 to
|
18 |
)
|
19 |
|
20 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
|
4 |
+
def topn_tokens(sequence, domain_bounds, n):
|
5 |
+
example_dict = {}
|
6 |
chars = list(sequence)
|
7 |
+
start_index = domain_bounds['start'][0] - 1
|
8 |
+
end_index = domain_bounds['end'][0] - 1
|
9 |
+
|
10 |
+
for i in range(len(sequence)):
|
11 |
+
if start_index <= i <= end_index:
|
12 |
+
example_dict[chars[i]] = 'yo'
|
13 |
+
|
14 |
+
df = pd.DataFrame(list(example_dict.items()), columns=['Original Residue', 'Predicted Residues'])
|
15 |
return df
|
16 |
|
17 |
demo = gr.Interface(
|
18 |
+
fn=topn_tokens,
|
19 |
+
inputs=[
|
20 |
"text",
|
21 |
+
gr.Dataframe(
|
22 |
+
headers=["start", "end"],
|
23 |
+
datatype=["number", "number"],
|
24 |
+
row_count=1,
|
25 |
+
col_count=(2, "fixed"),
|
26 |
+
),
|
27 |
+
gr.Dropdown([str(i) for i in range(1, 21)]), # Dropdown with numbers from 1 to 20
|
28 |
],
|
29 |
+
outputs="dataframe",
|
30 |
+
description="Choose a number between 1-20 to predict n tokens for each position. Choose the start and end index of the domain of interest (indexing starts at 1).",
|
31 |
)
|
32 |
|
33 |
if __name__ == "__main__":
|