Update app.py
Browse files1234456789567891011121314141516171819202121import gradio as grimport pandas as pd
def topn_tokens(sequence, n): chars = [] for char in sequence: chars.append(char) return chars 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 return df
demo = gr.Interface( topn_tokens, [ "text", gr.Dropdown(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]), 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__": demo.launch() demo.launch()app.py+8-8