Views
No views yet
CATEGORY or PRODUCT)type=PRODUCT)type=CATEGORY)v1.1 was used during training.lora_r: 32lora_alpha: 32epochs: 1batch_size: 32 (8 per GPU * 4 gradient accumulation steps)learning_rate: 2e-4weight_decay: 0.01ẁarmup_ratio: 0.05 price: 500/523 (95.60% accuracy)
barcode: 360/408 (88.24% accuracy)
uncertain_barcode_or_product_name: 491/528 (92.99% accuracy)
category: 34/59 (57.63% accuracy) price: 466/523 (89.10% accuracy)
barcode: 345/408 (84.56% accuracy)
uncertain_barcode_or_product_name: 497/528 (94.13% accuracy)
category: 19/66 (28.79% accuracy)1OMP_NUM_THREADS=1 vllm serve --model Qwen/Qwen3-VL-8B-Instruct \
2 --limit-mm-per-prompt.video 0 \
3 --max-model-len 8192 \
4 --mm-processor-cache-gb 0 \
5 --enable-lora \
6 --lora-modules price_tag_extractor=openfoodfacts/price-tag-extractor \
7 --max-lora-rank 32uv run chat.py https://prices.openfoodfacts.org/img/price-tags/000/143/000143456.webp)1# /// script
2# dependencies = [
3# "openai==2.15.0",
4# "typer",
5# "requests"
6# ]
7# ///
8import json
9import time
10from typing import Annotated
11
12import requests
13import typer
14from openai import OpenAI
15
16
17def main(
18 image_url: Annotated[
19 str, typer.Argument(help="URL of the price tag image to extract from")
20 ],
21 base_url: Annotated[
22 str, typer.Argument(help="Base URL for OpenAI-compatible server")
23 ] = "http://localhost:8000/v1",
24 api_key: Annotated[str, typer.Option(help="API key for authentication")] = "",
25 model_name: Annotated[
26 str,
27 typer.Option(
28 help="Model name to use, here it is the name of the registered LoRA adapters."
29 ),
30 ] = "price_tag_extractor",
31):
32 typer.echo(f"Extracting price tag information from image '{image_url}'", err=True)
33
34 client = OpenAI(base_url=base_url, api_key=api_key)
35
36 typer.echo("Fetching generation configuration...", err=True)
37 config = requests.get(
38 "https://huggingface.co/datasets/openfoodfacts/price-tag-extraction/resolve/v1.1/config.json",
39 ).json()
40 json_schema = config["json_schema"]
41 instructions = config["instructions"]
42 json_schema_str = json.dumps(json_schema)
43 full_instructions = f"{instructions}\n\nResponse must be formatted as JSON, and follow this JSON schema:\n{json_schema_str}"
44
45 typer.echo("Sending request to model...", err=True)
46
47 start_time = time.monotonic()
48 response = client.chat.completions.create(
49 model=model_name,
50 messages=[
51 {
52 "role": "user",
53 "content": [
54 {
55 "type": "text",
56 "text": full_instructions,
57 },
58 {"type": "image_url", "image_url": {"url": image_url}},
59 ],
60 }
61 ],
62 )
63 end_time = time.monotonic()
64 typer.echo(f"Request completed in {end_time - start_time:.2f} seconds", err=True)
65 typer.echo(response.choices[0].message.content)
66
67
68if __name__ == "__main__":
69 typer.run(main)