Find a file
2025-03-20 23:56:08 +00:00
.devcontainer Added Dev Container Folder 2024-12-17 07:53:04 -05:00
.gitignore MVP 2024-12-17 05:32:40 -05:00
.gitlab-ci.yml Update .gitlab-ci.yml 2025-03-20 23:39:30 +00:00
black_forest_streamlit.py Update black_forest_streamlit.py 2025-03-20 23:55:29 +00:00
black_forest_test.py MVP 2024-12-17 05:32:40 -05:00
README.rst Update README.rst 2024-12-17 10:58:34 -05:00
requirements.txt Update requirements.txt 2025-03-20 23:56:08 +00:00

Black Forest Labs Image Generation
==================================

This project allows you to generate images based on prompts using the Black Forest Labs API. The generated images are saved to a local directory, and their metadata, including base64 representations, are stored in a SQLite database.

Requirements
------------

- Python 3.x
- Required Python packages:
    - ``http.client``
    - ``json``
    - ``base64``
    - ``os``
    - ``time``
    - ``requests``
    - ``streamlit`` (optional for web user interface)
    - ``argparse``
    - ``re``
    - ``sqlite3``
    - ``datetime``

Installation
------------

1. Clone the Repository
~~~~~~~~~~~~~~~~~~~~~

Clone this repository to your local machine::

    git clone git@github.com:russellballestrini/black_forest_test.git
    cd black_forest_test

Install required packages::

    pip install -r requirements.txt

Set your API key as an environment variable::

    export BLACK_FOREST_LABS_API_KEY="your_api_key_here"

Replace ``"your_api_key_here"`` with your actual Black Forest Labs API key.

Usage
-----

Run the script with a prompt::

    python black_forest_test.py "A beautiful sunset over the mountains"

The script will automatically create an ``images`` directory for storing generated images.


Run the streamlit web interface!::

    streamlit run black_forest_streamlit.py


Output
------

- Generated images are saved in the ``images`` directory
- Image metadata stored in ``image_metadata.db`` SQLite database

Database Structure
-----------------

The ``images`` table contains:

- **id**: Unique identifier (INTEGER PRIMARY KEY)
- **slug**: Prompt-based slug (TEXT)
- **prompt**: Original generation prompt (TEXT)
- **filename**: Saved image filename (TEXT)
- **base64_image**: Base64 encoded image (TEXT)
- **timestamp**: Creation timestamp (DATETIME)

Notes
-----

- Requires active internet connection
- Keep API key confidential

License
-------

This work is dedicated to the public domain.