Views
No views yet
| Model File | Format | Size | Description | Use Case |
|---|---|---|---|---|
id_classifier.tflite | TFLite | 1.11 MB | Lightweight ID classifier | Mobile inference |
id_card_embedding_model.tflite | TFLite | 1.26 MB | Compact embedding model | Mobile feature extraction |
id_card_classifier.keras | Keras | 5.23 MB | Full Keras classifier | Training/fine-tuning |
id_classifier_saved_model.h5 | H5 | 8.85 MB | H5 format classifier | Legacy compatibility |
id_classifier_saved_model.keras | Keras | 12.7 MB | Complete Keras model | Development/evaluation |
id_card_embedding_model.keras | Keras | 191 MB | High-accuracy embedding model | Server-side processing |
1// Load TFLite model in Android
2val model = Interpreter(loadModelFile("id_classifier.tflite"))
3
4// Prepare input
5val inputBuffer = ByteBuffer.allocateDirect(inputSize)
6val outputBuffer = ByteBuffer.allocateDirect(outputSize)
7
8// Run inference
9model.run(inputBuffer, outputBuffer)1from tensorflow.keras.models import load_model
2
3# Load full Keras model
4model = load_model("id_card_classifier.keras")
5
6# Make predictions
7predictions = model.predict(input_data)1import tensorflow as tf
2
3# Load TFLite model
4interpreter = tf.lite.Interpreter(model_path="id_card_embedding_model.tflite")
5interpreter.allocate_tensors()
6
7# Get input and output details
8input_details = interpreter.get_input_details()
9output_details = interpreter.get_output_details()
10
11# Run inference
12interpreter.set_tensor(input_details[0]['index'], input_data)
13interpreter.invoke()
14output = interpreter.get_tensor(output_details[0]['index'])1git lfs install
2git clone https://huggingface.co/Ajay007001/Android-Projekt1from huggingface_hub import hf_hub_download
2
3model_path = hf_hub_download(
4 repo_id="Ajay007001/Android-Projekt",
5 filename="id_classifier.tflite"
6)Input (224x224x3)
↓
MobileNetV3Small (Pretrained on ImageNet)
↓
GlobalAveragePooling2D
↓
Dense(256, activation='relu')
↓
L2 Normalization
↓
Embedding Vector (256-dim).tflite files in app/src/main/assets/1implementation 'org.tensorflow:tensorflow-lite:2.14.0'
2implementation 'org.tensorflow:tensorflow-lite-support:0.4.4'
3implementation 'org.tensorflow:tensorflow-lite-gpu:2.14.0'id_card_embedding_model.keras (191 MB) requires significant memory. For mobile deployment, use the .tflite versions (1-1.3 MB) which are optimized and quantized.| Model | Accuracy | Inference Time* | Mobile FPS |
|---|---|---|---|
| Embedding Model (TFLite) | 94.2% | ~25ms | ~40 FPS |
| Classifier (TFLite) | 96.8% | ~18ms | ~55 FPS |
L2Norm layer. Load them with:1import tensorflow as tf
2
3class L2Norm(tf.keras.layers.Layer):
4 def call(self, inputs):
5 return tf.math.l2_normalize(inputs, axis=1)
6
7 def get_config(self):
8 return super().get_config()
9
10model = tf.keras.models.load_model(
11 "id_card_embedding_model.keras",
12 custom_objects={'L2Norm': L2Norm}
13)1# Load base model
2base_model = load_model("id_card_classifier.keras")
3
4# Freeze early layers
5for layer in base_model.layers[:-5]:
6 layer.trainable = False
7
8# Add custom layers for your specific use case
9# ... your architecture
10
11# Compile and train
12model.compile(optimizer='adam', loss='categorical_crossentropy')
13model.fit(train_data, epochs=10)1import tensorflow as tf
2
3# Load Keras model
4model = tf.keras.models.load_model("id_card_classifier.keras")
5
6# Convert to TFLite with optimization
7converter = tf.lite.TFLiteConverter.from_keras_model(model)
8converter.optimizations = [tf.lite.Optimize.DEFAULT]
9
10# For INT8 quantization (smaller size, faster inference)
11def representative_dataset():
12 for data in dataset.take(100):
13 yield [data]
14
15converter.representative_dataset = representative_dataset
16converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
17converter.inference_input_type = tf.uint8
18converter.inference_output_type = tf.uint8
19
20tflite_model = converter.convert()
21
22# Save
23with open("model_quantized.tflite", "wb") as f:
24 f.write(tflite_model)1import org.tensorflow.lite.gpu.GpuDelegate
2
3val options = Interpreter.Options()
4val gpuDelegate = GpuDelegate()
5options.addDelegate(gpuDelegate)
6val interpreter = Interpreter(modelFile, options)1import tensorflow as tf
2import numpy as np
3
4# Load TFLite model
5interpreter = tf.lite.Interpreter(model_path="id_classifier.tflite")
6interpreter.allocate_tensors()
7
8# Prepare sample input
9input_shape = interpreter.get_input_details()[0]['shape']
10sample_input = np.random.rand(*input_shape).astype(np.float32)
11
12# Run inference
13interpreter.set_tensor(interpreter.get_input_details()[0]['index'], sample_input)
14interpreter.invoke()
15output = interpreter.get_tensor(interpreter.get_output_details()[0]['index'])
16
17print(f"Input shape: {input_shape}")
18print(f"Output shape: {output.shape}")
19print(f"Predictions: {output}")1@misc{android-projekt-2025,
2 author = {Ajay Vasan},
3 title = {Android-Projekt: ID Card Classification & Embedding Models},
4 year = {2025},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/Ajay007001/Android-Projekt}}
7}id_card_embedding_model.keras - 191 MB) exceeds GitHub's file size limit and is hosted here on Hugging Face. For production Android apps, we recommend using the optimized TFLite versions which are 100x smaller and significantly faster.