Geraldine commited on
Commit
ef0156e
·
verified ·
1 Parent(s): 006f21c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -26
app.py CHANGED
@@ -177,27 +177,21 @@ MODEL_MAP = {
177
  MODEL_CHOICES = list(MODEL_MAP.keys())
178
 
179
  PROMPTS = {
180
- "GENERAL": {
181
- "name": "General Text Extraction",
182
- "description": "Extract all text from this cover page",
183
- "prompt": "Extract all text from this image. Preserve the layout and structure. Output plain text.",
184
- "icon": "📄"
185
- },
186
- "MARKDOWN": {
187
- "name": "Simple Markdown Conversion",
188
- "description": "Convert document to Markdown format",
189
- "prompt": "Convert this document to Markdown. Preserve headings, lists, and formatting.",
190
  "icon": "📝"
191
  },
192
- "MARKDOWN_OCR": {
193
- "name": "Markdown OCR",
194
  "description": "Perform OCR and convert to Markdown",
195
  "prompt": "Perform OCR including inside images and logos and convert to Markdown.",
196
  "icon": "🔍"
197
  },
198
- "TITLE_JSON": {
199
- "name": "Title JSON",
200
- "description": "Extract title as JSON",
201
  "prompt": """Extract the document title from this cover page.
202
  Output ONLY valid JSON:
203
  {
@@ -205,9 +199,9 @@ Output ONLY valid JSON:
205
  }""",
206
  "icon": "🏷️"
207
  },
208
- "LOCATED_TITLE_JSON": {
209
- "name": "Located Title JSON",
210
- "description": "Extract located title as JSON",
211
  "prompt": """Extract the document title from the middle central block of this cover page.
212
  Output ONLY valid JSON:
213
  {
@@ -215,9 +209,9 @@ Output ONLY valid JSON:
215
  }""",
216
  "icon": "📍"
217
  },
218
- "GROUNDED_TITLE_JSON": {
219
- "name": "Grounded Title JSON",
220
- "description": "Extract grounded title as JSON",
221
  "prompt": """Extract the document title usually located around (x=0.5015, y=0.442) from this cover page.
222
  Output ONLY valid JSON:
223
  {
@@ -283,11 +277,11 @@ Return ONLY the JSON, no explanation.""",
283
  }
284
 
285
  image_examples = [
286
- {"query": PROMPTS["GENERAL"]["prompt"], "image": "examples/dumas_01382452.png", "model": "Nanonets-OCR2-3B"},
287
- {"query": PROMPTS["MARKDOWN_OCR"]["prompt"], "image": "examples/dumas_01646440.png", "model": "olmOCR-7B-0725"},
288
- {"query": PROMPTS["TITLE_JSON"]["prompt"], "image": "examples/ephesvt_theses_doc13.jpg", "model": "Qwen3-VL-4B-Instruct"},
289
- {"query": PROMPTS["LOCATED_TITLE_JSON"]["prompt"], "image": "examples/memoires_cridaf_doc07.jpg", "model": "Qwen2-VL-OCR-2B"},
290
- {"query": PROMPTS["GROUNDED_TITLE_JSON"]["prompt"], "image": "examples/thesefr_2015PA010690.png", "model": "LightOnOCR-2-1B"},
291
  {"query": "", "image": "examples/thesefr_2015PA010690.png", "model": "LightOnOCR-2-1B"},
292
  ]
293
 
 
177
  MODEL_CHOICES = list(MODEL_MAP.keys())
178
 
179
  PROMPTS = {
180
+ "OCR_GENERAL": {
181
+ "name": "Simple Text Etraction",
182
+ "description": "Extract the text including inside images and logos",
183
+ "prompt": "Extract the text including inside images and logos",
 
 
 
 
 
 
184
  "icon": "📝"
185
  },
186
+ "OCR_MARKDOWN": {
187
+ "name": "OCR -> Markdown",
188
  "description": "Perform OCR and convert to Markdown",
189
  "prompt": "Perform OCR including inside images and logos and convert to Markdown.",
190
  "icon": "🔍"
191
  },
192
+ "STRUCTURED_EXTRACTION": {
193
+ "name": "Json Metadata Extraction",
194
+ "description": "Extract metadata",
195
  "prompt": """Extract the document title from this cover page.
196
  Output ONLY valid JSON:
197
  {
 
199
  }""",
200
  "icon": "🏷️"
201
  },
202
+ "STRUCTURED_LOCATED_EXTRACTION": {
203
+ "name": "Located Json Metadata Extraction",
204
+ "description": "Extract located metadata",
205
  "prompt": """Extract the document title from the middle central block of this cover page.
206
  Output ONLY valid JSON:
207
  {
 
209
  }""",
210
  "icon": "📍"
211
  },
212
+ "STRUCTURED_GROUNDED_EXTRACTION": {
213
+ "name": "Grounded Json Metadata Extraction",
214
+ "description": "Extract grounded metadata",
215
  "prompt": """Extract the document title usually located around (x=0.5015, y=0.442) from this cover page.
216
  Output ONLY valid JSON:
217
  {
 
277
  }
278
 
279
  image_examples = [
280
+ {"query": PROMPTS["OCR_GENERAL"]["prompt"], "image": "examples/dumas_01382452.png", "model": "Nanonets-OCR2-3B"},
281
+ {"query": PROMPTS["OCR_MARKDOWN"]["prompt"], "image": "examples/dumas_01646440.png", "model": "olmOCR-7B-0725"},
282
+ {"query": PROMPTS["STRUCTURED_EXTRACTION"]["prompt"], "image": "examples/ephesvt_theses_doc13.jpg", "model": "Qwen3-VL-4B-Instruct"},
283
+ {"query": PROMPTS["STRUCTURED_LOCATED_EXTRACTION"]["prompt"], "image": "examples/memoires_cridaf_doc07.jpg", "model": "Qwen2-VL-OCR-2B"},
284
+ {"query": PROMPTS["STRUCTURED_GROUNDED_EXTRACTION"]["prompt"], "image": "examples/thesefr_2015PA010690.png", "model": "LightOnOCR-2-1B"},
285
  {"query": "", "image": "examples/thesefr_2015PA010690.png", "model": "LightOnOCR-2-1B"},
286
  ]
287