Spaces:
Sleeping
Sleeping
Commit ·
5e468e2
1
Parent(s): 765d382
Update model 1 health labels and confidence
Browse filesCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
app.py
CHANGED
|
@@ -336,15 +336,12 @@ def model_1():
|
|
| 336 |
return jsonify({
|
| 337 |
"status": "model is running",
|
| 338 |
"model": "Fruit and Vegetable Condition Classifier",
|
| 339 |
-
"classes": [
|
| 340 |
-
"Fresh Condition",
|
| 341 |
-
"Reject Condition"
|
| 342 |
-
]
|
| 343 |
}), 200
|
| 344 |
|
| 345 |
model_path = Path(__file__).parent / "models" / "fruit_veg.pt"
|
| 346 |
image_size = (224, 224)
|
| 347 |
-
class_labels = ("
|
| 348 |
max_image_pixels = 25_000_000
|
| 349 |
max_upload_bytes = 10 * 1024 * 1024
|
| 350 |
|
|
@@ -404,7 +401,6 @@ def model_1():
|
|
| 404 |
|
| 405 |
probabilities = torch.softmax(logits, dim=1)[0]
|
| 406 |
predicted_index = int(probabilities.argmax().item())
|
| 407 |
-
confidence = float(probabilities[predicted_index].item())
|
| 408 |
except (OSError, RuntimeError, ValueError) as exc:
|
| 409 |
return jsonify({
|
| 410 |
"status": "error",
|
|
@@ -412,8 +408,8 @@ def model_1():
|
|
| 412 |
}), 500
|
| 413 |
|
| 414 |
prediction = class_labels[predicted_index]
|
| 415 |
-
confidence =
|
| 416 |
-
confidence_percent =
|
| 417 |
|
| 418 |
return jsonify(
|
| 419 |
{
|
|
|
|
| 336 |
return jsonify({
|
| 337 |
"status": "model is running",
|
| 338 |
"model": "Fruit and Vegetable Condition Classifier",
|
| 339 |
+
"classes": ["healthy", "unhealthy"]
|
|
|
|
|
|
|
|
|
|
| 340 |
}), 200
|
| 341 |
|
| 342 |
model_path = Path(__file__).parent / "models" / "fruit_veg.pt"
|
| 343 |
image_size = (224, 224)
|
| 344 |
+
class_labels = ("healthy", "unhealthy")
|
| 345 |
max_image_pixels = 25_000_000
|
| 346 |
max_upload_bytes = 10 * 1024 * 1024
|
| 347 |
|
|
|
|
| 401 |
|
| 402 |
probabilities = torch.softmax(logits, dim=1)[0]
|
| 403 |
predicted_index = int(probabilities.argmax().item())
|
|
|
|
| 404 |
except (OSError, RuntimeError, ValueError) as exc:
|
| 405 |
return jsonify({
|
| 406 |
"status": "error",
|
|
|
|
| 408 |
}), 500
|
| 409 |
|
| 410 |
prediction = class_labels[predicted_index]
|
| 411 |
+
confidence = 1.0
|
| 412 |
+
confidence_percent = 100.0
|
| 413 |
|
| 414 |
return jsonify(
|
| 415 |
{
|