-
Notifications
You must be signed in to change notification settings - Fork 0
/
decompression.py
33 lines (25 loc) · 982 Bytes
/
decompression.py
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
import streamlit as st
from pathlib import Path
from model.model import decompress
from PIL import Image
import matplotlib.pyplot as plt
import torch
def decompression():
st.markdown('### Decompression')
uploaded_file = st.file_uploader("Choose file: ", accept_multiple_files=False, key='decompression')
if uploaded_file:
if uploaded_file.type == 'application/octet-stream':
img_path = decompress(uploaded_file)
img = Image.open(img_path)
st.image(img)
@st.fragment
def download():
with open(img_path, "rb") as file:
btn = st.download_button(
label="Download image",
data=file,
file_name=Path(img_path).name,
mime="application/octet-stream",
key='decomp-image'
)
download()