Out of sheer curiosity, I built an AI-powered virtual try-on app a lightweight open-source project that lets you upload your photo and a clothing item and see what it might look like on you. No fancy cameras or 3D scanners, just a bit of AI magic under the hood!
It's built with Next.js and uses Google's Gemini API (experimental Flash model) to generate try-on previews. If you're curious about generative AI, want to learn about handling images in React/Next.js, or just enjoy experimenting, this project is a fun place to start.
Check it out here:
π GitHub Repository
β¨ Features
- π€ User Image Upload β Add your own photo.
- π Clothing Image Upload β Upload a shirt, jacket, or any apparel.
- πΌοΈ Image Previews β See your selected images before generating results.
- π§ AI-Powered Try-On β Uses Google Gemini to generate a virtual try-on.
- β Result Display β Get a final AI-generated image preview.
- β³ Loading Indicator β Visual feedback while the AI does its work.
- π Reset Button β Quickly clear everything and start fresh.
- π¨ Clean UI β Built with Tailwind CSS for simplicity and responsiveness.
π§° Tech Stack
Tech | Description |
---|---|
Next.js 13+ | App Router + React |
TypeScript | Safer, typed JavaScript |
Tailwind CSS | Utility-first CSS styling |
Google Gemini API | Flash experimental model |
@google/gemini SDK | For interacting with the API |
Lucide React | Clean, minimal icons |
npm | Package manager |
π Getting Started Locally
Here's how to get this running on your machine:
1. Clone the Repo
git clone https://github.com/oyeolamilekan/gemini-ai-tryon.git
cd gemini-ai-tryon
Or if you already have the code locally, navigate to the root directory.
2. Install Dependencies
npm install
3. Add Your Gemini API Key
Create a .env.local
file in the root:
# .env.local
GEMINI_API_KEY=YOUR_GOOGLE_GEMINI_API_KEY
Replace YOUR_GOOGLE_GEMINI_API_KEY
with a real key from Google AI Studio.
4. Start the Dev Server
npm run dev
Visit http://localhost:3000 to view the app.
π§ͺ How to Use
- Upload your photo.
- Upload a clothing item image.
- Click "Try It On!"
- Wait a few seconds while the AI works.
- View your AI-generated try-on image.
- Click Reset to start over.
π§΅ API Details
Endpoint: POST /api/tryon
Request Body: FormData containing:
-
userImage
: The user's photo -
clothingImage
: The clothing item photo
Success Response:
{
"image": "data:image/png;base64,...",
"description": "Optional description"
}
Error Response:
{
"error": "Error message",
"details": "Optional additional details"
}
π Why I Built This
I've been curious about how AI could be applied to fashion and e-commerce. What started as an experimental project ended up being a fun way to learn how to combine frontend frameworks, generative models, and image processing into a single app.
It's open-source, simple, and meant to be hacked on.
π§βπ» Try It, Fork It, Break It!
Feel free to clone the repo, tinker with the UI, swap in a different AI model, or build your own version of a virtual fitting room. I'd love to see what you make!
GitHub: github.com/oyeolamilekan/gemini-ai-tryon
π Let's Connect
If you try it out or build something cool with it, tag me or drop a comment!
Happy hacking! π¨π½βπ»β¨
Top comments (0)