upscaler / app.py
analist's picture
Update app.py
6afed95
raw
history blame
No virus
1.06 kB
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')
if file is not None:
image = Image.open(file)
st.image(image)
if model_choice == "EDSR":
model = EdsrModel.from_pretrained("eugenesiow/edsr-base", scale=2)
inputs = ImageLoader.load_image(image)
preds = model(inputs)
ImageLoader.save_image(preds, './scaled_2x.png')
img = cv2.imread('./scaled_2x.png')
st.subheader('New image')
st.image(img, caption=f'Upscaled {choice} times image')
st.download_button('Download', img)
else:
st.text('Not supported yet. Comeback soon for fun releases')