Spaces:
Runtime error
Runtime error
tiling
Browse files20 unmodified lines21222324252631 unmodified lines58596061626387 unmodified lines15115215315415515615715815916020 unmodified linesimport torchimport gradio as grimport tracebackimport mathimport numpy as np31 unmodified linesdst.write(data_padded)return padded_path# configWEIGHT_DIR = os.getenv("DTR2_WEIGHT_DIR", "/data/weights")87 unmodified linesos.makedirs(preds_geo_dir, exist_ok=True)project_to_geojson(tiles_dir, preds_dir, 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)cleaned = clean_crowns(crowns, 0.6, confidence=0)20 unmodified lines2122232425262731 unmodified lines59606162636465666768697071727374757677787980818283848587 unmodified lines17317417517617717817918018118218318418520 unmodified linesimport torchimport gradio as grimport tracebackimport reimport mathimport numpy as np31 unmodified linesdst.write(data_padded)return padded_pathdef _sanitize_geojson_filenames(dirpath):changed = 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")87 unmodified linesos.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)cleaned = clean_crowns(crowns, 0.6, confidence=0)
app.py+25