File size: 1,330 Bytes
70d7fb2
2ec19ea
 
6afed95
70d7fb2
 
 
581ddb4
70d7fb2
6dd0277
70d7fb2
c5b1dc0
 
 
 
70d7fb2
82e08d5
2ec19ea
485af7c
3a11649
 
 
018107d
3a11649
6dd0277
c5b1dc0
 
018107d
8c55095
 
0d5cc5c
6afed95
8477de0
3a11649
 
 
 
 
 
8c55095
c5b1dc0
 
a4aeff4
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
import streamlit as st
from super_image import EdsrModel, ImageLoader
from PIL import Image
import cv2

st.title('Take your picture to the next level')


col1, col2 = st.columns([3, 1])
preds = None

with col2:
    choice = st.selectbox('Scale to', [2, 3, 4])
    model_choice = st.selectbox('Model', ['EDSR', 'PAN', 'CARN'])

with col1:
    file = st.file_uploader('Post your picture', type=['png', 'jpeg'])
    if file is not None:
        image = Image.open(file)

        col1, col2 = st.columns(2)
        with col1:
            st.subheader('Input image')
            st.image(image)

        if model_choice == "EDSR":

            model = EdsrModel.from_pretrained("eugenesiow/edsr-base", scale=int(choice))
            inputs = ImageLoader.load_image(image)
            preds = model(inputs)

            ImageLoader.save_image(preds, './scaled_2x.png')
            img = Image.open('./scaled_2x.png')
            with col2:
                st.subheader('New image')
                st.image(img, caption=f'Upscaled {choice} times image')
    
                with open('./scaled_2x.png', 'rb') as f:
                    st.download_button(label="Download image", data=f, file_name="upscaled.png", mime="image/png")
            
        else:
            st.text('Not supported yet. Comeback soon for fun releases')