Skip to main content

Specialized agent for hair style and color editing

Project description

Hair Editor Agent

PyPI PyPI - Python Version CI License

Hair Editor Agent is an AI-powered Python library and agent for realistic hairstyle and hair-color editing using image models and vision-capable LLMs.

This package focuses on flexible, descriptive editing: orchestrators may pass free-form textual descriptions for hair_style and hair_color (for example: "Shoulder-length wavy hair with subtle balayage highlights, loose beachy waves"). The agent handles image validation, optional image size/quality tuning, and forwards requests to a configurable LLM-backed client.

Key features

  • Free-form hairstyle editing: accept detailed textual descriptions (length, texture, cut, layers, styling).
  • Hair color transformations: accept descriptive color instructions (e.g. "rose gold with warm undertones").
  • Change appearance task: combine style and color transformations in a single request.
  • Optional client-side image resizing/compression to reduce payload size and latency.
  • Simple, test-friendly API designed for integration into larger orchestrators and CI-driven publishing.

Installation

Developer / editable install:

python -m pip install -e .[dev]

Install from PyPI (when published):

pip install hair-editor-agent

Install directly from this repository:

pip install git+https://github.com/msalsas/hair-editor-agent.git

Quick start

from hair_editor_agent import HairEditorAgent
from agent_core_framework import AgentTask

# Create the agent. You can tune image payload size via max_image_size and jpeg_quality.
agent = HairEditorAgent(openrouter_api_key="YOUR_API_KEY", max_image_size=1024, jpeg_quality=85)

# Edit hair style and color with descriptive strings
task = AgentTask(
    type="edit_hair_style",
    payload={
        "image_path": "photo.jpg",
        "hair_style": "Shoulder-length wavy hair with subtle balayage highlights, loose beachy waves",
        "hair_color": "warm chestnut with golden highlights"
    }
)
response = agent.process(task)
print(response.success, response.error)
print(response.data)  # contains edited_image_path and echoed style/color when successful

Supported task types (examples): edit_hair_style, edit_hair_color, change_appearance.

Testing

Run the test suite locally:

python -m pytest

(Use PYTHONPATH=src if running tests from the project root to import the local package: PYTHONPATH=src pytest -q)

Publishing to TestPyPI (manual)

  1. Bump the version in pyproject.toml (e.g. to 0.2.0).
  2. Build distributions:
python -m build
  1. Upload to TestPyPI (create a TestPyPI API token first):
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Notes on CI

A GitHub Actions workflow (.github/workflows/publish.yml) can be included to automate publishing. To enable automated publishing to TestPyPI, add your TestPyPI token as a repository secret named TEST_PYPI_API_TOKEN and run the workflow manually or by pushing a test tag.

The repository also contains tests and basic CI configuration; ensure your runner has Pillow and test dependencies available.

Contributing

Contributions are welcome. Please open an issue or a pull request. Follow the existing code style, add tests for new behavior, and keep changes focused and small. If you add or change public behavior, add/adjust unit tests accordingly.

License

MIT — see the LICENSE file for details.

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

hair_editor_agent-0.2.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

hair_editor_agent-0.2.0-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file hair_editor_agent-0.2.0.tar.gz.

File metadata

  • Download URL: hair_editor_agent-0.2.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hair_editor_agent-0.2.0.tar.gz
Algorithm Hash digest
SHA256 04c2f8d24ab1fd732e79b357898b07710314eda74328d7b5907dbf60a93b2232
MD5 597d3d22e67f7aa0f484a263a9b9d99a
BLAKE2b-256 d7d05d323fdcf7f793cdb93cf08ec734952bd07eafd6a9bc3c6048e82da2ee3f

See more details on using hashes here.

File details

Details for the file hair_editor_agent-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for hair_editor_agent-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a5f27a443b64643bc00e4b7fbf38fce371902c79c9aea094d2171a9c571219fe
MD5 adf41a38ede2ba846453115c75a753dc
BLAKE2b-256 ce2d784b5db6bbc69e701ba62720426541e722493a5e414e0eea08e1d678d837

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