Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ import json
|
|
7 |
|
8 |
app = Flask(__name__)
|
9 |
|
10 |
-
# Load the TensorFlow
|
11 |
-
model = tf.keras.
|
12 |
|
13 |
# Load categories
|
14 |
with open('./categories.json') as f:
|
@@ -31,12 +31,11 @@ def predict():
|
|
31 |
image_array = preprocess_image(image)
|
32 |
|
33 |
# Make prediction
|
34 |
-
predictions = model
|
35 |
predicted_class = np.argmax(predictions, axis=1)[0]
|
36 |
|
37 |
# Map to category names
|
38 |
-
predicted_label =
|
39 |
-
predicted_label = predicted_label[0] if predicted_label else 'Unknown'
|
40 |
|
41 |
return jsonify({'class': predicted_label, 'confidence': float(predictions[0][predicted_class])})
|
42 |
|
|
|
7 |
|
8 |
app = Flask(__name__)
|
9 |
|
10 |
+
# Load the TensorFlow model
|
11 |
+
model = tf.keras.layers.TFSMLayer('./plant_disease_detection_saved_model', call_endpoint='serving_default')
|
12 |
|
13 |
# Load categories
|
14 |
with open('./categories.json') as f:
|
|
|
31 |
image_array = preprocess_image(image)
|
32 |
|
33 |
# Make prediction
|
34 |
+
predictions = model(image_array)
|
35 |
predicted_class = np.argmax(predictions, axis=1)[0]
|
36 |
|
37 |
# Map to category names
|
38 |
+
predicted_label = categories.get(str(predicted_class), 'Unknown')
|
|
|
39 |
|
40 |
return jsonify({'class': predicted_label, 'confidence': float(predictions[0][predicted_class])})
|
41 |
|