# Example Code: Try this code on google colab

# Step 1: Install Required Libraries
!pip install huggingface_hub

# Step 2: Import Libraries
import os
import numpy as np
from huggingface_hub import hf_hub_download
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from google.colab import files

# Step 3: Download the Model from Hugging Face
repo_id = "krishnamishra8848/Nepal_Vehicle_License_Plates_Character_Recognisation"
filename = "model.h5"

model_path = hf_hub_download(repo_id=repo_id, filename=filename)

# Step 4: Load the Model
model = load_model(model_path)

# Step 5: Allow User to Upload an Image
uploaded = files.upload()

# Assuming only one file is uploaded
for image_name in uploaded.keys():
    # Step 6: Process the Uploaded Image
    img_height, img_width = 64, 64  # Image dimensions used during training
    img = load_img(image_name, target_size=(img_height, img_width))
    img_array = img_to_array(img)
    img_array = img_array / 255.0  # Normalize pixel values
    img_array = np.expand_dims(img_array, axis=0)  # Add batch dimension

    # Step 7: Predict Using the Model
    prediction = model.predict(img_array)
    predicted_class_index = np.argmax(prediction)
    confidence = np.max(prediction)

    # Step 8: Map Index to Class Labels
    class_labels = [
        'क', 'को', 'ख', 'ग', 'च', 'ज', 'झ', 'ञ', 'डि', 'त', 'ना', 'प',
        'प्र', 'ब', 'बा', 'भे', 'म', 'मे', 'य', 'लु', 'सी', 'सु', 'से', 'ह',
        '०', '१', '२', '३', '४', '५', '६', '७', '८', '९'
    ]
    predicted_class = class_labels[predicted_class_index]

    # Step 9: Display the Result
    print(f"Predicted Class: {predicted_class}")
    print(f"Confidence: {confidence:.4f}")
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Space using krishnamishra8848/Nepal_Vehicle_License_Plates_Character_Recognisation 1