Update app.py
Browse files1234456677891011121314151617111218192021222324252614272816172930313233import gradio as grimport pandas as pd
def topn_tokens(sequence, n):def topn_tokens(sequence, domain_bounds, n): example_dict = {} chars = list(sequence) n_column = [n] * len(chars) # Create a column with the chosen integer repeated df = pd.DataFrame({'Character': chars, 'N': n_column}) # Create the DataFrame 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( topn_tokens, [ fn=topn_tokens, inputs=[ "text", gr.Dataframe( headers=["start", "end"], datatype=["number", "number"], row_count=1, col_count=(2, "fixed"), ), gr.Dropdown([int(i) for i in range(1, 21)]), # Dropdown with numbers from 1 to 20 gr.Dropdown([str(i) for i in range(1, 21)]), # Dropdown with numbers from 1 to 20 ], "dataframe", description="Choose a number between 1-20 to display n tokens", 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__":app.py+21-8