aegishield's picture
use
42155bf
raw
history blame
1.03 kB
import gradio as gr
from huggingface_hub import from_pretrained_keras
from tensorflow.keras.preprocessing import image
import numpy as np
# Load models
idpred = from_pretrained_keras("aegishield/idpred")
fingpred = from_pretrained_keras("aegishield/fingpred")
def predict_image(img):
# Preprocess the image (example, adjust based on your model's needs)
img = img.resize((224, 224)) # Adjust the size according to your model input
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
# Predictions
y_SubjectID_pred = idpred.predict(img_array)
y_fingerNum_pred = fingpred.predict(img_array)
# Process predictions to readable format if necessary
# For example, if your predictions are one-hot encoded, convert them to labels
return f'Subject ID: {y_SubjectID_pred[0]}, Finger Number: {y_fingerNum_pred[0]}'
# Create Gradio interface
iface = gr.Interface(fn=predict_image, inputs="image", outputs="text")
# Launch interface
iface.launch()