admin管理员组文章数量:1356815
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
本文标签:
版权声明:本文标题:python - How do I recall my function img when it is in a if statement and im making an elif statement under it? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743981205a2571086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论