Update app.py
Browse files1234567891011121314151617181920import gradio as grimport pandas as pddef topn_tokens(sequence, n):chars = list(sequence)n_column = [n] * len(chars) # Create a column with the chosen integer repeateddf = pd.DataFrame({'Character': chars, 'N': n_column}) # Create the DataFramereturn dfdemo = gr.Interface(topn_tokens,["text",gr.Dropdown([int(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",)if __name__ == "__main__":123456789101112131415161718192021222324252627282930313233import gradio as grimport pandas as pddef topn_tokens(sequence, domain_bounds, n):example_dict = {}chars = list(sequence)start_index = domain_bounds['start'][0] - 1end_index = domain_bounds['end'][0] - 1for 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 dfdemo = gr.Interface(fn=topn_tokens,inputs=["text",gr.Dataframe(headers=["start", "end"],datatype=["number", "number"],row_count=1,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__":
app.py+21-8