-
Create the model directory:
mkdir -p model_profiling/models/edgetam
-
Clone EdgeTAM source if it is not already present:
EDGETAM_CORE="model_profiling/models/edgetam/edgetam_core"
test -d "${EDGETAM_CORE}" || git clone https://github.com/facebookresearch/EdgeTAM.git "${EDGETAM_CORE}"
test -f "${EDGETAM_CORE}/LICENSE"
-
Install or document required Python dependencies in .venv. Common EdgeTAM wrapper dependencies include hydra-core and omegaconf; inspect the cloned repository before adding more.
-
Add model_profiling/models/edgetam/model.py with an EagerModelBase implementation that:
- loads the full EdgeTAM model lazily;
- loads the checkpoint from
edgetam_core/checkpoints/;
- extracts
full_model.image_encoder;
- returns
image_encoder.eval() from get_eager_model();
- returns a representative image tensor from
get_example_inputs(), typically (torch.randn(1, 3, 1024, 1024),).
-
Add model_profiling/models/edgetam/__init__.py that registers the model:
from .model import EdgeTAMImageEncoderModel
from .. import register_model
register_model("edgetam_image_encoder", EdgeTAMImageEncoderModel)
-
Confirm model_profiling/models/__init__.py imports optional EdgeTAM without breaking environments where the source has not been cloned.
-
Export the model:
source .venv/bin/activate
python model_profiling/export/export_model.py \
--model edgetam_image_encoder \
--backend xnnpack \
--dtype fp32 \
--outdir model_profiling/out_edgetam_image_encoder/artifacts \
--save-graph
-
Validate artifacts:
test -s model_profiling/out_edgetam_image_encoder/artifacts/edgetam_image_encoder_xnnpack_fp32.pte
test -s model_profiling/out_edgetam_image_encoder/artifacts/graph.json