Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,76 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import stylecloud
|
3 |
-
from PIL import Image
|
4 |
-
import os
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import stylecloud
|
3 |
+
from PIL import Image
|
4 |
+
import os
|
5 |
+
|
6 |
+
#fonksiyon tanımla
|
7 |
+
def create_stylecloud(file,language,icon):
|
8 |
+
# Dosya yolunu ve içerik türünü belirleyin
|
9 |
+
#icon kodları ve daha fazlası için ==>> https://fontawesome.com/icons
|
10 |
+
text=file.decode("utf-8")
|
11 |
+
output_file='stylecloud.png' # Çıktı dosyasının ismi
|
12 |
+
|
13 |
+
#Kelime bulutunu oluştur
|
14 |
+
stylecloud.gen_stylecloud(
|
15 |
+
text=text,
|
16 |
+
icon_name=icon,
|
17 |
+
size=500,
|
18 |
+
output_name=output_file,
|
19 |
+
)
|
20 |
+
|
21 |
+
#oluşturulan kelime bulutunun dosya adı
|
22 |
+
return output_file
|
23 |
+
'''
|
24 |
+
Extra paretmetreler
|
25 |
+
palette="cartocolors.qualitative.Bold_10",
|
26 |
+
gradient="horizontal",
|
27 |
+
background_color="white",
|
28 |
+
collocations=False
|
29 |
+
'''
|
30 |
+
#Gradio arayüzünü oluşturma
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
gr.Markdown('Kelime Bulutu Oluşturucu')
|
33 |
+
with gr.Row():
|
34 |
+
file_input=gr.File(label='Metin dosyasını yükle', type='binary')
|
35 |
+
language=gr.Radio(choices=['TR', 'EN'],label='Dil Seçimi', value='TR')
|
36 |
+
icon = gr.Dropdown(
|
37 |
+
choices=[
|
38 |
+
"fas fa-car",
|
39 |
+
"fas fa-star-and-crescent",
|
40 |
+
"fas fa-trophy",
|
41 |
+
"fas fa-heart",
|
42 |
+
"far fa-smile",
|
43 |
+
"fab fa-github",
|
44 |
+
"fas fa-pizza-slice",
|
45 |
+
"fas fa-tree",
|
46 |
+
"fas fa-music",
|
47 |
+
"fas fa-film",
|
48 |
+
"fas fa-coffee",
|
49 |
+
"fas fa-biking",
|
50 |
+
"fas fa-atom",
|
51 |
+
"fas fa-robot",
|
52 |
+
"fas fa-microchip",
|
53 |
+
"fas fa-plane",
|
54 |
+
"fas fa-mountain",
|
55 |
+
"fas fa-phone",
|
56 |
+
"fas fa-comments",
|
57 |
+
"fas fa-envelope",
|
58 |
+
"fas fa-heartbeat",
|
59 |
+
"fas fa-dumbbell",
|
60 |
+
"fas fa-ice-cream",
|
61 |
+
"fab fa-adn",
|
62 |
+
"fab fa-apple"
|
63 |
+
|
64 |
+
],
|
65 |
+
label='İkon seçimi',
|
66 |
+
value="fas fa-car")
|
67 |
+
output_file=gr.File(label='Kelime Bulutunu İndir')
|
68 |
+
create_button=gr.Button('Oluştur')
|
69 |
+
|
70 |
+
#butona basıldığında
|
71 |
+
create_button.click(
|
72 |
+
create_stylecloud,
|
73 |
+
inputs=[file_input,language,icon],
|
74 |
+
outputs=output_file
|
75 |
+
)
|
76 |
+
demo.launch(share=True) #share=True public link verir
|