Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,15 +60,17 @@ with gr.Blocks() as demo:
|
|
60 |
# evaluate the model on the test set
|
61 |
model.fit(x_train, y_train, epochs=5)
|
62 |
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
|
|
|
|
|
63 |
|
64 |
-
print("Test accuracy: ", test_acc)
|
65 |
-
|
66 |
-
# Define any necessary preprocessing steps for the image input here
|
67 |
-
# the image can be passed as a PIL or numpy
|
68 |
# create the final model for production
|
69 |
probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
|
70 |
|
71 |
-
#
|
|
|
|
|
|
|
|
|
72 |
# assuming image_array is your input image array of shape (552, 3)
|
73 |
resized_array = np.resize(img, (28, 28)) # resize the array to (28, 28)
|
74 |
input_array = np.expand_dims(resized_array, axis=0) # add an extra dimension to represent the batch size
|
@@ -85,7 +87,6 @@ with gr.Blocks() as demo:
|
|
85 |
with gr.Column(scale=2):
|
86 |
image_data = gr.Image(label="Upload Image", type="numpy")
|
87 |
with gr.Column(scale=1):
|
88 |
-
model_performance = gr.Text(label="Model Performance", interactive=False)
|
89 |
model_prediction = gr.Text(label="Model Prediction", interactive=False)
|
90 |
image_data.change(modelTraining, image_data, model_prediction)
|
91 |
|
|
|
60 |
# evaluate the model on the test set
|
61 |
model.fit(x_train, y_train, epochs=5)
|
62 |
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
|
63 |
+
post_train_results = f"Test accuracy: {test_acc} Test Loss: {test_loss}"
|
64 |
+
print(post_train_results)
|
65 |
|
|
|
|
|
|
|
|
|
66 |
# create the final model for production
|
67 |
probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
|
68 |
|
69 |
+
# Input image pre-processing before submission to the model
|
70 |
+
# the image can be passed as a PIL or numpy
|
71 |
+
|
72 |
+
# Normalize the pixel values?
|
73 |
+
print(f"Input image shape: {img.shape} Dimensions: {img.ndim} Array Element: {img[0]} ***********************************************************************")
|
74 |
# assuming image_array is your input image array of shape (552, 3)
|
75 |
resized_array = np.resize(img, (28, 28)) # resize the array to (28, 28)
|
76 |
input_array = np.expand_dims(resized_array, axis=0) # add an extra dimension to represent the batch size
|
|
|
87 |
with gr.Column(scale=2):
|
88 |
image_data = gr.Image(label="Upload Image", type="numpy")
|
89 |
with gr.Column(scale=1):
|
|
|
90 |
model_prediction = gr.Text(label="Model Prediction", interactive=False)
|
91 |
image_data.change(modelTraining, image_data, model_prediction)
|
92 |
|