Commit
Β·
fad3a13
1
Parent(s):
21fbc77
updated app with warning message
Browse files
app.py
CHANGED
|
@@ -130,6 +130,9 @@ ENTROPY_THR = 2.7
|
|
| 130 |
lite_model = "β‘ Lite β‘ less accurate prediction"
|
| 131 |
pro_model = "π Pro π more accurate prediction"
|
| 132 |
|
|
|
|
|
|
|
|
|
|
| 133 |
# Computes the entropy
|
| 134 |
def entropy(pred_probs):
|
| 135 |
|
|
@@ -193,7 +196,7 @@ def classify_food(image, model=pro_model) -> Tuple[Dict, str, str]:
|
|
| 193 |
# Check out model parameter
|
| 194 |
if model == None:
|
| 195 |
model = pro_model
|
| 196 |
-
|
| 197 |
# Make prediction...
|
| 198 |
with torch.inference_mode():
|
| 199 |
|
|
@@ -329,7 +332,7 @@ def classify_food(image, model=pro_model) -> Tuple[Dict, str, str]:
|
|
| 329 |
# Create title, description, and examples
|
| 330 |
title = "Transform-Eats Large<br>π₯ͺπ₯π₯£π₯©ππ£π°"
|
| 331 |
description = f"""
|
| 332 |
-
A cutting-edge
|
| 333 |
"""
|
| 334 |
|
| 335 |
# Group food items alphabetically
|
|
@@ -405,6 +408,7 @@ with gr.Blocks(theme="ocean") as demo:
|
|
| 405 |
gr.Textbox(label="Prediction time:"),
|
| 406 |
gr.Textbox(label="Food Description:"),
|
| 407 |
status_output], # outputs
|
|
|
|
| 408 |
examples=food_vision_examples, # Create examples list from "examples/" directory
|
| 409 |
article=article, # Created by...
|
| 410 |
flagging_mode=flagging_mode, # Only For debugging
|
|
|
|
| 130 |
lite_model = "β‘ Lite β‘ less accurate prediction"
|
| 131 |
pro_model = "π Pro π more accurate prediction"
|
| 132 |
|
| 133 |
+
# Set messages
|
| 134 |
+
warning_message = "β οΈ Processing times may be longer than usual due to high server demand. If that's the case, consider trying again later for faster response times. β οΈ"
|
| 135 |
+
|
| 136 |
# Computes the entropy
|
| 137 |
def entropy(pred_probs):
|
| 138 |
|
|
|
|
| 196 |
# Check out model parameter
|
| 197 |
if model == None:
|
| 198 |
model = pro_model
|
| 199 |
+
|
| 200 |
# Make prediction...
|
| 201 |
with torch.inference_mode():
|
| 202 |
|
|
|
|
| 332 |
# Create title, description, and examples
|
| 333 |
title = "Transform-Eats Large<br>π₯ͺπ₯π₯£π₯©ππ£π°"
|
| 334 |
description = f"""
|
| 335 |
+
A cutting-edge transformer model to classify 101 delicious food types. Discover the power of AI in culinary recognition.
|
| 336 |
"""
|
| 337 |
|
| 338 |
# Group food items alphabetically
|
|
|
|
| 408 |
gr.Textbox(label="Prediction time:"),
|
| 409 |
gr.Textbox(label="Food Description:"),
|
| 410 |
status_output], # outputs
|
| 411 |
+
description=f"{warning_message}",
|
| 412 |
examples=food_vision_examples, # Create examples list from "examples/" directory
|
| 413 |
article=article, # Created by...
|
| 414 |
flagging_mode=flagging_mode, # Only For debugging
|