Metadata-Version: 2.5
Name: brandcheck
Version: 0.1.0
Summary: Score brand photos against a photography guideline with a vision model
Requires-Python: >=3.10
Requires-Dist: jsonschema>=4.23
Requires-Dist: openai<3,>=2
Requires-Dist: pillow<13,>=11
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# brandcheck

Score brand photos against a photography guideline with a vision model.

You write the guideline in Markdown. brandcheck turns it into an **answer card** (a list of
criteria with weights and must-pass rules), then scores each photo against that card. For each
criterion you get a score (100, 75, 50, 25 or 0), the model's confidence and a short piece of
evidence. All of it is combined into one **brand match score**.

Every result is a suggestion for a person to review, not an approval.

## Install

```
pip install brandcheck
```

Needs Python 3.10 or newer.

## Set up the model

brandcheck works with any OpenAI-compatible vision model (for example Qwen3-VL served by vLLM).
Set three environment variables:

```
export VISION_MODEL_BASE_URL=https://your-server/v1
export VISION_MODEL_API_KEY=your-key
export VISION_MODEL_NAME=your-model-name
```

## Command line

Make a card from a guideline (this takes a few minutes):

```
brandcheck make-card guideline.md -o card.json
```

Score one or more photos:

```
brandcheck score photo1.jpg photo2.png --card card.json
```

Options for `score`:

- `--context "live event"` gives the model background about the photo
- `--no-summary` skips the photo description (one model call instead of two)
- `--json` prints the full result

## Python

```python
from brandcheck import OpenAICompatibleModel, make_card, check_photo

model = OpenAICompatibleModel.from_env()

card = make_card(open("guideline.md").read(), model)["card"]
result = check_photo("photo.jpg", card, model)

print(result["brand_score"]["score"])  # e.g. 80
for answer in result["answers"]:
    print(answer["name"], answer["score"], answer["confidence"], answer["evidence"])
```

## Using a different model

Anything with a matching `complete` method works. Pass it in place of `OpenAICompatibleModel`:

```python
from brandcheck import ModelReply

class MyModel:
    def complete(self, messages, schema, *, name="", max_tokens=2048, timeout=None,
                 logprobs=False, require_stop=True):
        # call your model with the messages, ask for JSON matching `schema`
        return ModelReply(content=json_text, requested_model="mine", returned_model="mine")
```

Confidence needs token log-probabilities. Without them, `confidence` is `None` and
everything else still works.

## How the brand match score works

- Each criterion counts by its weight: high 3, medium 2, low 1
- `cannot_assess` and `not_applicable` answers are left out, not counted as 0
- If a must-pass criterion scores below 100, the score is capped: 75 caps it at 80%,
  50 at 60%, 25 or 0 at 40%. The worst miss sets the cap

## Run the tests

```
pip install -e ".[test]"
pytest
```

The tests use a fake model, so they need no network or API key.