Views
No views yet
tensorflow library.1# Clones the repository and installs dependencies
2!git clone https://huggingface.co/preethamganesh/digit-recognizer-v1.0.0
3!pip install tensorflow
4
5# Imports TensorFlow
6import tensorflow as tf
7
8# Loads the pre-trained model from the cloned directory
9model_path = "digit-recognizer-v1.0.0"
10exported_model = tf.saved_model.load(model_path)
11
12# Retrieves the default serving function from the loaded model
13model = exported_model.signatures["serving_default"]
14
15# Prepares a dummy input tensor for inference (batch size: 1, height: 28, width: 28, channels: 1)
16input_data = tf.ones((1, 28, 28, 1), dtype=tf.float32)
17
18# Performs inference using the model. The output will be a dictionary, with the classification logits in the key 'output_0'
19output = model(input_data)["output_0"]
20
21# Prints the predicted class (e.g., 0 for normal, 1 for abnormal)
22predicted_digit = tf.argmax(output, axis=-1).numpy()[0]
23print("Predicted digit: ", predicted_digit)1@misc{preethamganesh2024digitrecog,
2 title={Digit Recognizer - v1.0.0},
3 author={Preetham Ganesh},
4 year={2025},
5 url={https://huggingface.co/preethamganesh/digit-recognizer-v1.0.0},
6 note={Apache-2.0 License}
7}