Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
import torch
|
6 |
+
|
7 |
+
def load_image(image_file):
|
8 |
+
img = Image.open(image_file)
|
9 |
+
return img
|
10 |
+
|
11 |
+
def process_image(image):
|
12 |
+
image_cv = np.array(image.convert('RGB'))
|
13 |
+
image_cv = cv2.cvtColor(image_cv, cv2.COLOR_RGB2BGR)
|
14 |
+
unsam_plus_output = image_cv # Replace with UNSAM+ processing
|
15 |
+
unsam_output = image_cv # Replace with UNSAM processing
|
16 |
+
return unsam_plus_output, unsam_output
|
17 |
+
|
18 |
+
st.title("UNSAM Image Processing")
|
19 |
+
|
20 |
+
image_file = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])
|
21 |
+
|
22 |
+
if image_file is not None:
|
23 |
+
original_image = load_image(image_file)
|
24 |
+
st.image(original_image, caption="Original Image", use_column_width=True)
|
25 |
+
|
26 |
+
unsam_plus_output, unsam_output = process_image(original_image)
|
27 |
+
|
28 |
+
st.image(unsam_plus_output, caption="UNSAM+ Output", use_column_width=True)
|
29 |
+
st.image(unsam_output, caption="UNSAM Output", use_column_width=True)
|