Spaces:
Sleeping
Sleeping
tonyliu404
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -228,9 +228,6 @@ class_names = [
|
|
228 |
"tuna_tartare", "waffles"
|
229 |
]
|
230 |
|
231 |
-
def softmax_with_temperature(logits, temperature=1.0):
|
232 |
-
logits = logits / temperature
|
233 |
-
return tf.nn.softmax(logits)
|
234 |
|
235 |
def classifyImage(input_image):
|
236 |
input_image = input_image.resize((img_size, img_size))
|
@@ -241,11 +238,17 @@ def classifyImage(input_image):
|
|
241 |
|
242 |
predictions = model.predict(input_array)[0]
|
243 |
print(f"Predictions: {predictions}")
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
print(f"Predictions AFTER SOFTMAX: {predictions}")
|
246 |
|
247 |
probability_sum = predictions.sum() * 100
|
248 |
-
print(f"Sum of predictions (as percentages): {probability_sum:.2f}%")
|
249 |
|
250 |
for i, confidence in enumerate(predictions):
|
251 |
print(f"Class {i} has {confidence*100:.2f}% confidence")
|
|
|
228 |
"tuna_tartare", "waffles"
|
229 |
]
|
230 |
|
|
|
|
|
|
|
231 |
|
232 |
def classifyImage(input_image):
|
233 |
input_image = input_image.resize((img_size, img_size))
|
|
|
238 |
|
239 |
predictions = model.predict(input_array)[0]
|
240 |
print(f"Predictions: {predictions}")
|
241 |
+
|
242 |
+
|
243 |
+
probability_sum = predictions.sum() * 100
|
244 |
+
print(f"Sum of predictions BEFORE SOFTMAX(as percentages): {probability_sum:.2f}%")
|
245 |
+
|
246 |
+
|
247 |
+
predictions = tf.nn.softmax(predictions).numpy() #testing
|
248 |
print(f"Predictions AFTER SOFTMAX: {predictions}")
|
249 |
|
250 |
probability_sum = predictions.sum() * 100
|
251 |
+
print(f"Sum of predictions AFTER SOFTMAX(as percentages): {probability_sum:.2f}%")
|
252 |
|
253 |
for i, confidence in enumerate(predictions):
|
254 |
print(f"Class {i} has {confidence*100:.2f}% confidence")
|