Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,17 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
import numpy as np
|
| 4 |
from PIL import Image
|
| 5 |
-
|
| 6 |
-
st.
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 10 |
-
|
| 11 |
if uploaded_file is not None:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
gray_img = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
|
| 22 |
-
|
| 23 |
-
# Display grayscale image
|
| 24 |
-
st.subheader("Grayscale Image")
|
| 25 |
-
st.image(gray_img, use_column_width=True, clamp=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
import numpy as np
|
| 4 |
from PIL import Image
|
| 5 |
+
st.title("🖼️ Image to Grayscale Converter")
|
| 6 |
+
uploaded_file = st.file_uploader("Upload an Image", type=["jpg",
|
| 7 |
+
"jpeg", "png"])
|
|
|
|
|
|
|
|
|
|
| 8 |
if uploaded_file is not None:
|
| 9 |
+
img = Image.open(uploaded_file)
|
| 10 |
+
img_array = np.array(img)
|
| 11 |
+
gray_image = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
|
| 12 |
+
st.subheader("Original Image")
|
| 13 |
+
st.image(img, caption="Uploaded Image",
|
| 14 |
+
use_column_width=True)
|
| 15 |
+
st.subheader("Grayscale Image")
|
| 16 |
+
st.image(gray_image, caption="Grayscale Image",
|
| 17 |
+
use_column_width=True, channels="GRAY")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|