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'Click here to download the upscaled image' 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()