-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: integrate got-ocr2.0 as image reader #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
phv2312
wants to merge
18
commits into
Cinnamon:main
Choose a base branch
from
phv2312:feat/integrate_3rd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bb0f46e
feat: update stale action
phv2312 93ec972
feat: comfort gocr2 format
phv2312 4b7e9ca
fix: resolve conflicts
phv2312 84e5683
feat: resolve conflicts
phv2312 8157733
feat: update state for extension manager while load setting
phv2312 53c7203
fix: resolve conflicts
phv2312 e6b4439
feat: comfort pre-commit
phv2312 02f8a81
feat: update ocr loader
phv2312 fca8a10
feat: change default loader for image
phv2312 d9b9bc1
feat: update guideline
phv2312 dfc416e
feat: update github stales & remove unncessary files
phv2312 3f5d1fb
feat: update extentions for pdf
phv2312 a358fd2
feat: introduce docker-compose
phv2312 609a1f0
chore: refactor by pre-commit
phv2312 ae56308
feat: update docling reader into extension manager
phv2312 9bbd8a1
feat: bring extension manager to kotaemon
phv2312 038dabb
refactor: move exteions manager to ktem
cin-niko cb4fabc
fix: remove duplicate loader setting in retrieval settings
cin-niko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Close stale issues | ||
on: | ||
schedule: | ||
- cron: "0 0 * * *" # Runs at 00:00 UTC every day | ||
|
||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/stale@v9 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
stale-issue-message: | | ||
Hi folk 😊, it looks like this issue has been inactive for a while. Is there any update or further action | ||
needed? If not, we might consider closing it soon to keep our board clean and focused. | ||
|
||
But don't worry, you can reopen it anytime when needed.Thank you for your contributions to Kotaemon🪴 | ||
|
||
days-before-issue-stale: 30 | ||
days-before-issue-close: 3 | ||
days-before-pr-stale: 90 | ||
days-before-pr-close: -1 | ||
exempt-issue-labels: "documentation,tutorial,TODO" | ||
operations-per-run: 300 # The maximum number of operations per run, used to control rate limiting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
kotaemon: | ||
volumes: | ||
- "./ktem_app_data:/app/ktem_app_data" | ||
- "./libs/kotaemon:/app/kotaemon" | ||
- "./libs/ktem:/app/ktem" | ||
- "./flowsettings.py:/app/flowsettings.py" | ||
ports: | ||
- "7860:7860" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
services: | ||
kotaemon: | ||
build: | ||
context: . | ||
target: lite | ||
dockerfile: Dockerfile | ||
env_file: .env | ||
environment: | ||
- GRADIO_SERVER_NAME=0.0.0.0 | ||
- GRADIO_SERVER_PORT=7860 | ||
ports: | ||
- "7860:7860" | ||
networks: | ||
- backend | ||
# gocr: | ||
# image: ghcr.io/phv2312/got-ocr2.0:main | ||
# ports: | ||
# - "8881:8881" | ||
# deploy: | ||
# resources: | ||
# reservations: | ||
# devices: | ||
# - driver: nvidia | ||
# count: 1 | ||
# capabilities: [gpu] | ||
# networks: | ||
# - backend | ||
networks: | ||
backend: | ||
driver: bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Extension Manager and GOT-OCR2.0 Loader | ||
|
||
## Key Features | ||
|
||
### 1. **GOCR2 as Image Reader** | ||
|
||
- **GOCR2ImageReader** is a new class designed to read images using the [**GOCR-2.0** OCR engine](https://github.com/Ucas-HaoranWei/GOT-OCR2.0). | ||
- This reader is initialized with an endpoint that defaults to `http://localhost:8881/ai/infer/` for the OCR service, but can be configured through an environment variable `GOCR2_ENDPOINT` or passed explicitly. | ||
- It uses exponential backoff retry mechanisms to ensure robustness during API calls. | ||
- Supports loading image files and extracting their text content, returning structured document data. | ||
|
||
#### Setup | ||
|
||
- We provide the docker image, with fastapi for serving the GOT-OCR2.0. Pull the image from: | ||
|
||
```bash | ||
docker run -d --gpus all -p 8881:8881 ghcr.io/phv2312/got-ocr2.0:main | ||
phv2312 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
- Detail implementation is placed at [ocr_loader.py](/libs/kotaemon/kotaemon/loaders/ocr_loader.py) | ||
|
||
### 2. **Extension Manager** | ||
|
||
- ExtensionManager allows users to dynamically manage multiple loaders for different file types. | ||
|
||
- Users can switch between multiple loaders for the same file extension, such as using the GOCR2ImageReader or a | ||
different unstructured data parser for .png files. This provides the flexibility to choose the best-suited loader for the task at hand. | ||
|
||
- To change the default loader, go to **Settings**, then **Loader settings**. It displays a grid of extensions and | ||
its supported loaders. Any modification will be saved to DB as other settings do. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.