Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from rembg import remove
|
| 3 |
from PIL import Image, ImageFilter
|
| 4 |
import io
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Streamlit App Configuration
|
| 7 |
st.set_page_config(page_title="Background Remover & Changer", layout="wide")
|
| 8 |
st.title("Background Remover & Changer")
|
|
@@ -21,7 +24,7 @@ if uploaded_files:
|
|
| 21 |
image = image.convert("RGBA")
|
| 22 |
|
| 23 |
# Remove background using high-quality model
|
| 24 |
-
removed_bg = remove(image,
|
| 25 |
|
| 26 |
# Apply smoothing to improve edges
|
| 27 |
removed_bg = removed_bg.filter(ImageFilter.SMOOTH)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from rembg import remove, new_session
|
| 3 |
from PIL import Image, ImageFilter
|
| 4 |
import io
|
| 5 |
|
| 6 |
+
# Load high-quality model
|
| 7 |
+
session = new_session("u2net")
|
| 8 |
+
|
| 9 |
# Streamlit App Configuration
|
| 10 |
st.set_page_config(page_title="Background Remover & Changer", layout="wide")
|
| 11 |
st.title("Background Remover & Changer")
|
|
|
|
| 24 |
image = image.convert("RGBA")
|
| 25 |
|
| 26 |
# Remove background using high-quality model
|
| 27 |
+
removed_bg = remove(image, session=session)
|
| 28 |
|
| 29 |
# Apply smoothing to improve edges
|
| 30 |
removed_bg = removed_bg.filter(ImageFilter.SMOOTH)
|