Spaces:
Runtime error
Runtime error
Commit ·
09f51f6
1
Parent(s): 68341e4
change to jpg
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import segmentation_models as sm
|
|
| 9 |
from keras.metrics import MeanIoU
|
| 10 |
from functools import partial
|
| 11 |
from glob import glob
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
|
|
@@ -57,7 +58,8 @@ model.compile(metrics=metrics)
|
|
| 57 |
'#images/human_pixel_masks.npy'
|
| 58 |
def predict(ash_image, model=model):
|
| 59 |
#label = np.load(label_image)
|
| 60 |
-
ash_image = np.load(ash_image)[...,4]
|
|
|
|
| 61 |
y_pred = model.predict(ash_image.reshape(1,256, 256, 3))
|
| 62 |
prediction = np.argmax(y_pred[0], axis=2).reshape(256,256,1)
|
| 63 |
#intersection = label & prediction
|
|
@@ -81,7 +83,7 @@ if __name__ == "__main__":
|
|
| 81 |
section_btn = gr.Button("Generate Predictions")
|
| 82 |
section_btn.click(partial(predict, model=model), img_input, img_output)
|
| 83 |
|
| 84 |
-
images_dir = glob(os.path.join(os.getcwd(), "images") + os.sep + "*.
|
| 85 |
examples = [i for i in images_dir]
|
| 86 |
gr.Examples(examples=examples, inputs=img_input, outputs=img_output)
|
| 87 |
|
|
|
|
| 9 |
from keras.metrics import MeanIoU
|
| 10 |
from functools import partial
|
| 11 |
from glob import glob
|
| 12 |
+
from PIL import Image
|
| 13 |
|
| 14 |
|
| 15 |
|
|
|
|
| 58 |
'#images/human_pixel_masks.npy'
|
| 59 |
def predict(ash_image, model=model):
|
| 60 |
#label = np.load(label_image)
|
| 61 |
+
#ash_image = np.load(ash_image)[...,4]
|
| 62 |
+
ash_image = np.asarray(Image.open(ash_image))
|
| 63 |
y_pred = model.predict(ash_image.reshape(1,256, 256, 3))
|
| 64 |
prediction = np.argmax(y_pred[0], axis=2).reshape(256,256,1)
|
| 65 |
#intersection = label & prediction
|
|
|
|
| 83 |
section_btn = gr.Button("Generate Predictions")
|
| 84 |
section_btn.click(partial(predict, model=model), img_input, img_output)
|
| 85 |
|
| 86 |
+
images_dir = glob(os.path.join(os.getcwd(), "images") + os.sep + "*.jpg")
|
| 87 |
examples = [i for i in images_dir]
|
| 88 |
gr.Examples(examples=examples, inputs=img_input, outputs=img_output)
|
| 89 |
|