Spaces:
Runtime error
Runtime error
tiling
Browse files63 unmodified lines646566676869707172737475767778798081828384858685 unmodified lines17217317417517617717817918018118218318463 unmodified lineschanged = 0for p in glob.glob(os.path.join(dirpath, "*.geojson")):base = os.path.basename(p)nums = re.findall(r"-?\d+", base)if len(nums) >= 5:last5 = nums[-5:]target = "_".join(last5) + ".geojson"if target != base:dst = os.path.join(dirpath, target)# avoid accidental collisionsif os.path.exists(dst):k = 1root = "_".join(last5)while os.path.exists(os.path.join(dirpath, f"{root}__{k}.geojson")):k += 1dst = os.path.join(dirpath, f"{root}__{k}.geojson")os.replace(p, dst)changed += 1return changed# configWEIGHT_DIR = os.getenv("DTR2_WEIGHT_DIR", "/data/weights")os.makedirs(WEIGHT_DIR, exist_ok=True)85 unmodified linespreds_geo_dir = os.path.join(tiles_dir, "predictions_geo")os.makedirs(preds_geo_dir, exist_ok=True)project_to_geojson(tiles_dir, preds_dir, preds_geo_dir)_sanitize_geojson_filenames(preds_geo_dir)geos = glob.glob(os.path.join(preds_geo_dir, "*.geojson"))if not geos:return None, None, None, f"Error: No geojson files found in {preds_geo_dir}."# stitch + clean + filtercrowns = stitch_crowns(preds_geo_dir, 1)63 unmodified lines64656667686970717273747576777879808182838485868788899085 unmodified lines17617717817918018118218318418518618718818919019119219319419519663 unmodified lineschanged = 0for p in glob.glob(os.path.join(dirpath, "*.geojson")):base = os.path.basename(p)nums = re.findall(r"-?\d+", base) # grab all integers anywhere# ensure we have exactly 5 integersif len(nums) < 5:nums = (["0"] * (5 - len(nums))) + numselse:nums = nums[-5:]target = "_".join(nums) + ".geojson"if target != base:dst = os.path.join(dirpath, target)# avoid collisionsif os.path.exists(dst):k = 1root = "_".join(nums)while os.path.exists(os.path.join(dirpath, f"{root}__{k}.geojson")):k += 1dst = os.path.join(dirpath, f"{root}__{k}.geojson")os.replace(p, dst)changed += 1return changed# configWEIGHT_DIR = os.getenv("DTR2_WEIGHT_DIR", "/data/weights")os.makedirs(WEIGHT_DIR, exist_ok=True)85 unmodified linespreds_geo_dir = os.path.join(tiles_dir, "predictions_geo")os.makedirs(preds_geo_dir, exist_ok=True)project_to_geojson(tiles_dir, preds_dir, preds_geo_dir)_sanitize_geojson_filenames(preds_geo_dir)geos = glob.glob(os.path.join(preds_geo_dir, "*.geojson"))if not geos:return None, None, None, f"Error: No geojson files found in {preds_geo_dir}."bad = [os.path.basename(g)for g in geosif not re.fullmatch(r"-?\d+_-?\d+_-?\d+_-?\d+_-?\d+\.geojson", os.path.basename(g))]if bad:return None, None, None, "Error: Unexpected GeoJSON names (need 5 integers): " + ", ".join(bad)# stitch + clean + filtercrowns = stitch_crowns(preds_geo_dir, 1)
app.py+28-16