Skip to main content

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 :

  1. Generate concept: Extraction du concept créatif depuis un brief produit (PDF) et une annonce d'inspiration
  2. Generate prompt for nanobanana: Création d'un prompt détaillé pour la génération d'image
  3. Generate new ad visual: Génération d'une nouvelle annonce visuelle combinant l'image produit avec le style d'inspiration
  4. 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
  • 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.traineddata and place it in the tessdata directory:

Configuration

  1. Copiez le fichier d'exemple d'environnement:
cp .env.example .env
  1. Ouvrez .env et 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 visuels
    • NewAdConcept: Génération de concept avec GPT-O3
    • PromptNanobanana: Génération de prompt avec GPT-4.1
    • NewAdVisual: Génération de visuel avec Gemini
  • loops.processors: Processeurs d'images et OCR
    • EncodedImage: Gestion d'images encodées en base64
    • RawAdVisual: Correction OCR avec Claude
  • loops.core: Modules core
    • BrandBrief: Lecture de briefs PDF
    • PromptedImage: Formatage d'images pour LangChain
    • SystemPrompt: 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:

  1. Step 1: Génère un concept créatif depuis le brief produit et l'annonce d'inspiration
  2. Step 2: Produit un prompt détaillé pour nanobanana guidé par le concept
  3. Step 3: Génère une nouvelle annonce visuelle qui combine l'image produit avec le style d'inspiration
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loops_ai-0.1.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loops_ai-0.1.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

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

Hashes for loops_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5b971226a4f97e1882204855265e21577dfdf460c59cd134dc8e721dafce998
MD5 955f316d0354fdfefa12a79d2ca57015
BLAKE2b-256 3090127acd49193813b69570334f256731f06c442acac658c8d7a9f8ed75a332

See more details on using hashes here.

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

Hashes for loops_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4700fe67439b2721ef78401bb855d87b18ade8eee256bb8d245900ccf522899f
MD5 880114b43e059d1c950841eeb9508b58
BLAKE2b-256 dece76c342817e426091f1e643e7744a942d0ce45fec964fd2ef1fd750422d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page