File size: 798 Bytes
5c07633 a86b4a9 5c07633 a86b4a9 5c07633 07566a3 5c07633 36f96e0 5c07633 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# Step 2: Import libraries
import gradio as gr
from wordcloud import WordCloud
import matplotlib.pyplot as plt
# Step 3: Define the word cloud generator function
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"
# Step 4: Set up the Gradio interface
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"
)
# Step 5: Launch the interface in Colab
iface.launch(share=True)
|