Spaces:
Sleeping
Sleeping
"feat:add_webcam_input"
Browse files
app.py
CHANGED
|
@@ -106,12 +106,21 @@ def main():
|
|
| 106 |
"Choose an image...", type=["jpg", "jpeg", "png"]
|
| 107 |
)
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
if uploaded_file is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
try:
|
| 111 |
-
image = Image.open(
|
| 112 |
|
| 113 |
with col1:
|
| 114 |
-
st.image(image, caption="
|
| 115 |
|
| 116 |
# Preprocess the image and make a prediction
|
| 117 |
with st.spinner("Analyzing the image..."):
|
|
@@ -135,7 +144,7 @@ def main():
|
|
| 135 |
|
| 136 |
else:
|
| 137 |
with col2:
|
| 138 |
-
st.info("Please upload an image to see the prediction.")
|
| 139 |
|
| 140 |
if __name__ == "__main__":
|
| 141 |
main()
|
|
|
|
| 106 |
"Choose an image...", type=["jpg", "jpeg", "png"]
|
| 107 |
)
|
| 108 |
|
| 109 |
+
st.header("Or Use Webcam")
|
| 110 |
+
camera_image = st.camera_input("Take a picture")
|
| 111 |
+
|
| 112 |
+
image_to_process = None
|
| 113 |
if uploaded_file is not None:
|
| 114 |
+
image_to_process = uploaded_file
|
| 115 |
+
elif camera_image is not None:
|
| 116 |
+
image_to_process = camera_image
|
| 117 |
+
|
| 118 |
+
if image_to_process is not None:
|
| 119 |
try:
|
| 120 |
+
image = Image.open(image_to_process)
|
| 121 |
|
| 122 |
with col1:
|
| 123 |
+
st.image(image, caption="Your Image", use_container_width=True)
|
| 124 |
|
| 125 |
# Preprocess the image and make a prediction
|
| 126 |
with st.spinner("Analyzing the image..."):
|
|
|
|
| 144 |
|
| 145 |
else:
|
| 146 |
with col2:
|
| 147 |
+
st.info("Please upload an image or use the webcam to see the prediction.")
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
main()
|