
    ]i                     ,    d dl mZ  G d d          ZdS )    )YOLOc                       e Zd ZddZd ZdS )EggDetector皙?c                 <    t          |          | _        || _        d S )N)r   modelconf_threshold)self
model_pathr	   s      O/data/users/s19104799/parasitic-detection.dcism.org/backend/src/egg_detector.py__init__zEggDetector.__init__   s    *%%
,    c           	         |                      || j                  }g }t          |          D ]\  }}|j        t	          |j                  dk    rt          |j                  D ]\  }}|j        d                                                                         \  }}	}
}|j        d                                                                         }t          |j
        d                                                                                   }| j         j        |         }t          |          t          |	          t          |
          t          |          f\  }}	}
}d}t          d||z
            }t          d|	|z
            }t          |j        |
|z             }t          |j        ||z             }|                    ||||f          }|||	|
|f||||ft#          |          ||d}|                    |           |S )N)confr   
   )imagebboxbbox_padded
confidence
class_nameclass_id)r   r	   	enumerateboxeslenxyxycpunumpyr   intclsnamesmaxminwidthheightcropfloatappend)r
   r   resultscropped_imagesiresultjboxx1y1x2y2r   r   r   padding	x1_padded	y1_padded	x2_padded	y2_paddedcropped_imgcropped_infos                         r   detect_eggszEggDetector.detect_eggs	   s   **U)<*=="7++ 	8 	8IAv|'C,=,=,A,A'55 8 8FAs%(Xa[__%6%6%<%<%>%>NBB!$!!2!2!8!8!:!:J"371:>>#3#3#9#9#;#;<<H!%!1(!;J%(WWc"ggs2wwB%GNBB G #ArG| 4 4I #ArG| 4 4I #EKg > >I #EL"w, ? ?I"'**"Iy)D# #K
 "-!#RR 0(19i'S&+J&7&7&0$,$ $L #)),7777r   N)r   )__name__
__module____qualname__r   r9    r   r   r   r      s7        - - - -$ $ $ $ $r   r   N)ultralyticsr   r   r=   r   r   <module>r?      sI         ) ) ) ) ) ) ) ) ) )r   