File size: 2,665 Bytes
efa0e35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Evaluation

The CLI reads `text_prompts.jsonl` and `text_prompts_zh.jsonl` from the repository root. Use Python 3.10+ and Pillow, and run the commands below from that directory.

## Generate images

```bash
python evaluation/bench.py export --output jobs.jsonl --n-samples 4 --seed 42
python evaluation/local_inference.py --adapter my_adapter:generate \
  --jobs jobs.jsonl --images images
python evaluation/bench.py check --images images --n-samples 4
```

Provide `generate(*, prompt, seed, width, height)` in `my_adapter.py`, returning a PIL image. The 960 exported jobs use 1024×1024 canvases and seeds computed as `base_seed + prompt_id * n_samples + sample_index`. Outputs follow `images/<prompt_id>/samples/<sample_index>.png`, with both IDs padded to five digits.

The adapter supports `--num-shards N --shard-index I`. For another dataset directory containing the two prompt files, pass `--data-dir` to `bench.py`.

## OCR and coverage

Install a CUDA-compatible PyTorch/torchvision pair and the evaluation dependencies:

```bash
python -m pip install -r evaluation/requirements.txt
python evaluation/bench.py score --images images --n-samples 4 \
  --output scores --ocr-model /path/to/Qwen2.5-VL-7B-Instruct --workers 1
```

`--ocr-model` points to a local Qwen2.5-VL-7B-Instruct checkpoint, including its tokenizer and processor. `--workers` sets the number of OCR GPU workers. Images are processed as 1024×1024 RGB inputs using LANCZOS resizing; OCR generates up to 4,096 tokens.

The main score is `scores/summary.json` → `macro_overall_mean6`, the equal mean of the six language/length group coverage scores. Each group uses total matched units divided by total target units. English units are words; Chinese units are characters. Matching retains repeated-unit counts. The target includes the title, author, and passage.

The X-Omni normalization removes punctuation, lowercases English, and removes Chinese whitespace while retaining Latin-letter case in Chinese text. Images with empty OCR text receive zero matched units. Results are stored in `scores/en/results.jsonl` and `scores/zh/results.jsonl`.

For one image per prompt, use `--n-samples 1` for export, image checks, and scoring.

## Reuse OCR results

```bash
python evaluation/bench.py summarize --results scores \
  --output rescored --n-samples 4
```

This recomputes coverage from saved OCR text and dataset targets. Use the same sample count and language selection as the original run.

## Attribution

The OCR and coverage evaluation follows [X-Omni](https://github.com/X-Omni-Team/X-Omni). The bundled evaluation code retains its [Apache-2.0 license](vendor/X-Omni-LICENSE).