arslannbilal commited on
Commit
f3cc45b
1 Parent(s): 0024e27

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import stylecloud
4
+
5
+ def create_stylecloud(text, language, icon, colors):
6
+ output_file = "stylecloud.png"
7
+
8
+ stylecloud.gen_stylecloud(text=text,
9
+ icon_name=icon,
10
+ output_name=output_file,
11
+ colors=colors)
12
+
13
+ return output_file
14
+
15
+ st.title("WordCloud Creator")
16
+
17
+ file = st.file_uploader("Import txt file", type=["txt"])
18
+
19
+ if file is not None:
20
+ text = file.getvalue().decode("utf-8")
21
+
22
+ language = st.radio("Language", ["tr", "en"])
23
+
24
+ icon_options = ["fas fa-car", "fas fa-star", "fas fa-trophy", "fas fa-heart", 'fas fa-wifi', 'fas fa-laptop', 'fas fa-coffee', 'fas fa-radio', 'fas fa-snowflake', 'fas fa-star-and-crescent']
25
+ icon = st.selectbox("Icon Selection", icon_options, index=9)
26
+
27
+ color_options = ["black", "white", "red", "blue", "green", "yellow", "orange", "purple" , "pink" , "brown"]
28
+ colors = st.multiselect("Color Selection", color_options, default=["black"])
29
+
30
+ if st.button("Create"):
31
+ output_file = create_stylecloud(text, language, icon, colors)
32
+ st.markdown(f"### [Download WordCloud](./{output_file})")
33
+
34
+ image = Image.open(output_file)
35
+ st.image(image, caption='WordCloud', use_column_width=True)