import streamlit as st import time from rembg import remove from PIL import Image st.title("Background Remover") # Create a file uploader uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Retrieve the path of the uploaded file input_path = uploaded_file.name # Store path of the output image in the variable output_path output_path = 'output.png' # Start timer start_time = time.time() # Processing the image with Image.open(uploaded_file) as input: # Removing the background from the given Image output = remove(input) # Saving the image in the given path output.save(output_path) # End timer and calculate elapsed time elapsed_time = time.time() - start_time st.success(f"Image processing completed in {elapsed_time:.2f} seconds.") # Display the output image st.image(output_path)