An AI-powered 2D digital human avatar with intelligent clothing replacement using Live2D and Google Gemini API.
- https://avatar.gbase.ai/ → name, style, (optional) company URL for auto-branding → Generate (live preview)
- Connect a knowledge base so it can actually talk (we use GBase; use whatever)
- 🎨 AI-Powered Clothing Replacement: Upload clothing images or use text descriptions to automatically replace avatar clothing
- 🤖 Intelligent Recognition: Uses Gemini Vision API to understand clothing details from photos
- 🎭 Live2D Integration: Built on Live2D runtime for smooth 2D character animation
- 🔄 Easy Restoration: One-click restore to original texture
- 📸 Multiple Input Methods: Support both image upload and text description
openavatar/
├── index.html # Main HTML page for displaying the avatar
├── generate_texture.py # AI-powered texture generation tool
├── requirements.txt # Python dependencies
├── lib/
│ └── local_main.js # JavaScript loader for Live2D runtime
└── runtime/
├── anime_runtime.js # Live2D runtime library
└── motion/ # Animation motion files
- Python 3.8 or higher
- A Google Gemini API key (get one from Google AI Studio)
- Clone the repository:
git clone git@github.com-mikeyang-spar:sparticleinc/open-avatar.git
cd open-avatar- Install Python dependencies:
pip install -r requirements.txt- Set up your Gemini API key:
export GEMINI_API_KEY='your_gemini_api_key_here'Simply open index.html in a web browser. The Live2D avatar will be displayed with animations.
For local development, you may need to serve the files through a web server:
# Using Python
python -m http.server 8000
# Using Node.js
npx serveThen open http://localhost:8000 in your browser.
Run the texture generation tool:
python generate_texture.pyThe tool provides three modes:
-
Image Upload Mode: Provide a path to a clothing image
Input > /path/to/your/tshirt.jpgThe AI will analyze the image and generate a 2D cartoon version.
-
Text Description Mode: Describe the clothing directly
Input > red hoodie with white logo on front -
Restore Original: Revert to the original texture
Input > restore -
Quit: Exit the program
Input > quit
$ python generate_texture.py
==================================================
Avatar Clothing Change Tool - AI Smart Replacement
==================================================
✨ Feature: AI automatically identifies clothing position, keeps other parts unchanged
Usage:
1. Upload clothing photo: Enter the file path of a real clothing image
2. Text description: Directly enter the clothing description
3. Restore original: Enter 'restore'
4. Quit program: Enter 'quit'
Input > red t-shirt with blue jeans
📝 Using text description: red t-shirt with blue jeans
🔄 AI is intelligently replacing clothing part...
✓ New texture saved to: runtime/haru_greeter_t05.2048/texture_01.png
✅ Clothing change complete! Texture updated
💡 Please refresh browser to see the effectAfter generating a new texture, refresh your browser to see the updated avatar.
-
Clothing Analysis (Image Mode): When you upload a clothing image, Gemini Vision API analyzes the clothing details including:
- Clothing type (T-shirt, hoodie, jacket, etc.)
- Colors and color scheme
- Patterns or logos
- Special design elements
- Overall style
-
Intelligent Replacement: The AI understands the Live2D texture layout and:
- Identifies the torso/clothing area automatically
- Keeps all other parts unchanged (hair, face, arms, legs, etc.)
- Generates new clothing in 2D cartoon style matching the original
- Maintains the exact layout and positions
-
Texture Update: The new texture is saved as
texture_00.png, replacing the original while keeping a backup.
The tool uses Google Gemini API. You need to set the API key as an environment variable:
export GEMINI_API_KEY='your_api_key_here'- Verify your
GEMINI_API_KEYis correctly set - Check your network connection
- Ensure your API key has proper permissions
- Try more detailed descriptions
- Use the
restorecommand to revert - Upload a clearer clothing image
- If the generated image has abnormal artifacts or extra parts, you can use a background removal service to clean up unwanted elements from the texture
- Make sure all dependencies are installed:
pip install -r requirements.txt - Check Python version (3.8+ required)
- Ensure all runtime files are in the correct directories
- Check browser console for errors
- Verify file paths in
lib/local_main.js
- Model Format: Live2D Cubism 3.0 (
.moc3,.model3.json) - Texture Size: 2048x2048 pixels
- AI Models Used:
gemini-2.0-flash-expfor image understandinggemini-2.5-flash-imagefor texture generation
We welcome contributions to Open Avatar!