AKKI-AFK commited on
Commit
d475d8e
Β·
verified Β·
1 Parent(s): 7ea504f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +143 -7
README.md CHANGED
@@ -1,10 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: Cover Overlap Detection
3
- emoji: 🌍
4
- colorFrom: gray
5
- colorTo: gray
6
- sdk: docker
7
- pinned: false
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ“˜ Cover Validation API
2
+
3
+ Automated quality and layout validator for book covers.
4
+ Detects text overlaps, spacing issues, image quality problems, and manages workflow integration with Airtable, Google Drive, and Make automation.
5
+
6
+ ---
7
+
8
+ ## πŸš€ Overview
9
+
10
+ This FastAPI-based service processes book cover images or PDFs and validates layout rules automatically.
11
+ It aims to reduce manual QA time by 80% while maintaining 90%+ detection accuracy.
12
+
13
+ **Core validations include:**
14
+ - Author name overlapping with the *21st Century Emily Dickinson Award* badge zone.
15
+ - Text within unsafe margins (3 mm on sides, 9 mm bottom reserved area).
16
+ - Missing or unauthorized text in the award zone.
17
+ - Image sharpness, resolution, and alignment.
18
+
19
+ ---
20
+
21
+ ## βš™οΈ Technical Stack
22
+
23
+ | Component | Purpose |
24
+ |------------|----------|
25
+ | **FastAPI** | Core REST API |
26
+ | **EasyOCR + OpenCV** | Text and layout detection |
27
+ | **PyAirtable** | Database integration |
28
+ | **Make (Integromat)** | Workflow automation |
29
+ | **Google Drive** | File upload trigger |
30
+ | **Hugging Face Spaces (Docker)** | Deployment environment |
31
+
32
+ ---
33
+
34
+ ## 🧠 API Endpoints
35
+
36
+ ### `POST /analyze`
37
+ Uploads and validates a single cover file.
38
+
39
+ **Request**
40
+ - `multipart/form-data`
41
+ - field: `file` β†’ PNG or PDF file
42
+
43
+ **Response**
44
+ ```json
45
+ {
46
+ "isbn": "1234567890123",
47
+ "status": "PASS",
48
+ "confidence": 92.3,
49
+ "validation_message": "Image resolution and layout OK",
50
+ "airtable_record_id": "recXXXX"
51
+ }
52
+ ```
53
+
54
+ **Status logic**
55
+ - βœ… **PASS** – all layout and quality rules met
56
+ - ⚠️ **REVIEW NEEDED** – minor overlap, low resolution, or OCR uncertainty
57
+
58
  ---
59
+
60
+ ## 🧩 Automation Workflow
61
+
62
+ **Trigger:**
63
+ Book cover uploaded to a Google Drive folder.
64
+
65
+ **Pipeline:**
66
+ 1. Google Drive β†’ Watch Files in Folder
67
+ 2. Download file
68
+ 3. HTTP β†’ POST to this API (`/analyze`)
69
+ 4. Parse JSON response
70
+ 5. Gmail β†’ Send formatted report to author
71
+ 6. (Optional) Airtable β†’ Log record update
72
+
73
+ All modules run inside one **Make.com scenario** for full automation.
74
+
75
  ---
76
 
77
+ ## βœ‰οΈ Email Template
78
+
79
+ ```
80
+ Subject: Cover Validation: {{status}}
81
+
82
+ Dear Author,
83
+
84
+ Your book cover has been reviewed by the automated validation system.
85
+
86
+ Status: {{status}}
87
+ Confidence: {{confidence}}%
88
+ Issues: {{issues}}
89
+
90
+ {{overlay_url}}
91
+
92
+ If status is "REVIEW NEEDED", please make the suggested corrections and re-upload your file.
93
+
94
+ – Validation Team
95
+ ```
96
+
97
+ ---
98
+
99
+ ## 🧾 Airtable Fields
100
+
101
+ | Field | Description |
102
+ |--------|--------------|
103
+ | Book ID (ISBN) | Extracted from filename |
104
+ | Detection Timestamp | UTC time of validation |
105
+ | Issue Type | Badge Overlap / Safe Margin / Quality |
106
+ | Status | PASS / REVIEW NEEDED |
107
+ | Confidence | 0–100% combined OCR + overlap score |
108
+ | Overlay URL | Annotated image |
109
+ | Correction Notes | Auto-generated text |
110
+ | Author Email | For notification mapping |
111
+
112
+ ---
113
+
114
+ ## πŸ§ͺ Local Development
115
+
116
+ ```bash
117
+ pip install -r requirements.txt
118
+ uvicorn main:app --reload
119
+ ```
120
+
121
+ Access Swagger UI at:
122
+ [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
123
+
124
+ ---
125
+
126
+ ## ☁️ Deployment (Hugging Face Spaces)
127
+
128
+ Uses **Docker SDK**:
129
+ ```dockerfile
130
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
131
+ ```
132
+ Environment variables (`Settings β†’ Variables and secrets`):
133
+ ```
134
+ AIRTABLE_BASE=appXXXX
135
+ AIRTABLE_TABLE=Book cover revision
136
+ AIRTABLE_KEY=keyXXXX
137
+ MAKE_WEBHOOK=https://hook.eu1.make.com/abcd1234efgh5678
138
+ ```
139
+
140
+ ---
141
+
142
+ ## πŸ”’ Notes
143
+
144
+ - SMTP ports are blocked on Spaces β†’ all emails sent through Make webhook.
145
+ - Use HTTPS APIs only for outbound requests.
146
+ - Models load once at startup for faster inference.