├── README.md └── BackgroundRemoval-main └── BackgroundRemoval-main ├── requirements.txt ├── zebra.jpg ├── wallaby.png ├── README.md └── bg_remove.py /README.md: -------------------------------------------------------------------------------- 1 | # Background-remover- 2 | 3 | Url of live demo app: 4 | https://bgremover07.streamlit.app/ 5 | -------------------------------------------------------------------------------- /BackgroundRemoval-main/BackgroundRemoval-main/requirements.txt: -------------------------------------------------------------------------------- 1 | rembg==2.0.50 2 | Pillow==9.3.0 3 | streamlit==1.21.0 4 | numba==0.57 5 | numpy==1.23.0 6 | -------------------------------------------------------------------------------- /BackgroundRemoval-main/BackgroundRemoval-main/zebra.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tania53/Background-remover-/HEAD/BackgroundRemoval-main/BackgroundRemoval-main/zebra.jpg -------------------------------------------------------------------------------- /BackgroundRemoval-main/BackgroundRemoval-main/wallaby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tania53/Background-remover-/HEAD/BackgroundRemoval-main/BackgroundRemoval-main/wallaby.png -------------------------------------------------------------------------------- /BackgroundRemoval-main/BackgroundRemoval-main/README.md: -------------------------------------------------------------------------------- 1 | # BackgroundRemoval 2 | Upload an image and adjust the settings to remove the background for any image! 3 | 4 | # License 5 | MIT 6 | -------------------------------------------------------------------------------- /BackgroundRemoval-main/BackgroundRemoval-main/bg_remove.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | from rembg import remove 3 | from PIL import Image 4 | from io import BytesIO 5 | import base64 6 | 7 | st.set_page_config(layout="wide", page_title="Image Background Remover") 8 | 9 | st.write("## Remove background from your image") 10 | st.write( 11 | ":dog: Try uploading an image to watch the background magically removed. Full quality images can be downloaded from the sidebar. This code is open source and available [here](https://github.com/tyler-simons/BackgroundRemoval) on GitHub. Special thanks to the [rembg library](https://github.com/danielgatis/rembg) :grin:" 12 | ) 13 | st.sidebar.write("## Upload and download :gear:") 14 | 15 | MAX_FILE_SIZE = 5 * 1024 * 1024 # 5MB 16 | 17 | # Download the fixed image 18 | def convert_image(img): 19 | buf = BytesIO() 20 | img.save(buf, format="PNG") 21 | byte_im = buf.getvalue() 22 | return byte_im 23 | 24 | 25 | def fix_image(upload): 26 | image = Image.open(upload) 27 | col1.write("Original Image :camera:") 28 | col1.image(image) 29 | 30 | fixed = remove(image) 31 | col2.write("Fixed Image :wrench:") 32 | col2.image(fixed) 33 | st.sidebar.markdown("\n") 34 | st.sidebar.download_button("Download fixed image", convert_image(fixed), "fixed.png", "image/png") 35 | 36 | 37 | col1, col2 = st.columns(2) 38 | my_upload = st.sidebar.file_uploader("Upload an image", type=["png", "jpg", "jpeg"]) 39 | 40 | if my_upload is not None: 41 | if my_upload.size > MAX_FILE_SIZE: 42 | st.error("The uploaded file is too large. Please upload an image smaller than 5MB.") 43 | else: 44 | fix_image(upload=my_upload) 45 | else: 46 | fix_image("./zebra.jpg") 47 | --------------------------------------------------------------------------------