CS50P

๐Ÿ This is CS50โ€™s Introduction to Computer Science Solutions

View project on GitHub

Video Demo:

Description:

Remove Background GUI

This simple Python script uses the Tkinter library to create a graphical user interface (GUI) for removing backgrounds from images using the rembg library. The script allows users to select an image file, removes the background, and then saves the result as a PNG file.

Prerequisites

Before running the script, make sure you have the following dependencies installed:

  • Python (the script is compatible with Python 3)
  • Tkinter (usually included with Python)
  • PIL (Python Imaging Library)
  • rembg (to remove the background)

You can install the required Python packages using the following command:

pip install -r requirements.txt

How to Use

  1. Run the script by executing the following command in your terminal:
python project.py
  1. The GUI window will appear with a โ€œStart Hereโ€ button.

  2. Click the โ€œStart Hereโ€ button to open a file dialog and select an image file.

  3. The script will attempt to remove the background from the selected image and display the result in the GUI.

  4. Optionally, press F5 to restart the program.

Notes

  • If the selected file is not an image or if any errors occur during the process, an error message will be printed in the terminal.

  • The script uses the F5 key as a shortcut to restart the program.

  • The output image will be saved in PNG format.

Feel free to modify the script according to your needs or contribute to its development. If you encounter any issues, please check the error messages in the terminal for more information.