| |
| """ |
| Convert SatCLIP and CoordNet from source .ckpt to diffusers-style format. |
| Saves into this repo (satclip_location_encoder/, coordnet/) for self-contained inference. |
| |
| Usage: |
| 1. Download SatCLIP: huggingface.co/microsoft/SatCLIP-ViT16-L10 -> satclip-vit16-l10.ckpt |
| 2. Download GeoSynth-Location-OSM: huggingface.co/MVRL/GeoSynth-Location-OSM -> geosynth_loc_osm.ckpt |
| 3. Run: python convert_ckpts.py --satclip_ckpt /path/to/satclip-vit16-l10.ckpt --coordnet_ckpt /path/to/geosynth_loc_osm.ckpt |
| """ |
| import argparse |
| import os |
| import sys |
|
|
| REPO_DIR = os.path.dirname(os.path.abspath(__file__)) |
| sys.path.insert(0, REPO_DIR) |
|
|
| from geosynth_pipeline import GeoSynthCoordNetModel, SatCLIPLocationEncoder |
|
|
|
|
| def main(): |
| parser = argparse.ArgumentParser() |
| parser.add_argument("--satclip_ckpt", required=True, help="Path to satclip-vit16-l10.ckpt") |
| parser.add_argument("--coordnet_ckpt", required=True, help="Path to geosynth_loc_osm.ckpt") |
| args = parser.parse_args() |
|
|
| satclip_out = os.path.join(REPO_DIR, "satclip_location_encoder") |
| coordnet_out = os.path.join(REPO_DIR, "coordnet") |
|
|
| if not os.path.isfile(args.satclip_ckpt): |
| sys.exit(f"SatCLIP checkpoint not found: {args.satclip_ckpt}") |
| if not os.path.isfile(args.coordnet_ckpt): |
| sys.exit(f"CoordNet checkpoint not found: {args.coordnet_ckpt}") |
|
|
| print("Loading SatCLIP location encoder...") |
| loc_enc = SatCLIPLocationEncoder.from_satclip_ckpt(args.satclip_ckpt) |
| os.makedirs(satclip_out, exist_ok=True) |
| loc_enc.save_pretrained(satclip_out) |
| print(f"Saved to {satclip_out}") |
|
|
| print("Loading CoordNet...") |
| coordnet = GeoSynthCoordNetModel.from_geosynth_ckpt(args.coordnet_ckpt) |
| os.makedirs(coordnet_out, exist_ok=True) |
| coordnet.save_pretrained(coordnet_out) |
| print(f"Saved to {coordnet_out}") |
| print("Done. Use inference_demo.py with local paths.") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|