import gradio as gr description1 = "

Demo EmotioNL

\nThis demo allows you to analyse the emotion in a sentence." description2 = "

Demo EmotioNL

\nThis demo allows you to analyse the emotions in a dataset." def what_happened(text, file_object, option_list): if file_object: output = "You uploaded a file." if len(option_list) > 0: output = output + "\nYou selected these options:\n- " + "\n- ".join(option_list) else: output = "Normally, this demo should analyse the emotions in this text:\n" + text if len(option_list) > 0: output = output + "\nYou can only select options when uploading a dataset." return output def what_happened1(text): output = "Normally, this demo should analyse the emotions in this text:\n" + text return output def what_happened2(file_object, option_list): if file_object: output = "You uploaded a file." if len(option_list) > 0: output = output + "\nYou selected these options:\n- " + "\n- ".join(option_list) else: output = "You should upload a file." return output iface0 = gr.Interface( fn=what_happened, inputs=[ gr.Textbox( label= "Enter a sentence", lines=1, value="Your name"), gr.File( label="Or upload a dataset"), gr.CheckboxGroup( ["emotion frequencies", "emotion distribution over time", "peaks", "topics"], label = "Select options") ], outputs="text") iface1 = gr.Interface( fn=what_happened1, description = description1, inputs = gr.Textbox( label= "Enter a sentence", lines=1, value="Your name"), outputs="text") iface2 = gr.Interface( fn=what_happened2, description = description2, inputs=[ gr.File( label="Upload a dataset"), gr.CheckboxGroup( ["emotion frequencies", "emotion distribution over time", "peaks", "topics"], label = "Select options") ], outputs="text") iface = gr.TabbedInterface([iface1, iface2], ["Sentence", "Dataset"]) iface.launch()