Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,8 @@ with gr.Blocks() as demo:
|
|
| 16 |
gr.Markdown(
|
| 17 |
"""
|
| 18 |
* uploading an image will engage the model in image classsification
|
| 19 |
-
* trained on the following image types: 'T-shirt/top', 'Trouser', 'Pullover', 'Dress',
|
|
|
|
| 20 |
""")
|
| 21 |
|
| 22 |
# Train, evaluate and test a ML
|
|
@@ -59,7 +60,7 @@ with gr.Blocks() as demo:
|
|
| 59 |
|
| 60 |
# train the model - 5 runs
|
| 61 |
# evaluate the model on the test set
|
| 62 |
-
model.fit(x_train, y_train, epochs=5)
|
| 63 |
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
|
| 64 |
post_train_results = f"Test accuracy: {test_acc} Test Loss: {test_loss}"
|
| 65 |
print(post_train_results)
|
|
@@ -68,10 +69,7 @@ with gr.Blocks() as demo:
|
|
| 68 |
probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
|
| 69 |
|
| 70 |
|
| 71 |
-
def classifyImage(img):
|
| 72 |
-
#global probability_model
|
| 73 |
-
#global class_names
|
| 74 |
-
|
| 75 |
# Normalize the pixel values
|
| 76 |
img = np.array(img) / 255.0
|
| 77 |
|
|
|
|
| 16 |
gr.Markdown(
|
| 17 |
"""
|
| 18 |
* uploading an image will engage the model in image classsification
|
| 19 |
+
* trained on the following image types: 'T-shirt/top', 'Trouser', 'Pullover', 'Dress',
|
| 20 |
+
'Coat','Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'
|
| 21 |
""")
|
| 22 |
|
| 23 |
# Train, evaluate and test a ML
|
|
|
|
| 60 |
|
| 61 |
# train the model - 5 runs
|
| 62 |
# evaluate the model on the test set
|
| 63 |
+
model.fit(x_train, y_train, epochs=5, validation_split=0.3)
|
| 64 |
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
|
| 65 |
post_train_results = f"Test accuracy: {test_acc} Test Loss: {test_loss}"
|
| 66 |
print(post_train_results)
|
|
|
|
| 69 |
probability_model = tf.keras.Sequential([model, tf.keras.layers.Softmax()])
|
| 70 |
|
| 71 |
|
| 72 |
+
def classifyImage(img):
|
|
|
|
|
|
|
|
|
|
| 73 |
# Normalize the pixel values
|
| 74 |
img = np.array(img) / 255.0
|
| 75 |
|