Here's the code:
def main():
st.title("Image Restoration")
#define states of the app
colorizationPage = "Image Colorization"
inpaintingPage = "Image Inpainting"
enhancementPage = "Image Enhacement"
denoisingPage = "Image Denoising"
appMode = st.sidebar.selectbox(
"Choose the app mode",
[
colorizationPage,
inpaintingPage,
enhancementPage,
denoisingPage
])
st.header(appMode)
# prompt for uploading an image
imgFile = st.file_uploader("Choose an image file")
if imgFile is None:
st.text("You haven't uploaded an image file")
else:
image = Image.open(imgFile)
# run the python script corresponding to appMode
# image colorization
if appMode == colorizationPage:
original, colorized = st.columns(2)
# get the colorized image
result = colorize.colorize(image)
#display the images side by side
original.header("Original")
original.image(image, use_column_width = True)
colorized.header("Colorized")
colorized.image(result, use_column_width = True)
# image enhancement
if appMode == enhancementPage:
original, enhanced = st.columns(2)
# get the enhanced image
res = night_images.enhance(image)
# display the images
original.header("Original Image")
original.image(image, use_column_width = True)
enhanced.header("Denoised Image")
enhanced.image(res, use_column_width = True)
When the app mode is changed, the changes done to the image are reversed even if I reassign the result to the image itself. How would I retain the changes made ?
I tried changing the prompt where the image is uploaded to check if an image has already been uploaded to not re-upload it but that also doesn't seem to work.