File size: 2,039 Bytes
844e1a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
77
from HelperFunctions import *
import streamlit as st
from PIL import Image
import io

def Generate_image(text):
    # Dummy implementation for illustration
    # Replace this with your actual image generation model
    embeddings = Tokenize(text)
    tensor = generate_images(embeddings)
    tensor = tensor.squeeze().permute(1, 2, 0)
    # img = Image.new('RGB', (200, 100), color = (73, 109, 137))
    tensor = (tensor * 255).clamp(0, 255).byte()  # Scale to [0, 255] and convert to byte
    array = tensor.cpu().numpy()  # Convert to NumPy array
    return Image.fromarray(array)

    return img

st.markdown(
    """
    <style>
    @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
    
    .custom-text-input > div > input {
        font-size: 25px !important;
        height: 50px !important;
        font-family: 'Roboto', sans-serif;
    }
    .custom-label {
        font-size: 25px !important;
        font-weight: bold;
        font-family: 'Roboto', sans-serif;
    }
    </style>
    """,
    unsafe_allow_html=True,
)

st.title("Pokémon Image Generator")

st.markdown('<div class="custom-label">Enter a sentence:</div>', unsafe_allow_html=True)
input_text = st.text_input("", key='input', help='Type your sentence here', label_visibility='collapsed')


st.markdown(
    """
    <style>
    .custom-text-input {
        display: flex;
        flex-direction: column;
    }
    .custom-text-input label {
        font-size: 20px;
    }
    .custom-text-input > div > input {
        font-size: 20px !important;
        height: 50px !important;
    }
    </style>
    """,
    unsafe_allow_html=True,
)

if st.button("Generate Image"):
    if input_text:
        generated_image = Generate_image(input_text)
        
        img_bytes = io.BytesIO()
        generated_image.save(img_bytes, format='PNG')
        img_bytes.seek(0)
        
        st.image(img_bytes, caption="Generated Image", use_column_width=True)
    
    else:
        st.error("Please enter a sentence.")