mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-17 06:57:45 +01:00
0605-16:56
This commit is contained in:
parent
e269eb06da
commit
f39d8e5985
@ -63,8 +63,12 @@ PREPROCESSING_PROFILES = {
|
|||||||
def preprocess_image(image_path: str, **settings) -> Image.Image:
|
def preprocess_image(image_path: str, **settings) -> Image.Image:
|
||||||
img = Image.open(image_path).convert("RGB")
|
img = Image.open(image_path).convert("RGB")
|
||||||
base_name = os.path.basename(image_path)
|
base_name = os.path.basename(image_path)
|
||||||
|
|
||||||
|
# Gestion des dossiers de debug
|
||||||
debug_dir = settings.get("debug_output_dir", "debug_ocr_preprocessed")
|
debug_dir = settings.get("debug_output_dir", "debug_ocr_preprocessed")
|
||||||
os.makedirs(debug_dir, exist_ok=True)
|
profile_name = settings.get("profile_name", "default") # Ajout du nom du profil
|
||||||
|
debug_profile_dir = os.path.join(debug_dir, profile_name)
|
||||||
|
os.makedirs(debug_profile_dir, exist_ok=True)
|
||||||
|
|
||||||
# Redimensionnement
|
# Redimensionnement
|
||||||
if settings.get("resize_min_dim", 0) > 0:
|
if settings.get("resize_min_dim", 0) > 0:
|
||||||
@ -115,11 +119,12 @@ def preprocess_image(image_path: str, **settings) -> Image.Image:
|
|||||||
|
|
||||||
# Sauvegarde image prétraitée (debug)
|
# Sauvegarde image prétraitée (debug)
|
||||||
if settings.get("save_debug_output", False):
|
if settings.get("save_debug_output", False):
|
||||||
debug_path = os.path.join(debug_dir, f"optimized_{base_name}")
|
debug_path = os.path.join(debug_profile_dir, f"optimized_{base_name}")
|
||||||
cv2.imwrite(debug_path, img_cv)
|
cv2.imwrite(debug_path, img_cv)
|
||||||
|
|
||||||
return Image.fromarray(cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB))
|
return Image.fromarray(cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB))
|
||||||
|
|
||||||
def preprocess_image_with_profile(image_path: str, profile_name="default") -> Image.Image:
|
def preprocess_image_with_profile(image_path: str, profile_name="default") -> Image.Image:
|
||||||
settings = PREPROCESSING_PROFILES[profile_name]
|
settings = PREPROCESSING_PROFILES[profile_name].copy() # On fait une copie pour ne pas modifier l'original
|
||||||
|
settings["profile_name"] = profile_name # On ajoute le nom du profil aux paramètres
|
||||||
return preprocess_image(image_path, **settings)
|
return preprocess_image(image_path, **settings)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user