Spaces:
Runtime error
Runtime error
padding fix
Browse files22 unmodified lines232425262728150 unmodified lines17918018118218318418518618722 unmodified linesimport mathimport numpy as npfrom shapely.geometry import boxfrom detectron2.engine import DefaultPredictorfrom detectree2.preprocessing.tiling import tile_data150 unmodified lines# stitch + clean + filtercrowns = stitch_crowns(preds_geo_dir, 1)cleaned = clean_crowns(crowns, 0.6, confidence=0)cleaned = cleaned[cleaned["Confidence_score"] > float(conf_threshold)].set_geometry(cleaned.simplify(0.4))clip_geom = box(*orig_bounds)if not cleaned.empty:22 unmodified lines2324252627282930150 unmodified lines18118218318418518618718818919019119219319419519619719819920020120220320420520620722 unmodified linesimport mathimport numpy as npfrom shapely.geometry import boximport pyprojfrom detectron2.engine import DefaultPredictorfrom detectree2.preprocessing.tiling import tile_data150 unmodified lines# stitch + clean + filtercrowns = stitch_crowns(preds_geo_dir, 1)cleaned = clean_crowns(crowns, 0.6, confidence=0)cleaned = cleaned[cleaned["Confidence_score"] > float(conf_threshold)]with rasterio.open(infile) as _src:raster_crs = _src.crsraster_bounds = _src.boundsif cleaned.crs is None:cleaned = cleaned.set_crs(raster_crs, allow_override=True)elif cleaned.crs != raster_crs:cleaned = cleaned.to_crs(raster_crs)if not cleaned.empty:cleaned = cleaned.clip(box(*raster_bounds))if not cleaned.empty:if pyproj.CRS.from_user_input(raster_crs).is_geographic:tol = 2e-5else:tol = 0.4cleaned.set_geometry(cleaned.geometry.simplify(tol, preserve_topology=True), inplace=True)clip_geom = box(*orig_bounds)if not cleaned.empty:
app.py+23-3