§
    �Wêjý  ã                   ó   — d Z ddlmZ dd„ZdS )aD  
Image Model Features (IMF) extraction
Maintained by: AI Researchers
Purpose: Extract image-based features using neural network (ONNX)

image_feature_extraction_task() is the stable interface for pymupdf_util_ext.py.
Inference and detection logic lives in ImageFeatureExtractorV1 / V2.

feature_map / class_logits are returned SEPARATELY (not concatenated):
they have different statistical character (continuous embedding vs.
per-class score) and are meant to be pooled differently downstream -- see
roi_pooling.DEFAULT_FEATURE_MAP_POOLING_OPS / DEFAULT_CLASS_LOGITS_POOLING_OPS.
é   )Ú	BOX_IMAGENc                 óP  — |                      ¦   «         s|                     | |¬¦  «         |                     ¦   «         }|                     ¦   «         }g }g }d|v rF|                     ¦   «         D ]1}|                     |¦  «         |                     t          ¦  «         Œ2||||fS )u¶  
    Extract image-based features and segmentation-derived bboxes.

    Args:
        page_img:         np.ndarray (H, W, C), uint8 â€” page raster image
        feature_extractor: ImageFeatureExtractorV1 / V2 instance
        input_type:       tuple of element types; 'seg-image' enables bbox detection
        aug_fetmap:       optional extra channel map passed to predict()

    Returns:
        feature_map:      decoder embedding output, shape (1, 5*F, H, W)
        class_logits:     per-class segmentation logits, shape (1, C, H, W)
        bboxes_to_add:    list of [x1, y1, x2, y2] in page pixel space
        box_types_to_add: list of box type strings (parallel to bboxes_to_add)
    )Ú
aug_fetmapz	seg-image)Úconsume_cacheÚpredictÚget_feature_mapÚget_class_logitsÚget_picture_detectionsÚappendr   )	Úpage_imgÚfeature_extractorÚ
input_typer   Úfeature_mapÚclass_logitsÚbboxes_to_addÚbox_types_to_addÚbboxs	            ú‘/Users/tedpeters/Documents/Projects/Claude Projects/TPC Houses/house-viewer/.venv/lib/python3.11/site-packages/pymupdf/layout/pymupdf_util_imf.pyÚimage_feature_extraction_taskr      sÀ   € ð" ×*Ò*Ñ,Ô,ð CØ×!Ò! (°zÐ!ÑBÔBÐBà#×3Ò3Ñ5Ô5€KØ$×5Ò5Ñ7Ô7€LØ€MØÐà�jÐ Ð Ø%×<Ò<Ñ>Ô>ð 	/ð 	/ˆDØ× Ò  Ñ&Ô&Ð&Ø×#Ò#¥IÑ.Ô.Ð.Ð.à˜ mÐ5EÐEÐEó    )N)Ú__doc__Úpymupdf_util_baser   r   © r   r   ú<module>r      sG   ððð ð )Ð (Ð (Ð (Ð (Ð (ðFð Fð Fð Fð Fð Fr   