a tiny portrait background removal model, locally in the browser using Transformers.js, WebGPU-acceleration, and Basin to store and retrieve processed images on-chain.
A simple React + Vite application designed for running MODNet, a lightweight portrait background removal model, entirely in the browser. This solution leverages Transformers.js for seamless integration of machine learning models, while utilizing WebGPU acceleration to ensure smooth performance. Additionally, Basin is integrated to securely store and retrieve processed images on-chain, providing a decentralized solution for managing image data. This combination allows for a highly efficient, privacy-focused, and scalable application, fully powered by modern web technologies.
Follow the steps below to set up and run the application (both frontend and backend).
Ensure that you have Basin properly set up by following this guide. Once Basin is running, verify that ADM commands can be executed on your machine.
Clone the repository from GitHub:
git clone https://github.com/0xgoldenlion/basin-remove-bg.git
Change your working directory to the basin-remove-bg
folder:
cd basin-remove-bg
Install the necessary dependencies for the frontend using npm:
npm install
We need a backend to handle file uploads and interact with ADM.
.env
filerename the template.env
file in the project root to store your environment variables (Network and Private Key for ADM):
In your .env
file, add the following:
NETWORK=localnet
PRIVATE_KEY=your_private_key_here
ADMADDRESS=adress_here
ADMKEY= key_here
Replace your_private_key_here
with your actual private key for ADM transactions.
Navigate to the backend
directory and install the necessary backend dependencies:
cd backend
npm install
Start the backend server, which will handle file uploads and interactions with ADM:
node server.js
The backend server will be running on http://localhost:5555
.
Now that the backend is running, return to the main project directory (frontend) and start the development server:
npm run dev
The application should now be running locally. Open your browser and go to http://localhost:3511
to see it in action.