Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,10 @@ import tensorflow as tf
|
|
| 4 |
|
| 5 |
model = tf.keras.models.load_model('model.h5')
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def temp(image):
|
| 8 |
img = (image['composite'])
|
| 9 |
img = np.expand_dims(img, axis=0).astype('float32')
|
|
@@ -11,7 +15,7 @@ def temp(image):
|
|
| 11 |
y_pred = model.predict(img)
|
| 12 |
prediction = {0:'অ', 1:'আ', 3:'ই', 4:'ঈ', 5:'উ', 6:'ঊ', 7:'ঋ', 8:'এ', 9:'ঐ', 10:'ও', 2:'ঔ'}
|
| 13 |
for i in range(11):
|
| 14 |
-
if y_pred[0]
|
| 15 |
return prediction[i]
|
| 16 |
|
| 17 |
iface = gr.Interface(
|
|
|
|
| 4 |
|
| 5 |
model = tf.keras.models.load_model('model.h5')
|
| 6 |
|
| 7 |
+
def softmax(x):
|
| 8 |
+
e_x = np.exp(x - np.max(x))
|
| 9 |
+
return e_x / e_x.sum()
|
| 10 |
+
|
| 11 |
def temp(image):
|
| 12 |
img = (image['composite'])
|
| 13 |
img = np.expand_dims(img, axis=0).astype('float32')
|
|
|
|
| 15 |
y_pred = model.predict(img)
|
| 16 |
prediction = {0:'অ', 1:'আ', 3:'ই', 4:'ঈ', 5:'উ', 6:'ঊ', 7:'ঋ', 8:'এ', 9:'ঐ', 10:'ও', 2:'ঔ'}
|
| 17 |
for i in range(11):
|
| 18 |
+
if np.argmax(softmax(y_pred[0])) == i:
|
| 19 |
return prediction[i]
|
| 20 |
|
| 21 |
iface = gr.Interface(
|