Proof & Price Tag Prediction Flow
This document maps prediction-related operations for both proof and price tag creation.
Flow Diagram
graph TD
A["Proof.save()"] -->|"post_save signal"| B["proof_post_create_run_ocr<br/><b>ASYNC TASK via django-q</b>"]
A -->|"post_save signal"| C["proof_post_create_run_ml_models"]
B --> B1["fetch_and_save_ocr_data"]
C --> D["run_and_save_proof_prediction<br/>with run_async=True"]
D --> E["run_and_save_proof_type_prediction<br/><b>ASYNC TASK via django-q</b>"]
E --> E1["predict_proof_type<br/>Triton model"]
E1 --> E2["ProofPrediction.create<br/>type=CLASSIFICATION"]
D --> F{"proof.type == TYPE_PRICE_TAG?"}
F -->|"Yes"| G["run_and_save_price_tag_detection<br/><b>ASYNC TASK via django-q</b>"]
G --> G1["detect_price_tags<br/>Triton model"]
G1 --> G2["ProofPrediction.create<br/>type=OBJECT_DETECTION"]
G2 --> G3["create_price_tags_from_proof_prediction"]
G3 --> G4["FOR EACH detection (score >= threshold):<br/>PriceTag.create(created_by=None)"]
G4 --> K
H --> H1["extract_from_price_tag<br/>Gemini API"]
H1 --> H2["PriceTagPrediction.create<br/>type=PRICE_TAG_EXTRACTION"]
D --> I{"proof.type == TYPE_RECEIPT and run_receipt_extraction?"}
I -->|"Yes"| J["run_and_save_receipt_extraction_prediction<br/><b>ASYNC TASK via django-q</b>"]
J --> J1["extract_from_receipt<br/>Gemini API"]
J1 --> J2["ProofPrediction.create<br/>type=PROOF_PREDICTION_RECEIPT_EXTRACTION"]
K["PriceTag.save()<br/>(automatic or manual)"] -->|"post_save signal"| L["price_tag_post_create_run_ml_models<br/><b>ASYNC TASKS via django-q</b>"]
L --> L1["run_and_save_price_tag_classification_from_id"]
L --> L2["run_and_save_price_tag_extraction_from_id"]
L1 --> G5["run_and_save_price_tag_classification"]
G5 --> G6["PriceTagPrediction.create<br/>type=PRICE_TAG_CLF"]
L2 --> H["run_and_save_price_tag_extraction"]
style A stroke:#2ecc71,stroke-width:3px
style B stroke:#e74c3c,stroke-width:3px
style B1 stroke:#2ecc71,stroke-width:3px
style C stroke:#e74c3c,stroke-width:3px
style D stroke:#2ecc71,stroke-width:3px
style E stroke:#e74c3c,stroke-width:3px
style E1 stroke:#2ecc71,stroke-width:3px
style E2 stroke:#2ecc71,stroke-width:3px
style G stroke:#e74c3c,stroke-width:3px
style G1 stroke:#2ecc71,stroke-width:3px
style G2 stroke:#2ecc71,stroke-width:3px
style G3 stroke:#2ecc71,stroke-width:3px
style G4 stroke:#2ecc71,stroke-width:3px
style G5 stroke:#2ecc71,stroke-width:3px
style G6 stroke:#2ecc71,stroke-width:3px
style H stroke:#2ecc71,stroke-width:3px
style H1 stroke:#2ecc71,stroke-width:3px
style H2 stroke:#2ecc71,stroke-width:3px
style J stroke:#e74c3c,stroke-width:3px
style J1 stroke:#2ecc71,stroke-width:3px
style J2 stroke:#2ecc71,stroke-width:3px
style K stroke:#2ecc71,stroke-width:3px
style L stroke:#e74c3c,stroke-width:3px
style L1 stroke:#2ecc71,stroke-width:3px
style L2 stroke:#2ecc71,stroke-width:3px
Notes
- Green border: synchronous execution.
- Red border: asynchronous execution (django-q task).
- Price tags created automatically (from a proof detection) and manually (by a user) go through the same
post_savesignal, which runs classification and extraction in parallel (one task per price tag).
Configuration
ENABLE_ML_PREDICTIONSENABLE_OCR