Spaces:
Runtime error
Runtime error
Commit
·
42155bf
1
Parent(s):
58cb436
use
Browse files
app.py
CHANGED
|
@@ -1,11 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
return "Hello " + name + "!!"
|
| 6 |
-
|
| 7 |
idpred = from_pretrained_keras("aegishield/idpred")
|
| 8 |
fingpred = from_pretrained_keras("aegishield/fingpred")
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
+
from tensorflow.keras.preprocessing import image
|
| 4 |
+
import numpy as np
|
| 5 |
|
| 6 |
+
# Load models
|
|
|
|
|
|
|
| 7 |
idpred = from_pretrained_keras("aegishield/idpred")
|
| 8 |
fingpred = from_pretrained_keras("aegishield/fingpred")
|
| 9 |
|
| 10 |
+
def predict_image(img):
|
| 11 |
+
# Preprocess the image (example, adjust based on your model's needs)
|
| 12 |
+
img = img.resize((224, 224)) # Adjust the size according to your model input
|
| 13 |
+
img_array = image.img_to_array(img)
|
| 14 |
+
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
|
| 15 |
+
|
| 16 |
+
# Predictions
|
| 17 |
+
y_SubjectID_pred = idpred.predict(img_array)
|
| 18 |
+
y_fingerNum_pred = fingpred.predict(img_array)
|
| 19 |
+
|
| 20 |
+
# Process predictions to readable format if necessary
|
| 21 |
+
# For example, if your predictions are one-hot encoded, convert them to labels
|
| 22 |
+
|
| 23 |
+
return f'Subject ID: {y_SubjectID_pred[0]}, Finger Number: {y_fingerNum_pred[0]}'
|
| 24 |
+
|
| 25 |
+
# Create Gradio interface
|
| 26 |
+
iface = gr.Interface(fn=predict_image, inputs="image", outputs="text")
|
| 27 |
+
|
| 28 |
+
# Launch interface
|
| 29 |
iface.launch()
|