Spaces:
Sleeping
Sleeping
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
#pip install gradio | |
# In[2]: | |
#pip install stylecloud==0.5.2 | |
# In[7]: | |
#pip show stylecloud | |
# In[8]: | |
#pip show icon_font_to_png | |
# In[26]: | |
import gradio as gr | |
import stylecloud | |
from PIL import Image | |
import os | |
# Fonksiyon tanımla | |
def create_stylecloud(file, language, icon): | |
# Dosya yolunu ve içerik türünü belirleyin | |
text = file.decode("utf-8") | |
output_file = 'stylecloud.png' # Çıktı dosyasının ismi | |
# Kelime bulutu oluştur | |
stylecloud.gen_stylecloud( | |
text=text, | |
icon_name=icon, | |
size=500, | |
output_name=output_file | |
) | |
return output_file | |
# Gradio arayüzünü oluştur | |
with gr.Blocks() as demo: | |
gr.Markdown('Kelime Bulutu Oluşturucu') | |
with gr.Row(): | |
file_input = gr.File(label="Metin dosyasını yükle", type='binary') | |
language = gr.Radio(choices=['TR', 'EN'], label='Dil Seçimi', value='TR') | |
icon = gr.Dropdown( | |
choices=[ | |
"fas fa-car", | |
"fas fa-star-and-crescent", | |
"fas fa-trophy", | |
"fas fa-heart", | |
"far fa-smile", | |
"fab fa-github", | |
"fas fa-pizza-slice", | |
"fas fa-tree", | |
"fas fa-music", | |
"fas fa-film", | |
"fas fa-coffee", | |
"fas fa-biking", | |
"fas fa-atom", | |
"fas fa-robot", | |
"fas fa-microchip", | |
"fas fa-plane", | |
"fas fa-mountain", | |
"fas fa-phone", | |
"fas fa-comments", | |
"fas fa-envelope", | |
"fas fa-heartbeat", | |
"fas fa-dumbbell", | |
"fas fa-ice-cream", | |
"fab fa-adn", | |
"fab fa-apple" | |
], | |
label='İkon seçimi', | |
value="fas fa-heart" | |
) | |
output_file = gr.File(label='Kelime Bulutunu İndir') | |
create_button = gr.Button('Oluştur') | |
# Butona basıldığında | |
create_button.click( | |
create_stylecloud, | |
inputs=[file_input, language, icon], | |
outputs=output_file | |
) | |
demo.launch(share=True) | |
# In[ ]: | |