Sep 8, 2024
As a tech-savvy parent, I wanted to create something truly special for my son's upcoming birthday. I decided to combine my love for technology with his passion for Peppa Pig to create a unique, personalized e-invitation. In this blog post, I'll walk you through how I used Replicate, Flux, LoRA, and Hugging Face to craft a Peppa Pig-themed e-invitation featuring my son.
The Concept: Merging AI with Creativity
The goal was simple yet innovative: design an e-invitation that seamlessly blends my son's image with the beloved Peppa Pig characters. This required training an AI model to recognize and generate images of my son in the distinctive Peppa Pig art style.
Essential Tools for AI-Generated Invitations
To bring this project to life, I utilized several powerful AI and machine learning tools:
Replicate: A versatile cloud platform for running, training, and experimenting with AI models. You won't need to buy an expensive GPU
Flux: An open-source machine learning framework that served as the foundation for the model.
LoRA (Low-Rank Adaptation): An efficient fine-tuning technique that works well with small datasets.
Hugging Face: A hub for saving, sharing, and accessing machine learning models.
Step-by-Step Process: From Photos to Custom AI Model
1. Gathering and Preparing Your Photos
Select 20 high-quality photos of your child
Ensure variety in poses and expressions
Preprocess images for consistency (resize, adjust lighting)
Rename each photo to "a_photo_of_xxx" where "xxx" is the name you'll use in your prompt later
Zip all 20 photos and rename the zip file to "a_photo_of_xxx" as well
Pro Tip: The naming convention is crucial for the AI to recognize and learn from your images effectively
Training Your Custom AI Model
I used Replicate AI to train my model, which I named "nile-flux-lora". Here's how:
Upload your zipped photos to Replicate
Use the lucataco/ai-toolkit model for training
Apply LoRA adapters for efficient fine-tuning
Start the training process

**Pro Tip**: The entire training process cost only $3.50. Using fewer photos can potentially reduce the cost even further.
3. Saving Your Trained Model
After training, save your custom model on Hugging Face. This allows for easy access and future use.
4. Image Inference
To create the invitation images:
1. Access the lucataco/flux-dev-lora model on Replicate
2. Input your custom model name (e.g., "YingcredibleAI/nile-flux-lora") in the UI
3. Use the following prompt (adjust as needed):
nile, wearing jean jumper, white t-shirt, yellow boots, and a gold-striped party hat, dancing with a large Peppa Pig costumed person in a muddy puddle in the park, blue pastel color birthday party in the background with hints of pink, balloons, banners, cupcakes, front-facing camera angle, ultra-high definition, 8k
4. Adjust parameters as needed. I kept all parameters the same except:
Changed the weight of LoRA to 1
Set output format to PNG file

5. Run the model (cost: $0.025 per run)
**Pro Tip**: Even with the same prompt, each run can produce different results. Don't be afraid to generate multiple images to find the perfect one.
For detailed specs of the model I used, check out this link.

**Tech Spec**: This model runs on Nvidia A100 (80GB) GPU hardware.
5. Creating Your E-Invitation
With your AI-generated images ready:
Visit Evite
Choose a free template
Upload your custom AI-generated image
Add event details and personalize your invitation

The Result: A Unique, Personalized Invitation
The final e-invitation featured my son in various Peppa Pig-inspired scenes, such as:
Dancing in a muddy puddle with a large Peppa Pig costumed character in the background
Surrounded by a pastel blue and pink birthday party setting
Wearing a distinctive outfit with a gold-striped party hat
This personalized touch made the invitation truly special, impressing family and friends with its uniqueness.
© Ying 2024