Spaces:
Runtime error
Runtime error
JefferyJapheth
commited on
Commit
•
4b1d8f8
1
Parent(s):
1fa9769
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,41 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
import numpy as np
|
|
|
4 |
|
5 |
+
import numpy as np
|
6 |
+
import tensorflow as tf
|
7 |
+
|
8 |
+
class TFLiteModel(tf.Module):
|
9 |
+
# ... (same as the previous TFLiteModel class definition)
|
10 |
+
|
11 |
+
# Load the TFLite model
|
12 |
+
model_path = 'path/to/your/tflite_model.tflite'
|
13 |
+
interpreter = tf.lite.Interpreter(model_path=model_path)
|
14 |
+
interpreter.allocate_tensors()
|
15 |
+
|
16 |
+
# Load the input and output .npy files
|
17 |
+
input_npy_file = 'input.npy'
|
18 |
+
output_npy_file = 'output.npy'
|
19 |
+
|
20 |
+
input_data = np.load(input_npy_file)
|
21 |
+
output_data = np.load(output_npy_file)
|
22 |
+
|
23 |
+
# Create the TFLiteModel instance
|
24 |
+
model = TFLiteModel(interpreter)
|
25 |
+
|
26 |
+
# Perform inference
|
27 |
+
input_tensor = tf.convert_to_tensor(input_data, dtype=tf.float32)
|
28 |
+
outputs = model(input_tensor)["outputs"]
|
29 |
+
|
30 |
+
# Convert outputs to numpy array
|
31 |
+
predicted_output = outputs.numpy()
|
32 |
+
|
33 |
+
# Print the prediction and true output
|
34 |
+
print("Predicted Output:")
|
35 |
+
print(predicted_output)
|
36 |
+
|
37 |
+
print("True Output:")
|
38 |
+
print(output_data)
|
39 |
+
|
40 |
+
iface = gr.Interface(fn=predict_sign_language, inputs="file", outputs="text")
|
41 |
+
iface.launch(share=True) # Set `share=True` to make it accessible outside the localhost
|