steamlit-ui / app.py
Inam65's picture
Update app.py
ad5057b verified
raw
history blame contribute delete
698 Bytes
import streamlit as st
import cv2
import numpy as np
from PIL import Image
# App title
st.title("Image to Grayscale Converter 🎨➡️🖤")
# File uploader
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
# Read the uploaded image
image = Image.open(uploaded_file)
st.image(image, caption="Original Image", use_column_width=True)
# Convert the image to an OpenCV format
img_array = np.array(image)
# Convert to grayscale
gray_image = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
# Display the grayscale image
st.image(gray_image, caption="Grayscale Image", use_column_width=True, clamp=True)