I am trying to make a website that can let you take pictures with your camera and converts that picture into grey and also lets you upload an image that gets converted to grey but the problem is that I want the camera button to disappear as in like it minimizes to a small tab and when you press on it, it will expand back to normal. But when I want to call the img variable to close the camera screen it would give me an error because it can't be identified in the elif statement how would I fix this problem?
My code:
import streamlit as st
from PIL import Image
uploaded_image = st.file_uploader("Upload Image")
camera_image = st.camera_input('Camera')
if camera_image:
img = Image.open(camera_image)
gray_img = img.convert("L")
st.image(gray_img)
elif uploaded_image:
uploaded_image = Image.open(uploaded_image)
gray_img = uploaded_image.convert("L")
st.image(gray_img)
img.close