linyi910256 commited on
Commit
66ed124
1 Parent(s): 9206df4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -1,11 +1,8 @@
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)
@@ -13,7 +10,6 @@ def generate_wordcloud(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,
@@ -24,4 +20,5 @@ iface = gr.Interface(
24
  )
25
 
26
  # 启动界面
27
- iface.launch()
 
 
 
 
 
 
 
 
1
  from wordcloud import WordCloud
2
  import numpy as np
3
+ import gradio as gr
4
+
5
+ font_path = '猫啃网风雅宋.ttf' # 确保这个文件名与你上传的文件名匹配
6
 
7
  def generate_wordcloud(text):
8
  wc = WordCloud(width=800, height=400, background_color='white', font_path=font_path)
 
10
  image = wc.to_image()
11
  image = np.array(image)
12
  return image
 
13
 
14
  iface = gr.Interface(
15
  fn=generate_wordcloud,
 
20
  )
21
 
22
  # 启动界面
23
+ if __name__ == "__main__":
24
+ iface.launch()