File size: 1,254 Bytes
1b4c9a8
 
 
 
 
7d8e7ad
1b4c9a8
 
 
 
 
 
8416746
abcebf2
1b4c9a8
 
 
 
30bada8
1b4c9a8
 
 
0ca458a
 
1b4c9a8
 
 
 
 
 
 
 
 
abcebf2
1b4c9a8
 
 
 
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
import os
from ulti import *
import threading
import pipeline
import streamlit as st
from PIL import Image


def main():
    st.set_page_config(layout="wide")

    st.image(os.path.join('Images','Banner No2.png'), use_column_width  = True)
    st.markdown("<h1 style='text-align: center; color: black;'>Writing Vietnamese poem from image</h1>", unsafe_allow_html=True)
    
    choice = 'Image Based'
    
    # Create the Home page
    if choice == 'Image Based':
        img_file_buffer = st.file_uploader('Upload your image here',type=['jpg','jpeg','png'])
        if img_file_buffer is not None:
            from PIL import Image
            col1, col2 = st.columns(2)
            image = Image.open(img_file_buffer).convert("RGB")
            #image = np.array(image)
            # image = adjust_gamma(image, gamma=gamma)
            with col1:
                st.image(image)

            poem = pipeline.main(image)
            print(poem)
            poem = poem.split(' [SEP] ')[-1].replace('\n', '<br />')

            with col2:
                st.markdown("<h4 style='text-align: center; color: black; line-height: 2;'>" + poem + "</h4>", unsafe_allow_html=True)


if __name__ == '__main__':
    main()