a
    yf
                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZ ejj	ejj
e dddd Zejj	ejj
e ddd	d
 Zejj	ejj
e dddd Zejj	ejj
e dddd ZdS )    N)Explorer)ASSETS)
TORCH_1_13zExplorer requires torch>=1.13)reasonc                  C   s   t dd} |   | jdd}t|dks.J | jtd d}t|dksNJ | jddgdd	}t|dkspJ |  }t|dksJ | d
}t|dksJ dS )zdTest the correctness and response length of similarity calculations and SQL queries in the Explorer.
coco8.yaml)data   )idx   zbus.jpg)Zimg   r	   limitzWHERE labels LIKE '%zebra%'N)r   create_embeddings_tableget_similarlenr   Zsimilarity_indexZ	sql_query)expsimilarZsim_idxsql r   O/var/www/html/django/DPS/env/lib/python3.9/site-packages/tests/test_explorer.pytest_similarity   s    

r   c                  C   s|   t ddd} | jdd t| j d dks2J | jdd	gd
d}t|dksTJ | jdd	gd
d}t|tj	j	sxJ dS )zRTest detection functionalities and verify embedding table includes bounding boxes.r   z
yolo11n.ptr   modelTforceZbboxesr   r   r   
   r   N
r   r   r   tableheadr   Zplot_similar
isinstancePILZImager   r   r   r   r   test_det   s    r"   c                  C   s|   t ddd} | jdd t| j d dks2J | jdd	gd
d}t|dksTJ | jdd	gd
d}t|tj	j	sxJ dS )z]Test segmentation functionalities and ensure the embedding table includes segmentation masks.zcoco8-seg.yamlzyolo11n-seg.ptr   Tr   masksr   r   r   r   r   Nr   r!   r   r   r   test_seg+   s    r$   c                  C   s|   t ddd} | jdd t| j d dks2J | jdd	gd
d}t|dksTJ | jdd	gd
d}t|tj	j	sxJ dS )zUTest pose estimation functionality and verify the embedding table includes keypoints.zcoco8-pose.yamlzyolo11n-pose.ptr   Tr   Z	keypointsr   r   r   r   r   Nr   r!   r   r   r   	test_pose8   s    r%   )r    ZpytestZultralyticsr   Zultralytics.utilsr   Zultralytics.utils.torch_utilsr   markZslowZskipifr   r"   r$   r%   r   r   r   r   <module>   s    