Spaces:
Running
Running
File size: 1,134 Bytes
fcb8b13 be398ac fcb8b13 be398ac fcb8b13 be398ac fcb8b13 be398ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# core/data_processing/image_processor.py
import os
from typing import List, Dict, Any
from utils.logger import logger
class ImageProcessor:
def __init__(self):
logger.info("ImageProcessor initialized.")
def process(self, file_path: str) -> List[Dict[str, Any]]:
try:
logger.debug(f"Processing image file: {file_path}")
if not os.path.exists(file_path):
logger.error(f"Image file not found: {file_path}")
return []
# create id by filename
base_name = os.path.basename(file_path)
chunk_id = f"{os.path.splitext(base_name)[0]}_image_chunk"
metadata = {
"source_id": base_name,
"type": "image",
"chunk_id": chunk_id,
"chunk_data_path": file_path
}
chunk = {
"content": file_path,
"metadata": metadata
}
return [chunk]
except Exception as e:
logger.error(f"Error processing image file {file_path}: {e}")
return [] |