Spaces:
Sleeping
Sleeping
import streamlit as st | |
import cv2 | |
import numpy as np | |
from PIL import Image | |
st.set_page_config(page_title="Image Processing MVP", layout="wide") | |
st.title("Image Processing MVP") | |
st.markdown( | |
""" | |
<style> | |
.stFileUploader label { | |
font-size: 20px; | |
font-weight: 500; | |
color: #1f77b4; | |
} | |
.stRadio label { | |
font-size: 20px; | |
font-weight: 500; | |
color: #1f77b4; | |
} | |
.stRadio div { | |
display: flex; | |
gap: 20px; | |
} | |
</style> | |
""", | |
unsafe_allow_html=True, | |
) | |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"]) | |
if uploaded_file is not None: | |
image = Image.open(uploaded_file) | |
st.write("Processing...") | |
action = st.radio("Choose an action:", ('A', 'B')) | |
image_np = np.array(image) | |
if action == 'A': | |
processed_image = image_np.copy() | |
elif action == 'B': | |
processed_image = image_np.copy() | |
rows, cols, _ = processed_image.shape | |
num_spots = 50 | |
for _ in range(num_spots): | |
x, y = np.random.randint(0, cols), np.random.randint(0, rows) | |
cv2.circle(processed_image, (x, y), 10, (0, 0, 0), -1) | |
col1, col2 = st.columns(2) | |
with col1: | |
st.image(image, caption='Uploaded Image', use_column_width=True) | |
with col2: | |
st.image(processed_image, caption='Processed Image', use_column_width=True) | |