Skip to content

Commit

Permalink
fix cocores
Browse files Browse the repository at this point in the history
  • Loading branch information
mayrajeo committed Sep 19, 2023
1 parent 288403f commit 2babb6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions geo2ml/data/cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ def coco_to_shp(

# %% ../../nbs/13_data.cv.ipynb 21
def shp_to_coco_results(
prediction_path: Path, raster_path: Path, coco_dict: Path, outpath: Path
prediction_path: Path,
raster_path: Path,
coco_dict: Path,
outpath: Path,
rotated_bbox: bool = False,
):
"Convert vector predictions into coco result format to be fed into COCO evaluator"

Expand All @@ -304,7 +308,7 @@ def shp_to_coco_results(
image_id = coco_dict["images"][im_id]["id"]
h = coco_dict["images"][im_id]["height"]
w = coco_dict["images"][im_id]["width"]
gdf = gpd.read_file(f"{self.prediction_path}/{result_tiles[i]}")
gdf = gpd.read_file(f"{prediction_path}/{vector_tiles[i]}")
tfmd_gdf = gdf_to_px(gdf, raster_path / raster_tiles[i], precision=3)
for row in tfmd_gdf.itertuples():
res = {
Expand Down
4 changes: 2 additions & 2 deletions nbs/13_data.cv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
"source": [
"#| export\n",
"\n",
"def shp_to_coco_results(prediction_path:Path, raster_path:Path, coco_dict:Path, outpath:Path):\n",
"def shp_to_coco_results(prediction_path:Path, raster_path:Path, coco_dict:Path, outpath:Path, rotated_bbox:bool=False):\n",
" \"Convert vector predictions into coco result format to be fed into COCO evaluator\"\n",
"\n",
" with open(coco_dict) as f:\n",
Expand All @@ -619,7 +619,7 @@
" image_id = coco_dict['images'][im_id]['id']\n",
" h = coco_dict['images'][im_id]['height']\n",
" w = coco_dict['images'][im_id]['width']\n",
" gdf = gpd.read_file(f'{self.prediction_path}/{result_tiles[i]}')\n",
" gdf = gpd.read_file(f'{prediction_path}/{vector_tiles[i]}')\n",
" tfmd_gdf = gdf_to_px(gdf, raster_path/raster_tiles[i], precision=3)\n",
" for row in tfmd_gdf.itertuples():\n",
" res = {'image_id': image_id,\n",
Expand Down
Loading

0 comments on commit 2babb6f

Please sign in to comment.