This project provides a graphical user interface (GUI) for removing backgrounds from images and enhancing them using AI through the Replicate API. The GUI is built using DelphiFMX for Python, offering a simple and intuitive way for users to upload images and receive background-removed, upscaled versions. The app runs background processes without blocking the user interface.
- Background Removal: Remove the background of uploaded images using AI.
- Upscale Enhancement: Add detail to the upscaled image after the background is removed.
- Status Updates: Real-time status updates on the processing of the image.
- Background Processing: Image processing runs in the background to keep the UI responsive.
Below is a screenshot of the GUI in action:
- Python 3.7 or higher
- Replicate API Token (you need to set this up and add it to your environment variables)
- DelphiFMX for Python
-
Clone this repository:
git clone /~https://github.com/your-username/ai-background-remover.git cd ai-background-remover
-
Install the required Python packages:
pip install delphifmx replicate
-
Set your Replicate API token:
export REPLICATE_API_TOKEN=your_replicate_api_token
-
Run the application:
python main.py
- Upload an Image: Click the "Select" button to choose an image from your computer.
- Processing: Once the image is uploaded, the app will automatically start the background removal process using the Replicate API.
- View Results: After processing, the original image and the enhanced background-removed image will be displayed side by side. The status bar at the bottom of the app provides real-time updates on the image processing.
bgremover.py
: The main Python script that contains the GUI logic and handles interaction with the Replicate API.Air.style
: The custom UI style applied to the application. You can replace or modify this file to change the appearance of the app.- Image Display: The app shows both the original and processed images within the GUI.
import os
import replicate
import urllib.request
import hashlib
from delphifmx import *
import threading
- Replicate API: Used for handling AI-powered background removal and enhancement.
- DelphiFMX: The GUI framework for creating the interface.
- Threading: Ensures the app remains responsive by running background tasks asynchronously.
- Upload Image: The user selects an image from their local machine.
- Background Removal and Enhancement: The app sends the image to the smoretalk/rembg-enhance model hosted on Replicate.
- Display Result: Once processing is complete, the background-removed and enhanced image is displayed alongside the original.
model = replicate.models.get("smoretalk/rembg-enhance")
version = model.versions.get("4067ee2a58f6c161d434a9c077cfa012820b8e076efa2772aa171e26557da919")
self.prediction = replicate.predictions.create(
version=version,
input={"image": open(file_path, "rb")}
)
Feel free to submit pull requests or open issues for suggestions and improvements.
This project is licensed under the MIT License.
- Replicate API
- DelphiFMX for Python This README provides a comprehensive overview of your project, explaining how to install, use, and contribute to it while also including code snippets to give users a quick understanding of its core functionality.