Hugging Faceyuvraj sharma, Freddy Boulton, Abubakar AbidTutorial
How to build scalable web apps with OpenAI's Privacy Filter
Summary
The article presents three web applications built around OpenAI’s open-source Privacy Filter, a PII detector that labels eight categories in one forward pass over a 128k-token context. Document Privacy Explorer extracts PDF or DOCX text and returns category-labeled spans, while Image Anonymizer combines Tesseract word boxes with character offsets to produce editable pixel redaction rectangles. SmartRedact Paste replaces detected spans with category placeholders, stores public and token-gated views, and evicts expired pastes in a daemon thread. Across the apps, gradio.Server’s @server.api routes model work through Gradio’s queue and gradio_client, while plain FastAPI routes serve custom HTML, views, and lightweight lookups. The implementations keep browser-side filtering, canvas edits, and PNG export out of server round-trips, and the paste service is about 200 lines including storage.
Context
The applications address three explicit needs: reading PII-heavy documents with highlighted spans and category filters; sharing screenshots with adjustable black-bar redactions; and creating pastebin-style links that expose redacted text publicly while reserving the original for a token-gated reveal link.
Approach / What changed
Privacy Filter processes document text, OCR-reconstructed image text, or pasted text in a single model call. The applications use gradio.Server’s @server.api for queued model operations and plain FastAPI routes for custom pages, views, and lightweight lookups. Browser code handles category toggles, canvas edits, PNG export, and rendering, while SmartRedact Paste stores redacted and original versions with generated identifiers and reveal tokens.
Takeaways
Privacy Filter has 1.5B parameters, 50M active parameters, an Apache 2.0 license, eight PII categories, and a 128,000-token context.
@server.api connects model handlers to Gradio queueing, ZeroGPU composition, progress events, and gradio_client access from both browser and Python clients.
Image Anonymizer maps Privacy Filter’s character spans back to OCR word boxes, joins them into pixel rectangles, and keeps bar edits and PNG export in the browser.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.