CoolFace
Apppublic

tyriaa/Segmentation_project

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
predictor.cpython-311.pyc28 linesDownload Raw Back to __pycache__
12:>g���@�ddlZddlmZddlmZGd�d��ZdS)�N)�3build_sam2)�SAM2ImagePredictorc�"�eZdZd�Zd�Zdd�ZdS)�	Predictorc��||_t|||���|_t|j��|_d|_dS)N)�deviceF)rr�modelr�	predictor�	image_set)�self�	model_cfg�4checkpointrs    �CC:\Users\marcv\Desktop\project\segmentation_tool\utils\predictor.py�__init__zPredictor.__init__s;������	�:�f�E�E�E��5�+�D�J�7�7��������c�V�||_|j�|��d|_dS)z!Set the image for SAM prediction.TN)�imager6�	set_imager)rrs  rrzPredictor.set_images*����7��� � ��'�'�'�����rFc�h�|jstd���|j�|||���S)zRun SAM prediction.zAAn image must be set with .set_image(...) before mask prediction.)�point_coords�point_labels�multimask_output)r�RuntimeErrorr8�predict)rrrrs    rrzPredictor.predictsD���~�	d��b�c�c�c��~�%�%�%�%�-�&�9�10�	11rN)F)�__name__�12__module__�__qualname__rrr�rrrrsF������������13�14�15�16�17�18rr)�numpy�np�sam2.build_samr�sam2.sam2_image_predictorrrrrr�<module>r#sg������%�%�%�%�%�%�8�8�8�8�8�8�19�20�21�22�23�24�25�26�27�28r