engrjamalakram commited on
Commit
94f49ee
·
verified ·
1 Parent(s): 2f352eb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ st.title("Grayscale Image Converter")
7
+
8
+ # Upload image
9
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
10
+
11
+ if uploaded_file is not None:
12
+ # Convert the uploaded image to a format OpenCV can read
13
+ image = Image.open(uploaded_file)
14
+ image_np = np.array(image)
15
+
16
+ # Convert to grayscale using OpenCV
17
+ gray_image = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
18
+
19
+ # Display the grayscale image using Streamlit
20
+ st.image(gray_image, caption="Grayscale Image", use_column_width=True, channels="GRAY")