U fb @sddlZddZdddZdS)Nc Cs|js|d}|||}g}|D]V\}}|j}|jrj|jrj||j}||j}|t|} nd} | |d<| |q*t |} | S)aGet the best intersection over union for a predicted polygon. Arguments --------- pred_poly : :py:class:`shapely.Polygon` Prediction polygon to test. test_data_GDF : :py:class:`geopandas.GeoDataFrame` GeoDataFrame of ground truth polygons to test ``pred_poly`` against. Returns ------- iou_GDF : :py:class:`geopandas.GeoDataFrame` A subset of ``test_data_GDF`` that overlaps ``pred_poly`` with an added column ``iou_score`` which indicates the intersection over union value. gr iou_score) is_validbuffer intersectsiterrowsgeometry intersectionareaunionfloatappendgpd GeoDataFrame) pred_poly test_data_GDFZprecise_matchesZ iou_row_list_rowZ test_polyrr riou_GDFrf/home/ec2-user/SageMaker/vegetation-management-remars2022/remars2022-workshop/libs/solaris/eval/iou.py calculate_ious      rTcCs<t||}|j|djddd}|r8|j|jddddS)a'Get the maximum intersection over union score for a predicted polygon. Arguments --------- pred_poly : :py:class:`shapely.geometry.Polygon` Prediction polygon to test. test_data_GDF : :py:class:`geopandas.GeoDataFrame` GeoDataFrame of ground truth polygons to test ``pred_poly`` against. remove_matching_element : bool, optional Should the maximum IoU row be dropped from ``test_data_GDF``? Defaults to ``True``. Returns ------- *This function doesn't currently return anything.* rrT)axisskipna)rinplaceN)rlocidxmaxdropname)rrZremove_matching_elementr max_iou_rowrrr process_iou/s r)T) geopandasr rrrrrrs+