Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +61 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""gradio_code.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1tV8K1B35gpDCX7ocofxoEbvEa93-YKaD
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
#pip install gradio
|
| 11 |
+
|
| 12 |
+
#pip install stylecloud==0.5.2
|
| 13 |
+
|
| 14 |
+
# pip install Pillow==9.4.0
|
| 15 |
+
|
| 16 |
+
import gradio as gr
|
| 17 |
+
import stylecloud
|
| 18 |
+
from PIL import Image
|
| 19 |
+
import os
|
| 20 |
+
|
| 21 |
+
# fonksiyon tanımla
|
| 22 |
+
def create_stylecloud(file,language,icon):
|
| 23 |
+
text = file.decode("utf-8")
|
| 24 |
+
output_file='stylecloud.png'
|
| 25 |
+
stylecloud.gen_stylecloud(
|
| 26 |
+
text = text,
|
| 27 |
+
icon_name = icon,
|
| 28 |
+
output_name = output_file,
|
| 29 |
+
)
|
| 30 |
+
# oluşturulan kelime bulutunun dosya adı
|
| 31 |
+
return output_file
|
| 32 |
+
|
| 33 |
+
'''
|
| 34 |
+
EKSTRA PARAMETRELER
|
| 35 |
+
size = 500, # size belirtilebilir.
|
| 36 |
+
palette = 'cartocolors.qualitative.Bold_10',
|
| 37 |
+
gradient = "horizontal",
|
| 38 |
+
background_color = "white",
|
| 39 |
+
collocations = False
|
| 40 |
+
'''
|
| 41 |
+
|
| 42 |
+
# Gradio ile arayüzü oluştur
|
| 43 |
+
with gr.Blocks() as demo:
|
| 44 |
+
gr.Markdown('Kelime Bulutu Oluşturucu')
|
| 45 |
+
|
| 46 |
+
with gr.Row():
|
| 47 |
+
file_input = gr.File(label='Metin Dosyasını Yükle', type='binary')
|
| 48 |
+
language = gr.Radio(choices=['TR','EN'],label='Dil Seçimi',value='TR')
|
| 49 |
+
icon = gr.Dropdown(choices=["fas fa-star-and-crescent", "fas fa-trophy", 'fas fa-laptop', "fas fa-heart", "fas fa-car",'fas fa-wifi'],
|
| 50 |
+
label='İkon seçimi',value="fas fa-heart")
|
| 51 |
+
create_button = gr.Button('Kelime Bulutu Oluştur')
|
| 52 |
+
output_file = gr.File(label='Kelime Bulutunu İndir')
|
| 53 |
+
|
| 54 |
+
# butona basıldığında
|
| 55 |
+
create_button.click(
|
| 56 |
+
create_stylecloud,
|
| 57 |
+
inputs=[file_input,language,icon],
|
| 58 |
+
outputs = output_file
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
demo.launch(share=True) # share = True public link verir.
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
stylecloud==0.5.2
|
| 3 |
+
pillow==9.4.0
|