Update app.py
Browse files
app.py
CHANGED
|
@@ -38,16 +38,16 @@ def emotion_analysis(emotions):
|
|
| 38 |
|
| 39 |
|
| 40 |
def predict_image(pic):
|
| 41 |
-
|
| 42 |
#show_img=image.load_img(pic, grayscale=False, target_size=(200, 200))
|
| 43 |
#pic = pic.reshape(-1,48, 48,1])
|
| 44 |
-
x = image.img_to_array(
|
| 45 |
|
| 46 |
x = np.expand_dims(x, axis = 0)
|
| 47 |
|
| 48 |
x /= 255
|
| 49 |
#x = x.reshape(-1,48,48,1)
|
| 50 |
-
custom = new_model.predict(x
|
| 51 |
|
| 52 |
emotion_analysis(custom[0])
|
| 53 |
|
|
@@ -71,7 +71,8 @@ iface = gr.Interface(
|
|
| 71 |
predict_image,
|
| 72 |
[
|
| 73 |
#gr.inputs.Image(shape=None, image_mode="RGB", invert_colors=False, source="upload", tool="editor", type="numpy", label=None, optional=False)
|
| 74 |
-
gr.inputs.Image(source="upload",shape=(48,48))
|
|
|
|
| 75 |
],
|
| 76 |
|
| 77 |
"text",
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def predict_image(pic):
|
| 41 |
+
img = image.load_img(pic, grayscale=True, target_size=(48, 48))
|
| 42 |
#show_img=image.load_img(pic, grayscale=False, target_size=(200, 200))
|
| 43 |
#pic = pic.reshape(-1,48, 48,1])
|
| 44 |
+
x = image.img_to_array(img)
|
| 45 |
|
| 46 |
x = np.expand_dims(x, axis = 0)
|
| 47 |
|
| 48 |
x /= 255
|
| 49 |
#x = x.reshape(-1,48,48,1)
|
| 50 |
+
custom = new_model.predict(x)
|
| 51 |
|
| 52 |
emotion_analysis(custom[0])
|
| 53 |
|
|
|
|
| 71 |
predict_image,
|
| 72 |
[
|
| 73 |
#gr.inputs.Image(shape=None, image_mode="RGB", invert_colors=False, source="upload", tool="editor", type="numpy", label=None, optional=False)
|
| 74 |
+
#gr.inputs.Image(source="upload",shape=(48,48))
|
| 75 |
+
gr.inputs.Image(source="upload",type="filepath")
|
| 76 |
],
|
| 77 |
|
| 78 |
"text",
|