Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[1]:
|
5 |
+
|
6 |
+
|
7 |
+
#pip install gradio
|
8 |
+
|
9 |
+
|
10 |
+
# In[2]:
|
11 |
+
|
12 |
+
|
13 |
+
#pip install stylecloud==0.5.2
|
14 |
+
|
15 |
+
|
16 |
+
# In[7]:
|
17 |
+
|
18 |
+
|
19 |
+
#pip show stylecloud
|
20 |
+
|
21 |
+
|
22 |
+
# In[8]:
|
23 |
+
|
24 |
+
|
25 |
+
#pip show icon_font_to_png
|
26 |
+
|
27 |
+
|
28 |
+
# In[26]:
|
29 |
+
|
30 |
+
|
31 |
+
import gradio as gr
|
32 |
+
import stylecloud
|
33 |
+
from PIL import Image
|
34 |
+
import os
|
35 |
+
|
36 |
+
# Fonksiyon tanımla
|
37 |
+
def create_stylecloud(file, language, icon):
|
38 |
+
# Dosya yolunu ve içerik türünü belirleyin
|
39 |
+
text = file.decode("utf-8")
|
40 |
+
output_file = 'stylecloud.png' # Çıktı dosyasının ismi
|
41 |
+
|
42 |
+
# Kelime bulutu oluştur
|
43 |
+
stylecloud.gen_stylecloud(
|
44 |
+
text=text,
|
45 |
+
icon_name=icon,
|
46 |
+
size=500,
|
47 |
+
output_name=output_file
|
48 |
+
)
|
49 |
+
return output_file
|
50 |
+
|
51 |
+
# Gradio arayüzünü oluştur
|
52 |
+
with gr.Blocks() as demo:
|
53 |
+
gr.Markdown('Kelime Bulutu Oluşturucu')
|
54 |
+
with gr.Row():
|
55 |
+
file_input = gr.File(label="Metin dosyasını yükle", type='binary')
|
56 |
+
language = gr.Radio(choices=['TR', 'EN'], label='Dil Seçimi', value='TR')
|
57 |
+
icon = gr.Dropdown(
|
58 |
+
choices=[
|
59 |
+
"fas fa-car",
|
60 |
+
"fas fa-star-and-crescent",
|
61 |
+
"fas fa-trophy",
|
62 |
+
"fas fa-heart",
|
63 |
+
"far fa-smile",
|
64 |
+
"fab fa-github",
|
65 |
+
"fas fa-pizza-slice",
|
66 |
+
"fas fa-tree",
|
67 |
+
"fas fa-music",
|
68 |
+
"fas fa-film",
|
69 |
+
"fas fa-coffee",
|
70 |
+
"fas fa-biking",
|
71 |
+
"fas fa-atom",
|
72 |
+
"fas fa-robot",
|
73 |
+
"fas fa-microchip",
|
74 |
+
"fas fa-plane",
|
75 |
+
"fas fa-mountain",
|
76 |
+
"fas fa-phone",
|
77 |
+
"fas fa-comments",
|
78 |
+
"fas fa-envelope",
|
79 |
+
"fas fa-heartbeat",
|
80 |
+
"fas fa-dumbbell"
|
81 |
+
|
82 |
+
|
83 |
+
],
|
84 |
+
label='İkon seçimi',
|
85 |
+
value="fas fa-heart"
|
86 |
+
)
|
87 |
+
output_file = gr.File(label='Kelime Bulutunu İndir')
|
88 |
+
create_button = gr.Button('Oluştur')
|
89 |
+
|
90 |
+
# Butona basıldığında
|
91 |
+
create_button.click(
|
92 |
+
create_stylecloud,
|
93 |
+
inputs=[file_input, language, icon],
|
94 |
+
outputs=output_file
|
95 |
+
)
|
96 |
+
demo.launch(share=True)
|
97 |
+
|
98 |
+
|
99 |
+
# In[ ]:
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
|