Skip to content

A Python-based file generator script that creates videos and images via Gemini API using Google's Veo3, Veo2, and Imagen 3 and 4 models.

License

Notifications You must be signed in to change notification settings

2b3pro/GeminiGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini Generator

A Python-based file generator script that creates videos and images via Gemini API using Google's Veo3, Veo2, and Imagen 3 and 4 models.

Files

  • gemini_generator.py: The main script for generating files.

Usage

The Gemini Generator creates videos and images using Google's Veo and Imagen models. You must specify either --video or --image to indicate the content type you want to generate.

The generator requires a prompt. This can be provided via stdin, setting the -p value, or both.

Arguments

  • -p, --prompt (optional): Text prompt describing what you want to generate. Can be combined with stdin content.
  • --video or --image (required): Choose content type - mutually exclusive flags
  • -i, --image_path (optional): Path to input image file for image-to-video generation
  • -np, --negative_prompt (optional): What you don't want in the output (default includes text overlays, watermarks, etc.)
  • -m, --model (optional): Generation model to use:
    • Video models: veo3gp, veo3fgp (default), veo2
    • Image models: imagen-4.0-generate-preview-06-06, imagen-4.0-ultra-generate-preview-06-06, imagen-3.0-generate-002
  • -o, --output_filename (optional): Custom filename without extension
  • -d, --destination_directory (optional): Output directory (default: ./generated)
  • --dimension (optional): Aspect ratio - 16:9/landscape (default) or 9:16/portrait (Veo2 only)
  • -n, --num (optional): Number of outputs to generate (1-4 for images, 1-2 for Veo2 videos, 1 for other video models)

Examples

Generate a video:

python gemini_generator.py --video -p "A serene sunset over a mountain lake with gentle ripples"

Generate an image:

python gemini_generator.py --image -p "A futuristic cityscape at night with neon lights"

Generate video with custom settings:

python gemini_generator.py --video -p "A cat playing in a garden" -m veo2 --dimension portrait -n 2 -o my_cat_video

Generate image-to-video:

python gemini_generator.py --video -p "Make this image come alive with gentle movement" -i path/to/image.jpg

Use clipboard content as prompt (macOS):

python gemini_generator.py --video -p "$(pbpaste)"

Read prompt from stdin:

echo "A serene sunset over a mountain lake" | python gemini_generator.py --video

Combine stdin and -p prompt:

echo "Base scene: A peaceful forest" | python gemini_generator.py --video -p "with gentle morning mist"

Pipe from file:

cat my_prompt.txt | python gemini_generator.py --image

For detailed help and all available options:

python gemini_generator.py --help

Development

Prerequisites

  • Python 3.x
  • uv (install with pip install uv or brew install uv)

Environment Setup

  1. Create a virtual environment and install dependencies using uv:
    uv venv
    uv pip install -e .
  2. Activate the virtual environment:
    source .venv/bin/activate

API Setup

Before using the Gemini Generator, you need to set up your Google Gemini API key:

  1. Get your Gemini API key:

    • Go to Google AI Studio
    • Sign in with your Google account
    • Click "Create API Key" to generate a new key
    • Copy the generated API key
  2. Create a .env file in the project root:

    touch .env
  3. Add your API key to the .env file:

    GEMINI_API_KEY=your_api_key_here
    DEFAULT_GENERATED_DIR=./generated
    

    Replace your_api_key_here with the actual API key you obtained from Google AI Studio.

    The DEFAULT_GENERATED_DIR variable sets the default directory for generated files. If not specified, it defaults to ./generated.

Note: The .env file is already included in .gitignore to prevent accidentally committing your API key to version control.

Running Tests

(If tests are implemented, instructions would go here)

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/your-feature-name).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature/your-feature-name).
  6. Open a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

A Python-based file generator script that creates videos and images via Gemini API using Google's Veo3, Veo2, and Imagen 3 and 4 models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages