Views
No views yet
1{
2 "店舗名": "セブンイレブン渋谷店",
3 "日付": "2024年01月15日",
4 "時刻": "14:30",
5 "レシートNo": "0001234",
6 "商品リスト": [
7 {
8 "商品名": "おにぎり鮭",
9 "数量": 1,
10 "単価": 128,
11 "金額": 128
12 }
13 ],
14 "小計": 840,
15 "消費税": 84,
16 "合計": 924,
17 "支払方法": "現金",
18 "お預り": 1000,
19 "お釣り": 76
20}
1{
2 "領収書": {
3 "店舗情報": [
4 {
5 "店名": "業務スーパー河内屋",
6 "場所": "青葉台店",
7 "電話": "045-985-9603"
8 }
9 ]
10 },
11 "登録番号": "T7011701002269",
12 "メッセージ": {
13 "内容": "プロの品質とプロの価格 業務スーパーでは毎日のお買い得となっています。"
14 },
15 "発行日": {
16 "月日年分類": "72025年 7月12日",
17 "担当者": "土田"
18 },
19 "商品情報": [
20 {
21 "名前": "鶏卵赤玉MSP",
22 "個数": "10個入り",
23 "価格": "¥237"
24 },
25 {
26 "名前": "マカロニ(セダーニーニー)500G。",
27 "個数": "¥138",
28 "商品詳細": "021 4901995400119"
29 },
30 {
31 "名前": "JUCO VIA(業)チュータースライサイズ",
32 "価格": "¥2418"
33 },
34 {
35 "名前": "協同牛乳 酪農牛乳 1L",
36 "価格": "¥199",
37 "商品詳細": "021 496168110063"
38 },
39 {
40 "名前": "おかも納豆極小粒ミニ",
41 "価格": "¥76"
42 },
43 {
44 "名前": "★協同牛乳",
45 "個数": "2418",
46 "商品詳細": "021 4901160010143"
47 }
48 ],
49 "税情報": {
50 "轻減税率対象": {
51 "金額": "1,068",
52 "割合": "%",
53 "外税買上額": "¥1,068",
54 "外税額": "¥85",
55 "税額合計": "¥85"
56 }
57 },
58 "合計情報": {
59 "金額": {
60 "合計": "¥1,153",
61 "外税合計": {
62 "金額": "1,068",
63 "割合": "%",
64 "外税合計": "¥1,068",
65 "外税合計割合": "%",
66 "税額合計": "¥85"
67 }
68 },
69 "お預り": "¥5,000",
70 "お釣り": "¥3,847"
71 },
72 "備考": {
73 "内容": "本問保管上のお願い財布・手帳等にはさんで保管頂く場合は、印刷面を内側に折り保管をお願いします"
74 },
75 "バーコード": {
76 "6829": "6821",
77 "日付": "11:20"
78 }
79}1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from PIL import Image
3
4# Load model and processor
5model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
6 "your-username/Japanese-Receipt-VL-3B-JSON"
7)
8processor = AutoProcessor.from_pretrained("your-username/Japanese-Receipt-VL-3B-JSON")
9
10# Load receipt image
11image = Image.open("japanese_receipt.jpg")
12
13# Optimized instruction prompt for Japanese receipt extraction
14instruct_prompt = """You are an intelligent document parser. Read the following Japanese receipt and extract every piece of information exactly as it appears, and present it in a well-structured JSON format using Japanese keys and values. Please strictly follow these rules: Only extract information that is actually present on the receipt. Do not include any missing, blank, or inferred fields. Do not summarize, omit, translate, or modify any part of the receipt. Every character, number, symbol, and line must be retained exactly as printed. Extract all available content including but not limited to: store details, receipt number, date, time, cashier name, product list, prices, tax breakdowns, payment details, receipt bags, barcodes, notices, and any footer messages. Preserve original formatting such as line breaks, symbols, and full-width characters (hiragana, katakana, kanji, numbers, etc.). Do not perform any translation, correction, interpretation, or reformatting of content. Use only what is present. Output the result in JSON format, using Japanese field names as keys."""
15
16# Prepare input
17messages = [
18 {
19 "role": "user",
20 "content": [
21 {"type": "image", "image": image},
22 {"type": "text", "text": instruct_prompt}
23 ]
24 }
25]
26
27# Process
28text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
29inputs = processor(text=[text], images=[image], return_tensors="pt")
30outputs = model.generate(**inputs, max_new_tokens=512)
31result = processor.batch_decode(outputs, skip_special_tokens=True)[0]
32print(result)1from your_preprocessing import process_receipt_image
2
3# Preprocess image for optimal results
4processed_image = process_receipt_image(
5 "receipt.jpg",
6 target_width=640,
7 target_height=896
8)1@model{japanese-receipt-vl-3b-json,
2 title={Japanese-Receipt-VL-3B-JSON: Fine-tuned Vision-Language Model for Japanese Receipt OCR},
3 author={[Your Name]},
4 year={2024},
5 publisher={Hugging Face},
6 journal={Hugging Face Model Hub},
7 howpublished={\url{https://huggingface.co/your-username/Japanese-Receipt-VL-3B-JSON}},
8 note={Trained on Japanese-Mobile-Receipt-OCR-1K dataset}
9}Sabari Nathan / Couger Inc,Japanvision-language, japanese, ocr, receipt-processing, json-extraction, qwen2.5-vl, multimodal, fine-tuned