Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from rembg import remove
|
| 3 |
from PIL import Image
|
| 4 |
import io
|
| 5 |
import fitz # PyMuPDF for handling PDFs
|
|
@@ -25,9 +25,12 @@ if uploaded_file is not None:
|
|
| 25 |
|
| 26 |
st.image(image, caption="Original Image", use_column_width=True)
|
| 27 |
|
| 28 |
-
#
|
|
|
|
|
|
|
|
|
|
| 29 |
with st.spinner("Removing background with high quality..."):
|
| 30 |
-
output_image = remove(image,
|
| 31 |
|
| 32 |
st.image(output_image, caption="Background Removed", use_column_width=True)
|
| 33 |
|
|
@@ -37,4 +40,4 @@ if uploaded_file is not None:
|
|
| 37 |
st.download_button("Download Image", img_byte_arr.getvalue(), file_name="no_bg_image.png", mime="image/png")
|
| 38 |
|
| 39 |
st.markdown("---")
|
| 40 |
-
st.markdown("💡 Developed with ❤️ using Streamlit and rembg (U2Net HQ)")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from rembg import remove, new_session
|
| 3 |
from PIL import Image
|
| 4 |
import io
|
| 5 |
import fitz # PyMuPDF for handling PDFs
|
|
|
|
| 25 |
|
| 26 |
st.image(image, caption="Original Image", use_column_width=True)
|
| 27 |
|
| 28 |
+
# Create a high-quality model session
|
| 29 |
+
session = new_session("u2net_hq") # Load the HQ model
|
| 30 |
+
|
| 31 |
+
# Remove background using the HQ model
|
| 32 |
with st.spinner("Removing background with high quality..."):
|
| 33 |
+
output_image = remove(image, session=session)
|
| 34 |
|
| 35 |
st.image(output_image, caption="Background Removed", use_column_width=True)
|
| 36 |
|
|
|
|
| 40 |
st.download_button("Download Image", img_byte_arr.getvalue(), file_name="no_bg_image.png", mime="image/png")
|
| 41 |
|
| 42 |
st.markdown("---")
|
| 43 |
+
st.markdown("💡 Developed with ❤️ using Streamlit and rembg (U2Net HQ)")
|