linyi910256 commited on
Commit
9206df4
1 Parent(s): 680922e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -1,27 +1,27 @@
1
- !pip install wordcloud matplotlib
2
- !pip install wordcloud matplotlib gradio
3
- !pip install gradio --upgrade
4
- from google.colab import files
5
- files.upload()
6
- font_path = '猫啃网风雅宋.ttf' # 确保这个文件名与你上传的文件名匹配
7
- from wordcloud import WordCloud
8
- import numpy as np
9
-
10
- def generate_wordcloud(text):
11
- wc = WordCloud(width=800, height=400, background_color='white', font_path=font_path)
12
- wc.generate(text)
13
- image = wc.to_image()
14
- image = np.array(image)
15
- return image
16
- import gradio as gr
17
-
18
- iface = gr.Interface(
19
- fn=generate_wordcloud,
20
- inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
21
- outputs="image",
22
- title="Word Cloud Generator",
23
- description="Enter text to generate a word cloud."
24
- )
25
-
26
- # 启动界面
27
  iface.launch()
 
1
+ pip install wordcloud matplotlib
2
+ pip install wordcloud matplotlib gradio
3
+ pip install gradio --upgrade
4
+ from google.colab import files
5
+ files.upload()
6
+ font_path = '猫啃网风雅宋.ttf' # 确保这个文件名与你上传的文件名匹配
7
+ from wordcloud import WordCloud
8
+ import numpy as np
9
+
10
+ def generate_wordcloud(text):
11
+ wc = WordCloud(width=800, height=400, background_color='white', font_path=font_path)
12
+ wc.generate(text)
13
+ image = wc.to_image()
14
+ image = np.array(image)
15
+ return image
16
+ import gradio as gr
17
+
18
+ iface = gr.Interface(
19
+ fn=generate_wordcloud,
20
+ inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
21
+ outputs="image",
22
+ title="Word Cloud Generator",
23
+ description="Enter text to generate a word cloud."
24
+ )
25
+
26
+ # 启动界面
27
  iface.launch()