AIM-SCU/Cross-Cultural_Meme_Transcreation
2
MemeXGen
Cross-Cultural Meme Transcreation with Vision-Language Models
Features
- Two-Mode Interface:
- Example Gallery: Browse and transcreate from 293 real Chinese memes
- Custom Upload: Upload your own memes for transcreation
- Three-Stage Pipeline:
- Cultural Analysis (LLaVA-13B): Understands emotional context and cultural nuances
- Image Generation (FLUX.1-schnell): Creates new cartoon-style meme images
- Caption Overlay: Adds culturally-adapted text to the generated image
Quick Start
Prerequisites
- Python 3.13+
- Replicate API account and token
- System fonts for caption rendering (automatically installed via
packages.txt)
Installation
- Clone the repository:
git clone https://huggingface.co/spaces/YZhao09/Meme_Gen
cd Meme_Gen- Install dependencies:
pip install -r requirements.txt- Set up your Replicate API token:
export REPLICATE_API_TOKEN="your_token_here"- Run the application:
python app.pyThe demo will launch at http://localhost:7860
📊 System Architecture
Models Used
- LLaVA-13B (
yorickvp/llava-13b) - Purpose: Vision-language understanding and cultural analysis
- Cost: ~$0.02 per call
- Analyzes emotion, intensity, and cultural context
- FLUX.1-schnell (
black-forest-labs/flux-schnell) - Purpose: Fast image generation
- Cost: ~$0.02 per call
- Generates cartoon-style meme images in 4 inference steps
Total Cost per Meme: ~$0.04
Character Batch Rotation
The system rotates through 6 character batches for visual variety:
- SpongeBob Universe (30%)
- Adult Animation (25%)
- Classic Looney Tunes (15%)
- Tom and Jerry + Friends (15%)
- Classic Disney (10%)
- Modern Cartoon Network (5%)
Dataset
- 293 Chinese memes with authentic descriptions
- Includes emotion and intensity labels
- Images stored via Git LFS (~44MB)
Configuration
Environment Variables
REPLICATE_API_TOKEN: Your Replicate API key (required)
Concurrency Settings
Located in app.py:
demo.queue(max_size=20) # Max 20 requests in queue
demo.launch(max_threads=2) # Max 2 concurrent generationsAdjust these values based on your budget and traffic expectations.
Font Configuration
Caption fonts are automatically loaded from:
- macOS:
/System/Library/Fonts/Supplemental/Impact.ttf - Linux: Liberation Sans Bold or DejaVu Sans Bold (via
packages.txt)
Project Structure
Meme_Gen/
├── app.py # Main application
├── requirements.txt # Python dependencies
├── packages.txt # System packages (fonts)
├── labeled_data_clean.csv # Meme metadata (293 entries)
├── image/ # Gallery images (293 files, Git LFS)
├── .gitattributes # Git LFS configuration
└── README.md # This fileUsage Examples
Gallery Mode
- Click any meme from the 293 example gallery
- Click "Transcreate Meme"
- Wait for the 3-stage pipeline to complete
- View the final transcreated meme with US-appropriate caption
Custom Upload Mode
- Upload your own meme image
- Provide a description (Chinese or English)
- Click "Transcreate Meme"
- Receive a culturally-adapted US version
🛠️ Development
System Requirements
- Python: 3.13+
- RAM: 2GB minimum
- Storage: 500MB (including images)
- Network: Stable connection for API calls
Dependencies
Core packages (see requirements.txt):
gradio>=4.0.0- Web interfacepillow>=10.0.0- Image processingreplicate>=0.25.0- API clientrequests>=2.31.0- HTTP requests
Caption Rendering
Font size: 6% of image height Position: Bottom of image (95% down) Style: White text with black outline (2-3px)
License
This project is licensed under CC BY-NC-SA 4.0 - see the license badge above for details.
Acknowledgments
- Models: LLaVA-13B (UW-Madison), FLUX.1-schnell (Black Forest Labs)
- Dataset: 293 Chinese memes with cultural annotations
- Infrastructure: Hugging Face Spaces, Replicate API
Contact
For questions or issues, please open an issue on the Hugging Face Space.
Live Demo: https://huggingface.co/spaces/YZhao09/Meme_Gen
