|
|
|
import gradio as gr |
|
from wordcloud import WordCloud |
|
import matplotlib.pyplot as plt |
|
|
|
|
|
def generate_word_cloud(text): |
|
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text) |
|
plt.figure(figsize=(10, 5)) |
|
plt.imshow(wordcloud, interpolation='bilinear') |
|
plt.axis('off') |
|
plt.savefig("wordcloud.png") |
|
return "wordcloud.png" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_word_cloud, |
|
inputs=gr.components.Textbox(lines=10, placeholder="Enter text here..."), |
|
outputs="image", |
|
title="Word Cloud Generator", |
|
description="Generate a word cloud from the input text" |
|
) |
|
|
|
|
|
iface.launch(share=True) |
|
|