Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,22 +33,22 @@ model_file = download_model()
|
|
| 33 |
model = tf.keras.models.load_model(model_file)
|
| 34 |
|
| 35 |
# Perform image classification for single class output
|
| 36 |
-
# def predict_class(image):
|
| 37 |
-
# img = tf.cast(image, tf.float32)
|
| 38 |
-
# img = tf.image.resize(img, [input_shape[0], input_shape[1]])
|
| 39 |
-
# img = tf.expand_dims(img, axis=0)
|
| 40 |
-
# prediction = model.predict(img)
|
| 41 |
-
# class_index = tf.argmax(prediction[0]).numpy()
|
| 42 |
-
# predicted_class = labels[class_index]
|
| 43 |
-
# return predicted_class
|
| 44 |
-
|
| 45 |
-
# Perform image classification for multy class output
|
| 46 |
def predict_class(image):
|
| 47 |
img = tf.cast(image, tf.float32)
|
| 48 |
img = tf.image.resize(img, [input_shape[0], input_shape[1]])
|
| 49 |
img = tf.expand_dims(img, axis=0)
|
| 50 |
prediction = model.predict(img)
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
# UI Design for single class output
|
| 54 |
# def classify_image(image):
|
|
|
|
| 33 |
model = tf.keras.models.load_model(model_file)
|
| 34 |
|
| 35 |
# Perform image classification for single class output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def predict_class(image):
|
| 37 |
img = tf.cast(image, tf.float32)
|
| 38 |
img = tf.image.resize(img, [input_shape[0], input_shape[1]])
|
| 39 |
img = tf.expand_dims(img, axis=0)
|
| 40 |
prediction = model.predict(img)
|
| 41 |
+
class_index = tf.argmax(prediction[0]).numpy()
|
| 42 |
+
predicted_class = labels[class_index]
|
| 43 |
+
return predicted_class
|
| 44 |
+
|
| 45 |
+
# Perform image classification for multy class output
|
| 46 |
+
# def predict_class(image):
|
| 47 |
+
# img = tf.cast(image, tf.float32)
|
| 48 |
+
# img = tf.image.resize(img, [input_shape[0], input_shape[1]])
|
| 49 |
+
# img = tf.expand_dims(img, axis=0)
|
| 50 |
+
# prediction = model.predict(img)
|
| 51 |
+
# return prediction[0]
|
| 52 |
|
| 53 |
# UI Design for single class output
|
| 54 |
# def classify_image(image):
|