VisionGPT / app.py
Singularity666's picture
Update app.py
c844544
raw
history blame
906 Bytes
import streamlit as st
from main import upscale_image
import base64
def get_image_download_link(img_path, filename="upscaled_image.png"):
with open(img_path, 'rb') as f:
bytes = f.read()
b64 = base64.b64encode(bytes).decode()
href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{filename}\'>Click here to download the upscaled image</a>'
return href
def app():
uploaded_file = st.file_uploader("Choose an image...", type="png")
if uploaded_file is not None:
with open("uploaded.png", "wb") as f:
f.write(uploaded_file.getvalue())
upscale_image("uploaded.png") # This will create "upscaled.png"
st.image("upscaled.png", caption="Upscaled Image", use_column_width=True)
st.markdown(get_image_download_link("upscaled.png"), unsafe_allow_html=True)
if __name__ == "__main__":
app()