mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Support Indexing Images via OCR (#823)
- Added support for uploading .jpeg, .jpg, and .png files to Khoj from Web, Desktop app
- Updating indexer to generate raw text and entries using RapidOCR
- Details
* added support for indexing images via ocr
* fixed pyproject.toml
* Update src/khoj/processor/content/images/image_to_entries.py
Co-authored-by: Debanjum <debanjum@gmail.com>
* Update src/khoj/processor/content/images/image_to_entries.py
Co-authored-by: Debanjum <debanjum@gmail.com>
* removed redudant try except blocks
* updated desktop js file to support image formats
* added tests for jpg and png
* Fix processing for image to entries files
* Update unit tests with working image indexer
* Change png test from version verificaition to open-cv verification
---------
Co-authored-by: Debanjum <debanjum@gmail.com>
Co-authored-by: sabaimran <narmiabas@gmail.com>
This commit is contained in:
BIN
tests/data/images/nasdaq.jpg
vendored
Normal file
BIN
tests/data/images/nasdaq.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
BIN
tests/data/images/testocr.png
vendored
Normal file
BIN
tests/data/images/testocr.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
21
tests/test_image_to_entries.py
Normal file
21
tests/test_image_to_entries.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
from khoj.processor.content.images.image_to_entries import ImageToEntries
|
||||
|
||||
|
||||
def test_png_to_jsonl():
|
||||
with open("tests/data/images/testocr.png", "rb") as f:
|
||||
image_bytes = f.read()
|
||||
data = {"tests/data/images/testocr.png": image_bytes}
|
||||
entries = ImageToEntries.extract_image_entries(image_files=data)
|
||||
assert len(entries) == 2
|
||||
assert "opencv-python" in entries[1][0].raw
|
||||
|
||||
|
||||
def test_jpg_to_jsonl():
|
||||
with open("tests/data/images/nasdaq.jpg", "rb") as f:
|
||||
image_bytes = f.read()
|
||||
data = {"tests/data/images/nasdaq.jpg": image_bytes}
|
||||
entries = ImageToEntries.extract_image_entries(image_files=data)
|
||||
assert len(entries) == 2
|
||||
assert "investments" in entries[1][0].raw
|
||||
Reference in New Issue
Block a user