Replies: 3 comments 7 replies
|
For better results with OCR replace lines 219 & 577 of pymupdf_service.py: This prevent the line fragmentation. (https://github.com/pymupdf/PyMuPDF/blob/78b39c13/docs/vars.rst#text-extraction-flags ) |
|
Just a quick "thank you" (¡gracias!) for this work, I've found it very usefull, but at least with OWUI v0.8.5 it doesn't work, soy i've modded it introducing this code: So, if anyone find this usefull like me, here's the modded service.py |
|
@rgaricano I am trying this approach and running the app locally and via docker both i can curl the endpoint to process the document and it works BUT i cannot make it work with the openwebui. I did the general settings for Content Extraction Engine as Also tried the updated code from @Arien02 but no result. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Example of External Content Extraction Engine
PyMuPDF with tesseract OCR as External Content Extraction Engine
Default Content Extraction Engine use pypdf for extract text from pdf files.
The inconvenient is that it doesn't can proccess images or do OCR over its.
Pymudf does it, throught tesseract (that also have GPU support), but there are Open-WebUI licenses incompatibilities for use it as integrated lib.
For that reason I implemented it as a External Content Extraction Engine.
The inconvenient is that when it's that the external Content Extraction Engine is not per file type, it have to manage all other file types too.
For solve it I added all other file types proccessing that are natively by default in Open-WebUI (or so I think, maybe some have escaped!) & also I improved it with:
Basically is a FastAPI HTTP service that implements the same API as expected by ExternalDocumentLoader.
Installation for linux (ubuntu):
Install tesseract plus (additional languages pack if necessary):
sudo apt install tesseract-ocr libtesseract-devsudo apt install tesseract-ocr-spa(https://tesseract-ocr.github.io/tessdoc/Data-Files.html)export TESSDATA_PREFIX="/usr/share/tesseract-ocr/5/tessdata")export CUDA_VISIBLE_DEVICES="0"set -a; source /etc/environment; set +a;)Install the pyMuPDF service:
python3 -m venv venv & source venv/bin/activate)pip install -r requirements.txt)python pymupdf_service.py)Configurable parameters:
Examples (for run the content extraction engine server):
pymupdf_service.py
requirements.txt
Tested with Open-WebUI v0.6.30
I don't use docker, but I left a dockfile and a yml with this service and with tesseract, if someone want to try or improve it. I didn't test its!!! (and it include all possible env vars, most of its unnecessaries)
Its need to be adapted to one's own needs!! (as language pack, ...)
docker-compose.gpu.yml
dockerfile.txt
All reactions