Image Classification
Keras
LiteRT
English
computer-vision
satellite-imagery
tensorflow
remote-sensing
land-cover-classification
Instructions to use Mirutex/Celyrix-1.0-Vision with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Mirutex/Celyrix-1.0-Vision with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Mirutex/Celyrix-1.0-Vision") - Notebooks
- Google Colab
- Kaggle
Download src/export.py from Mirutex/Celyrix-1.0-Vision: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/Mirutex/Celyrix-1.0-Vision/resolve/main/src/export.py
- Command line
-
hf download hf://Mirutex/Celyrix-1.0-Vision/src/export.py
-
curl -L -o export.py https://huggingface.co/Mirutex/Celyrix-1.0-Vision/resolve/main/src/export.py
2.27 kB
| """Export an inference-only float16 TFLite model and verify parity.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| from src.common import configure | |
| def main(): | |
| p = argparse.ArgumentParser() | |
| p.add_argument("--model-dir", default="artifacts/release") | |
| args = p.parse_args() | |
| configure() | |
| import tensorflow as tf | |
| out = Path(args.model_dir) | |
| model = tf.keras.models.load_model(out / "model.keras", compile=False) | |
| # Rebuild graph with training=False so augmentation/dropout never enter inference graph. | |
| inputs = tf.keras.Input((64, 64, 3), batch_size=1) | |
| inference = tf.keras.Model(inputs, model(inputs, training=False)) | |
| converter = tf.lite.TFLiteConverter.from_keras_model(inference) | |
| converter.optimizations = [tf.lite.Optimize.DEFAULT] | |
| converter.target_spec.supported_types = [tf.float16] | |
| data = converter.convert() | |
| (out / "model.float16.tflite").write_bytes(data) | |
| interpreter = tf.lite.Interpreter(model_content=data) | |
| interpreter.allocate_tensors() | |
| from src.dataset import load_data | |
| cfg = json.loads((out / "training_config.json").read_text()) | |
| splits, _ = load_data(cfg["data_dir"], cfg["seed"]) | |
| samples = splits["test"][0][:16].astype("float32") | |
| errors = [] | |
| for image in samples: | |
| x = image[None] | |
| interpreter.set_tensor(interpreter.get_input_details()[0]["index"], x) | |
| interpreter.invoke() | |
| actual = interpreter.get_tensor(interpreter.get_output_details()[0]["index"]) | |
| expected = np.asarray(inference(x, training=False)) | |
| errors.append(float(np.max(np.abs(actual - expected)))) | |
| if not np.allclose(actual, expected, atol=0.005): | |
| raise RuntimeError(f"TFLite parity failed: {errors[-1]}") | |
| delta = max(errors) | |
| (out / "export.json").write_text( | |
| json.dumps( | |
| { | |
| "format": "TFLite float16", | |
| "bytes": len(data), | |
| "max_absolute_error": delta, | |
| "parity_input": "first 16 held-out test patches", | |
| "samples": len(samples), | |
| }, | |
| indent=2, | |
| ) | |
| ) | |
| print("TFLite export verified:", len(data), "bytes; max error", delta) | |
| if __name__ == "__main__": | |
| main() | |