Spaces:
Sleeping
Sleeping
File size: 1,698 Bytes
508a85d 9106bc2 508a85d |
1 2 3 4 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# -*- coding: utf-8 -*-
"""gradio_code.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1tV8K1B35gpDCX7ocofxoEbvEa93-YKaD
"""
#pip install gradio
#pip install stylecloud==0.5.2
# pip install Pillow==9.4.0
import gradio as gr
import stylecloud
from PIL import Image
import os
# fonksiyon tanımla
def create_stylecloud(file,language,icon):
text = file.decode("utf-8")
output_file='stylecloud.png'
stylecloud.gen_stylecloud(
text = text,
icon_name = icon,
size = 500,
output_name = output_file,
)
# oluşturulan kelime bulutunun dosya adı
return output_file
'''
EKSTRA PARAMETRELER
palette = 'cartocolors.qualitative.Bold_10',
gradient = "horizontal",
background_color = "white",
collocations = False
'''
# Gradio ile arayüzü 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-star-and-crescent", "fas fa-trophy", 'fas fa-laptop', "fas fa-heart", "fas fa-car",'fas fa-wifi'],
label='İkon seçimi',value="fas fa-heart")
create_button = gr.Button('Kelime Bulutu Oluştur')
output_file = gr.File(label='Kelime Bulutunu İndir')
# butona basıldığında
create_button.click(
create_stylecloud,
inputs=[file_input,language,icon],
outputs = output_file
)
demo.launch(share=True) # share = True public link verir. |