Spaces:
Runtime error
Runtime error
Add post_clean step to reduce crowns-within-crowns artefacts
Browse filesAdds an iterative post_clean gap-filling pass after clean_crowns.
This fills in missed crowns while removing nested/overlapping
duplicates that looked poor in the demo output.
Pins detectree2 to commit a8a19da with the optimised post_clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
Files changed (2)
- Dockerfile+1-1
- app.py+7-3
30 unmodified lines3132333435363730 unmodified lines# Geo + UI + detectree2RUN python3 -m pip install --no-cache-dir \gradio==4.* rasterio geopandas shapely matplotlib \"git+https://github.com/PatBall1/detectree2.git@e241c71363d175d6f90538a1fe87ea9a8dce7ae5"WORKDIR /appCOPY app.py /app/app.py30 unmodified lines3132333435363730 unmodified lines# Geo + UI + detectree2RUN python3 -m pip install --no-cache-dir \gradio==4.* rasterio geopandas shapely matplotlib \"git+https://github.com/PatBall1/detectree2.git@a8a19da"WORKDIR /appCOPY app.py /app/app.py
22 unmodified lines23242526272829101 unmodified lines13113213313413513613713813914022 unmodified linesfrom detectron2.engine import DefaultPredictorfrom detectree2.preprocessing.tiling import tile_datafrom detectree2.models.outputs import project_to_geojson, stitch_crowns, clean_crownsfrom detectree2.models.predict import predict_on_datafrom detectree2.models.train import setup_cfg101 unmodified linesif not geos:return None, None, "", "Error: Could not project predictions to geographic coordinates. Check that the input CRS is valid."update_progress(0.85, "Stitching and cleaning crowns...")# 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))22 unmodified lines23242526272829101 unmodified lines13113213313413513613713813914014114214314422 unmodified linesfrom detectron2.engine import DefaultPredictorfrom detectree2.preprocessing.tiling import tile_datafrom detectree2.models.outputs import project_to_geojson, stitch_crowns, clean_crowns, post_cleanfrom detectree2.models.predict import predict_on_datafrom detectree2.models.train import setup_cfg101 unmodified linesif not geos:return None, None, "", "Error: Could not project predictions to geographic coordinates. Check that the input CRS is valid."update_progress(0.82, "Stitching and cleaning crowns...")# stitch + clean + post_clean gap-fill + filtercrowns = stitch_crowns(preds_geo_dir, 1)cleaned = clean_crowns(crowns, 0.6, confidence=0)update_progress(0.88, "Filling gaps with post_clean...")cleaned = post_clean(crowns, cleaned, iou_threshold=0.3, field="Confidence_score", verbose=True)cleaned = cleaned[cleaned["Confidence_score"] > float(conf_threshold)].set_geometry(cleaned.simplify(0.4))
Dockerfile+1-1
app.py+7-3