-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
65 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,28 +0,0 @@ | ||
from .transformers_service import TransformersService | ||
from .vector_db_context import VectorDbContext | ||
from ..config import config, environment | ||
|
||
transformers_service = TransformersService() | ||
db_context = VectorDbContext() | ||
ocr_service = None | ||
|
||
if environment.local_indexing: | ||
match config.ocr_search.ocr_module: | ||
case "easyocr": | ||
from .ocr_services import EasyOCRService | ||
|
||
ocr_service = EasyOCRService() | ||
case "easypaddleocr": | ||
from .ocr_services import EasyPaddleOCRService | ||
|
||
ocr_service = EasyPaddleOCRService() | ||
case "paddleocr": | ||
from .ocr_services import PaddleOCRService | ||
|
||
ocr_service = PaddleOCRService() | ||
case _: | ||
raise NotImplementedError(f"OCR module {config.ocr_search.ocr_module} not implemented.") | ||
else: | ||
from .ocr_services import DisabledOCRService | ||
|
||
ocr_service = DisabledOCRService() | ||
This file contains 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 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,31 @@ | ||
from .index_service import IndexService | ||
from .transformers_service import TransformersService | ||
from .vector_db_context import VectorDbContext | ||
from ..config import config, environment | ||
|
||
transformers_service = TransformersService() | ||
db_context = VectorDbContext() | ||
ocr_service = None | ||
|
||
if environment.local_indexing: | ||
match config.ocr_search.ocr_module: | ||
case "easyocr": | ||
from .ocr_services import EasyOCRService | ||
|
||
ocr_service = EasyOCRService() | ||
case "easypaddleocr": | ||
from .ocr_services import EasyPaddleOCRService | ||
|
||
ocr_service = EasyPaddleOCRService() | ||
case "paddleocr": | ||
from .ocr_services import PaddleOCRService | ||
|
||
ocr_service = PaddleOCRService() | ||
case _: | ||
raise NotImplementedError(f"OCR module {config.ocr_search.ocr_module} not implemented.") | ||
else: | ||
from .ocr_services import DisabledOCRService | ||
|
||
ocr_service = DisabledOCRService() | ||
|
||
index_service = IndexService(ocr_service, transformers_service, db_context) |
Empty file.
This file contains 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 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 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 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,11 @@ | ||
from pathlib import Path | ||
|
||
from loguru import logger | ||
|
||
|
||
def gather_valid_files(root: Path): | ||
for item in root.glob('**/*.*'): | ||
if item.suffix in ['.jpg', '.png', '.jpeg', '.jfif', '.webp', '.gif']: | ||
yield item | ||
else: | ||
logger.warning("Unsupported file type: {}. Skip...", item.suffix) |