File size: 1,072 Bytes
be331b6
a0ba8b5
be331b6
1b1c116
 
a0ba8b5
1b1c116
 
 
 
 
 
 
 
a0ba8b5
 
be331b6
1b1c116
 
be331b6
1b1c116
 
 
d8c7623
1b1c116
 
 
be331b6
1b1c116
 
be331b6
 
 
a0ba8b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import pandas as pd

def topn_tokens(sequence, domain_bounds, n):
    example_dict = {}
    chars = list(sequence)
    start_index = domain_bounds['start'][0] - 1  
    end_index = domain_bounds['end'][0] - 1      

    for i in range(len(sequence)):
        if start_index <= i <= end_index:
            example_dict[chars[i]] = 'yo'
    
    df = pd.DataFrame(list(example_dict.items()), columns=['Original Residue', 'Predicted Residues'])
    return df

demo = gr.Interface(
    fn=topn_tokens,
    inputs=[
        "text",
        gr.Dataframe(
            headers=["start", "end"],
            datatype=["number", "number"],
            row_count=(1, "fixed"),
            col_count=(2, "fixed"),
        ),
        gr.Dropdown([str(i) for i in range(1, 21)]),  # Dropdown with numbers from 1 to 20
    ],
    outputs="dataframe",
    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).",
)

if __name__ == "__main__":
    demo.launch()