Spaces:
Running on Zero
Running on Zero
Add images or a PDF: a PDF adds one page per sheet
Browse filesFiles changed (3)
- README.md+1-1
- app.py+24-1
- requirements.txt+1
14 unmodified lines1516171819202114 unmodified linesAsk a document typed questions (yes/no, pick-one, labelled boxes on the page, labelled spans in the text) and getevery answer from one read, each with a calibrated confidence. Pick an example from document pages (invoice, tax form,layout, page-stream splitting, open-vocabulary classification), photos, text (PII, RAG answer check, RAG retrieval) oragents (which actions a policy allows, routing a finished run, a browser agent's next step), or upload your own pages,and edit the request freely. A slider on the result chooses the confidence from which boxes and spans are shown.- 📄 **Scorecard:** [nutrient-document-decision-v2](https://huggingface.co/nutrientdocs/nutrient-document-decision-v2)14 unmodified lines1516171819202114 unmodified linesAsk a document typed questions (yes/no, pick-one, labelled boxes on the page, labelled spans in the text) and getevery answer from one read, each with a calibrated confidence. Pick an example from document pages (invoice, tax form,layout, page-stream splitting, open-vocabulary classification), photos, text (PII, RAG answer check, RAG retrieval) oragents (which actions a policy allows, routing a finished run, a browser agent's next step), or upload your own pages (images, or a PDF, which adds one page per sheet),and edit the request freely. A slider on the result chooses the confidence from which boxes and spans are shown.- 📄 **Scorecard:** [nutrient-document-decision-v2](https://huggingface.co/nutrientdocs/nutrient-document-decision-v2)
131 unmodified lines132133134135136137281 unmodified lines419420421422423424425108 unmodified lines534535536537538539131 unmodified linesreturn [(p, k) for k, p in page_list(gallery)]def page_bytes(path):fmt = Path(path).suffix.lstrip(".").lower().replace("jpg", "jpeg")if fmt in FORMATS:281 unmodified linespages = gr.Gallery(label="Pages",columns=4, height=240, interactive=True, type="filepath", file_types=["image"],object_fit="contain", allow_preview=False)gr.Markdown("<sub>Drop images to add pages; they are page_1, page_2, … in order.</sub>")gr.Markdown("### State: the document")@gr.render(inputs=[state_code, pages], triggers=[s_rev.change])108 unmodified linesev.then(bump, s_rev, s_rev).then(bump, q_rev, q_rev).then(**preview).then(panels, q_code, [drawn, spans]).then(lambda: gr.Tabs(selected="request"), None, out_tabs)pages.upload(relabel, pages, pages).then(bump, s_rev, s_rev).then(**preview)pages.delete(relabel, pages, pages).then(bump, s_rev, s_rev).then(**preview)state_code.input(**preview)q_code.input(**preview)131 unmodified lines132133134135136137138139140141142143144145146147148149150151152153154155156281 unmodified lines438439440441442443444445446447108 unmodified lines556557558559560561562131 unmodified linesreturn [(p, k) for k, p in page_list(gallery)]def add_files(gallery, files):"""Uploaded images and PDFs -> pages appended to the gallery; a PDF adds one page per sheet (rendered at 144 dpi)."""import tempfileimport pypdfium2paths = [p for _, p in page_list(gallery)]for f in files or []:f = getattr(f, "name", f)if str(f).lower().endswith(".pdf"):doc = pypdfium2.PdfDocument(f)for n in range(len(doc)):out = os.path.join(tempfile.mkdtemp(), f"{Path(f).stem}_p{n + 1}.png")doc[n].render(scale=2).to_pil().convert("RGB").save(out)paths.append(out)doc.close()else:paths.append(str(f))return [(p, f"page_{i}") for i, p in enumerate(paths, 1)]def page_bytes(path):fmt = Path(path).suffix.lstrip(".").lower().replace("jpg", "jpeg")if fmt in FORMATS:281 unmodified linespages = gr.Gallery(label="Pages",columns=4, height=240, interactive=True, type="filepath", file_types=["image"],object_fit="contain", allow_preview=False)with gr.Row(equal_height=True):add_files_btn = gr.UploadButton("Add images or a PDF", file_types=["image", ".pdf"], file_count="multiple",size="sm", scale=0, min_width=170)gr.Markdown("<sub>A PDF adds one page per sheet. Pages are page_1, page_2, … in order.</sub>")gr.Markdown("### State: the document")@gr.render(inputs=[state_code, pages], triggers=[s_rev.change])108 unmodified linesev.then(bump, s_rev, s_rev).then(bump, q_rev, q_rev).then(**preview).then(panels, q_code, [drawn, spans]).then(lambda: gr.Tabs(selected="request"), None, out_tabs)pages.upload(relabel, pages, pages).then(bump, s_rev, s_rev).then(**preview)add_files_btn.upload(add_files, [pages, add_files_btn], pages).then(bump, s_rev, s_rev).then(**preview)pages.delete(relabel, pages, pages).then(bump, s_rev, s_rev).then(**preview)state_code.input(**preview)q_code.input(**preview)
6 unmodified lines7896 unmodified linespyarrowpillownumpy6 unmodified lines789106 unmodified linespyarrowpillownumpypypdfium2
README.md+1-1
app.py+24-1
requirements.txt+1