CoolFace
Apppublic

AIM-SCU/Cross-Cultural_Meme_Transcreation

sourceHugging Facecc-by-nc-sa-4.0updated 7mo agoView on Hugging Face
2likes
App README

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

  1. 1.Clone the repository:
bash
git clone https://huggingface.co/spaces/YZhao09/Meme_Gen
cd Meme_Gen
  1. 1.Install dependencies:
bash
pip install -r requirements.txt
  1. 1.Set up your Replicate API token:
bash
export REPLICATE_API_TOKEN="your_token_here"
  1. 1.Run the application:
bash
python app.py

The demo will launch at http://localhost:7860

📊 System Architecture

Models Used

  1. 1.LLaVA-13B (yorickvp/llava-13b)
  2. 2.Purpose: Vision-language understanding and cultural analysis
  3. 3.Cost: ~$0.02 per call
  4. 4.Analyzes emotion, intensity, and cultural context
  1. 1.FLUX.1-schnell (black-forest-labs/flux-schnell)
  2. 2.Purpose: Fast image generation
  3. 3.Cost: ~$0.02 per call
  4. 4.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:

  1. 1.SpongeBob Universe (30%)
  2. 2.Adult Animation (25%)
  3. 3.Classic Looney Tunes (15%)
  4. 4.Tom and Jerry + Friends (15%)
  5. 5.Classic Disney (10%)
  6. 6.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:

python
demo.queue(max_size=20)  # Max 20 requests in queue
demo.launch(max_threads=2)  # Max 2 concurrent generations

Adjust 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 file

Usage Examples

Gallery Mode

  1. 1.Click any meme from the 293 example gallery
  2. 2.Click "Transcreate Meme"
  3. 3.Wait for the 3-stage pipeline to complete
  4. 4.View the final transcreated meme with US-appropriate caption

Custom Upload Mode

  1. 1.Upload your own meme image
  2. 2.Provide a description (Chinese or English)
  3. 3.Click "Transcreate Meme"
  4. 4.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 interface
  • —pillow>=10.0.0 - Image processing
  • —replicate>=0.25.0 - API client
  • —requests>=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