import pandas as pd from wordcloud_fa import WordCloudFa import gradio as gr data = pd.read_csv('shereno.csv') poets_list = data.Poet.unique().tolist() def get_wc(poet:str): poems = data.loc[data.Poet == poet] poems_txt = ' '.join(poems.Poem.tolist()) wc = WordCloudFa(persian_normalize=True, no_reshape=True, background_color="white", width=1000, height=500) word_cloud = wc.generate(poems_txt) image = word_cloud.to_image() return image iface = gr.Interface(fn=get_wc, inputs = gr.inputs.Dropdown(choices = poets_list, type="value", default='نیما یوشیج', label='Poet'), outputs= gr.outputs.Image(type="auto", label='Word Cloud'), layout= 'horizontal', title='Persian Modernist Poetry Word Cloud', description="You can select a poet from a list of 40 Persian modernist poets to see a word cloud of their poems.", theme='huggingface', allow_flagging='never') iface.launch()