File size: 2,415 Bytes
32c9194
 
 
 
 
94c8a6c
32c9194
 
94c8a6c
32c9194
 
 
94c8a6c
32c9194
 
 
 
 
 
 
7dd7aac
32c9194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
    # İcon kodları ve daha fazlası için ==>> https://fontawesome.com/icons
    text=file.decode("utf-8")
    output_file='stylecloud.png'  # Çıktı dosyasının ismi
    
    # Kelime bulutunu oluştur
    stylecloud.gen_stylecloud(
        text=text,
        icon_name=icon,
        size=500,
        output_name=output_file,
    )
    
    # Oluşturulan kelime bulutunun dosya adı (Görüntüyü Getir)
    return output_file
'''
Extra paretmetreler
 palette="cartocolors.qualitative.Bold_10",
        gradient="horizontal",
        background_color="white",
        collocations=False
'''
#Gradio arayüzünü oluşturma
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-car")
        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) #share=True public link verir