import streamlit as st import cv2 import numpy as np from PIL import Image st.title("Grayscale Image Converter") uploaded_file = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Load image using PIL and convert to numpy array image = Image.open(uploaded_file) img_array = np.array(image) # Convert to grayscale using OpenCV gray_img = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY) # Display grayscale image st.image(gray_img, caption="Grayscale Image", use_container_width=True, clamp=True)