# Performing inference on new data Refer to the tutorials ([Linux](./install_on_linux.md), [Windows](./install_on_wsl2.md)) for installation instructions. To run inference, you will need: - A checkpoint of a trained lightning module implementing model logic (class `simlearner3d.models.generic_model.Model`) - A pair of epipolar images - An installed and working version of [our micmac repository](https://github.com/DaliCHEBBI/micmac_SimLearning). ## Transforming .ckpt model to scripted .pt models Our [our micmac version](https://github.com/DaliCHEBBI/micmac_SimLearning) leverages learned models together with [PyTorch c++ api](https://pytorch.org/get-started/locally/) to perform large scale stereo image matching. In order to use trained models, you need to script the model checkpoint from pytorchlightning to a .pt model. This is performed using the following command line: ```bash python run.py \ task.task_name=extract_pt \ model.ckpt_path={/path/to/checkpoint.ckpt} ``` ## Run inference on a pair of epipolar images Inference routines are implemented in C++ into the open photogrammetry software [MicMac](https://github.com/micmacIGN/micmac). It tackles large scale stereo matching for large frame aerial imagery and EHR Satellite stereo reconstruction. Our models are embedded into a hierachical multi-resolution pipeline where lower resolution surface reconstructions serve as a prior for the next level reconstruction. This strategy is robust and allows integrating hand-crafted similarity metrics like (ncc, census,...) for lower resolution low context matching. To perform hierarchical matching using our similarity learning models, you need to: * git clone our repository and install `micmac` and `MicMac V2` after downloading plateform specific [torch cpp libraries](). You may need to modifiy `TORCH_INSTALL_PREFIX` in CMakeLists.txt to point to `libtorch` folder. For our installation, we set it to `${MMVII_SOURCE_DIR}/libtorch` * compile MMVII and micmac with libtorch * MicMac uses `xml specifications` files for hierachical dense image matching, we provide an example xml configuration file: ``` ZReg=0.005 DefCor=0.4 CostTrans=1.0 SzW=3 PenteMax=3.0 Interpol=eInterpolBiLin DoEpi=true Ori=Epi Im=TEST Im1=Im1DUBL.tif Im2=Im2DUBL.tif Modele=XXX WITH_MODELE=true IncPix=100 NbDirProg=7 ExtImIn=tif Purge=true NbProc=4 OnCuda=false UseMLP=false DirMEC=${Modele} DirPyram=Pyram/ ${IncPix} eGeomImage_EpipolairePure ${Im1} ${Im2} (.*)\.${ExtImIn} $1_Masq.tif true true -1 ${Interpol} ${SzW} eAlgo2PrgDyn 1 7 3 ${ZReg} true 1 false ePrgDAgrSomme ${NbDirProg} ${PenteMax} ${DefCor} ${CostTrans} false 16 8 40000000 MVCNNCorrel ../MODEL_MSAFF_AERIAL_DECISION/.*.pt UnetMLPMatcher ${OnCuda} ${UseMLP} 4 40000000 MVCNNCorrel ../MODEL_MSAFF_AERIAL_DECISION/.*.pt UnetMLPMatcher ${OnCuda} ${UseMLP} 2 40000000 MVCNNCorrel ../MODEL_MSAFF_AERIAL_DECISION/.*.pt UnetMLPMatcher ${OnCuda} ${UseMLP} 1 40000000 MVCNNCorrel ../MODEL_MSAFF_AERIAL_DECISION/.*.pt UnetMLPMatcher ${OnCuda} ${UseMLP} 1 1.0 eAlgoDequant false 1 1 eFloat32Bits eGeomPxBiDim 16 2.0 -1 ThisDir ${DirMEC}/ ${DirMEC}/ ${DirPyram} ${Purge} ${NbProc} 2048 540 512 20 40 eComprTiff_None true ``` * The aformentionned xml file activates our models from `Zoom 4`, i.e models are in charge of reconstruction for zooms: 4,2,1. This is accomplished with and adhoc correlation that calls a set of .pt models (feature extraction + mlp). ``` 40000000 MVCNNCorrel ../MODEL_MSAFF_AERIAL_DECISION/.*.pt UnetMLPMatcher ${OnCuda} ${UseMLP} ``` * Parametrization: To launch stereo matching between a pair of epipolar images, `mm3d MICMAC File.xml +Im1=Im1.tif +Im2=Im2.tif +DirMEC=MEC/ +OnCuda=0 +UsePredicNet=1`