AI-powered ad generation pipeline that transforms product briefs into creative ad visuals
Project description
Loops — AI-Powered Ad Generation Pipeline
Pipeline automatisé de génération d'annonces publicitaires utilisant plusieurs modèles d'IA.
Project Overview
Loops est un pipeline de génération d'annonces publicitaires en 4 étapes qui transforme un brief produit et des visuels d'inspiration en une nouvelle annonce visuelle :
- Generate concept: Extraction du concept créatif depuis un brief produit (PDF) et une annonce d'inspiration
- Generate prompt for nanobanana: Création d'un prompt détaillé pour la génération d'image
- Generate new ad visual: Génération d'une nouvelle annonce visuelle combinant l'image produit avec le style d'inspiration
- Fix text (optional): Correction du texte via OCR pour corriger les erreurs de génération
Installation
Depuis GitHub Packages (package interne)
pip install loops --index-url https://pypi.python.org/simple --extra-index-url https://USERNAME:TOKEN@pypi.github.com/denemlabs/loops.git/simple
Ou avec un fichier .pypirc configuré:
pip install loops
Note: Configurez vos credentials GitHub (token avec permissions read:packages).
Développement local
git clone git@github.com:denemlabs/loops.git
cd loops
uv install
Prerequisites
- Python 3.13+ (verify with
python3 --version) - uv package manager (pour développement local)
- macOS (Homebrew):
brew install uv - Official installer (all platforms):
curl -LsSf https://astral.sh/uv/install.sh | sh - Verify:
uv --version
- macOS (Homebrew):
- Tesseract OCR (pour correction de texte)
- macOS (Homebrew):
brew install tesseract - Ubuntu/Debian:
sudo apt-get install tesseract-ocr - Verify:
tesseract --version - French language data: Download
fra.traineddataand place it in the tessdata directory:- macOS (Homebrew):
/opt/homebrew/share/tessdata - Ubuntu/Debian:
/usr/share/tesseract-ocr/*/tessdata - Download from: https://github.com/tesseract-ocr/tessdata/raw/main/fra.traineddata
- Example (macOS):
curl -L -o /opt/homebrew/share/tessdata/fra.traineddata https://github.com/tesseract-ocr/tessdata/raw/main/fra.traineddata
- macOS (Homebrew):
- macOS (Homebrew):
Configuration
- Copiez le fichier d'exemple d'environnement:
cp .env.example .env
- Ouvrez
.envet remplissez vos clés API:
ANTHROPIC_API_KEY=your_anthropic_key
OPENAI_API_KEY=your_openai_key
GOOGLE_CLOUD_PROJECT=your_gcp_project_id
GOOGLE_API_KEY=your_google_api_key
LANGSMITH_API_KEY=your_langsmith_key
Note: Gardez .env hors du contrôle de version.
Utilisation
Pipeline complet
from loops import AdGenerationPipeline
pipeline = AdGenerationPipeline(
brand_brief_path="path/to/brief.pdf",
inspiration_path="path/to/inspiration.jpg",
product_image_path="path/to/product.png",
output_path="output/ad.jpg",
)
results = pipeline.generate(fix_text=True)
print(f"Raw image: {results['raw_image']}")
print(f"Fixed image: {results['fixed_image']}")
Utilisation modulaire
from loops import NewAdConcept, PromptNanobanana, NewAdVisual
# Step 1: Generate concept
concept = NewAdConcept("brief.pdf").generate_from("inspiration.jpg")
# Step 2: Generate prompt
prompt = PromptNanobanana().generate_from(concept)
# Step 3: Generate visual
visual = NewAdVisual("product.png").generate_following(prompt)
Structure du Package
loops.pipeline: Pipeline principal (AdGenerationPipeline)loops.generators: Générateurs de concepts, prompts et visuelsNewAdConcept: Génération de concept avec GPT-O3PromptNanobanana: Génération de prompt avec GPT-4.1NewAdVisual: Génération de visuel avec Gemini
loops.processors: Processeurs d'images et OCREncodedImage: Gestion d'images encodées en base64RawAdVisual: Correction OCR avec Claude
loops.core: Modules coreBrandBrief: Lecture de briefs PDFPromptedImage: Formatage d'images pour LangChainSystemPrompt: Chargement de prompts système
Example Data Setup
Fournissez les assets suivants dans le dossier examples (référence à l'exemple doucea):
- Un document brief (PDF)
- Une annonce d'inspiration (JPEG)
- Une image produit (PNG)
Structure d'exemple:
examples/
doucea/
Doucéa Brief.pdf
inspiration_ad.jpeg
product_image.png
outputs/
Running the Application
Depuis la racine du projet:
uv run main.py
Ou utilisez l'exemple:
uv run examples/example_usage.py
What the Application Does
Le pipeline exécute 4 étapes:
- Step 1: Génère un concept créatif depuis le brief produit et l'annonce d'inspiration
- Step 2: Produit un prompt détaillé pour nanobanana guidé par le concept
- Step 3: Génère une nouvelle annonce visuelle qui combine l'image produit avec le style d'inspiration
- Step 4 (optionnel): Corrige le texte via OCR pour corriger les erreurs de génération
Les sorties seront sauvegardées dans le dossier outputs de votre exemple (e.g., examples/doucea/outputs/doucea_new_ad_raw.jpg et doucea_new_ad_fixed.jpg).
Utilisation dans une API
Une fois installé depuis GitHub, dans votre API:
# requirements.txt ou pyproject.toml
loops @ git+https://github.com/denemlabs/loops.git
# Dans votre API
from loops import AdGenerationPipeline
@app.post("/generate-ad")
async def generate_ad(request: AdRequest):
pipeline = AdGenerationPipeline(
brand_brief=request.brief_content, # String avec le contenu du brief
inspiration_path=request.inspiration_path,
product_image_path=request.product_path,
)
results = pipeline.generate(fix_text=True)
# results contient: concept, prompt, raw_image (bytes), fixed_image (bytes)
return results
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loops_ai-0.1.0.tar.gz.
File metadata
- Download URL: loops_ai-0.1.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5b971226a4f97e1882204855265e21577dfdf460c59cd134dc8e721dafce998
|
|
| MD5 |
955f316d0354fdfefa12a79d2ca57015
|
|
| BLAKE2b-256 |
3090127acd49193813b69570334f256731f06c442acac658c8d7a9f8ed75a332
|
File details
Details for the file loops_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: loops_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4700fe67439b2721ef78401bb855d87b18ade8eee256bb8d245900ccf522899f
|
|
| MD5 |
880114b43e059d1c950841eeb9508b58
|
|
| BLAKE2b-256 |
dece76c342817e426091f1e643e7744a942d0ce45fec964fd2ef1fd750422d9a
|