minhwai
commited on
Commit
·
ae4d776
1
Parent(s):
bbe1ed5
Add website try1 app
Browse files
app.py
CHANGED
|
@@ -1,4 +1,30 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
+
st.title("Image Processing MVP")
|
| 7 |
+
|
| 8 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
| 9 |
+
|
| 10 |
+
if uploaded_file is not None:
|
| 11 |
+
image = Image.open(uploaded_file)
|
| 12 |
+
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
| 13 |
+
st.write("")
|
| 14 |
+
st.write("Processing...")
|
| 15 |
+
|
| 16 |
+
action = st.radio("Choose an action:", ('A', 'B'))
|
| 17 |
+
|
| 18 |
+
image_np = np.array(image)
|
| 19 |
+
|
| 20 |
+
if action == 'A':
|
| 21 |
+
processed_image = image_np.copy()
|
| 22 |
+
elif action == 'B':
|
| 23 |
+
processed_image = image_np.copy()
|
| 24 |
+
rows, cols, _ = processed_image.shape
|
| 25 |
+
num_spots = 50
|
| 26 |
+
for _ in range(num_spots):
|
| 27 |
+
x, y = np.random.randint(0, cols), np.random.randint(0, rows)
|
| 28 |
+
cv2.circle(processed_image, (x, y), 10, (0, 0, 0), -1)
|
| 29 |
+
|
| 30 |
+
st.image(processed_image, caption='Processed Image.', use_column_width=True)
|