animena3264 commited on
Commit
829b405
·
verified ·
1 Parent(s): 9bc6dd2

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +43 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from super_image import EdsrModel, ImageLoader
3
+ from PIL import Image
4
+ import cv2
5
+
6
+ st.title('Take your picture to the next level')
7
+
8
+
9
+ col1, col2 = st.columns([3, 1])
10
+ preds = None
11
+
12
+ with col2:
13
+ choice = st.selectbox('Scale to', [2, 3, 4])
14
+ model_choice = st.selectbox('Model', ['EDSR', 'PAN', 'CARN'])
15
+
16
+ with col1:
17
+ file = st.file_uploader('Post your picture', type=['png', 'jpeg'])
18
+ if file is not None:
19
+ image = Image.open(file)
20
+
21
+ col1, col2 = st.columns(2)
22
+ with col1:
23
+ st.subheader('Input image')
24
+ st.image(image)
25
+
26
+ if model_choice == "EDSR":
27
+
28
+ model = EdsrModel.from_pretrained("eugenesiow/edsr-base", scale=int(choice))
29
+ inputs = ImageLoader.load_image(image)
30
+ preds = model(inputs)
31
+
32
+ ImageLoader.save_image(preds, './scaled_2x.png')
33
+ img = Image.open('./scaled_2x.png')
34
+ with col2:
35
+ st.subheader('New image')
36
+ st.image(img, caption=f'Upscaled {choice} times image')
37
+
38
+ with open('./scaled_2x.png', 'rb') as f:
39
+ st.download_button(label="Download image", data=f, file_name="upscaled.png", mime="image/png")
40
+
41
+ else:
42
+ st.text('Not supported yet. Comeback soon for fun releases')
43
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ super-image
2
+ pillow
3
+ transformers
4
+ datasets