pemujo commited on
Commit
d708432
·
1 Parent(s): 528baa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -61,13 +61,13 @@ def predict(ash_image, model=model):
61
  #label = np.load(label_image)
62
  # ash_image = np.load('images/552609781892851211.npy')
63
  print(images_means)
64
-
65
- im_mean = round(np.asarray(ash_image).mean(),4)
66
  print(im_mean)
67
  if im_mean in images_means:
68
- ash_image = np.load('images/' + images_means[im_mean])
69
 
70
- y_pred = model.predict(np.asarray(ash_image).reshape(1,256, 256, 3))
71
  prediction = np.argmax(y_pred[0], axis=2).reshape(256,256)
72
  #intersection = label & prediction
73
  #false_negative = label - intersection
@@ -83,7 +83,7 @@ if __name__ == "__main__":
83
  with gr.Blocks(title="Contrail Predictions") as demo:
84
  gr.Markdown("""<h1><center>Predict Contrails in Satellite Images</center></h1>""")
85
  with gr.Row():
86
- img_input = gr.Image(type="pil", height=256, width=256, label="Image Input")
87
  img_output = gr.AnnotatedImage(label="Predictions", height=256, width=256, color_map=class2hexcolor)
88
 
89
  section_btn = gr.Button("Generate Predictions")
 
61
  #label = np.load(label_image)
62
  # ash_image = np.load('images/552609781892851211.npy')
63
  print(images_means)
64
+ im = np.asarray(Image.open(ash_image))
65
+ im_mean = round(im.mean(),4)
66
  print(im_mean)
67
  if im_mean in images_means:
68
+ im = np.load('images/' + images_means[im_mean])
69
 
70
+ y_pred = model.predict(im.reshape(1,256, 256, 3))
71
  prediction = np.argmax(y_pred[0], axis=2).reshape(256,256)
72
  #intersection = label & prediction
73
  #false_negative = label - intersection
 
83
  with gr.Blocks(title="Contrail Predictions") as demo:
84
  gr.Markdown("""<h1><center>Predict Contrails in Satellite Images</center></h1>""")
85
  with gr.Row():
86
+ img_input = gr.Image(type="filepath", height=256, width=256, label="Image Input")
87
  img_output = gr.AnnotatedImage(label="Predictions", height=256, width=256, color_map=class2hexcolor)
88
 
89
  section_btn = gr.Button("Generate Predictions")