RebeccaNissan26 commited on
Commit
bb1ca07
·
1 Parent(s): 2404026

filepath not image

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -55,10 +55,9 @@ model.compile(metrics=metrics)
55
  # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
56
  # iface.launch()
57
 
58
- '#images/human_pixel_masks.npy'
59
  def predict(ash_image, model=model):
60
  #label = np.load(label_image)
61
- ash_image = np.load('images/552609781892851211.npy')[...,4]
62
  #ash_image = np.asarray(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)
@@ -68,7 +67,8 @@ def predict(ash_image, model=model):
68
  #color_prediction = np.stack([false_negative*.7, intersection*.7, false_possitive*.7], axis=2).reshape(256,256,3)
69
  seg_info = [(prediction, 'contrails')]
70
  return(ash_image, seg_info)
71
-
 
72
 
73
 
74
  if __name__ == "__main__":
@@ -77,13 +77,13 @@ if __name__ == "__main__":
77
  with gr.Blocks(title="Contrail Predictions") as demo:
78
  gr.Markdown("""<h1><center>Predict Contrails in Satellite Images</center></h1>""")
79
  with gr.Row():
80
- img_input = gr.Image(type="pil", height=256, width=256, label="Input image")
81
  img_output = gr.AnnotatedImage(label="Predictions", height=256, width=256, color_map=class2hexcolor)
82
 
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
 
 
55
  # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
56
  # iface.launch()
57
 
 
58
  def predict(ash_image, model=model):
59
  #label = np.load(label_image)
60
+ ash_image = np.load(ash_image)[...,4]
61
  #ash_image = np.asarray(ash_image)
62
  y_pred = model.predict(ash_image.reshape(1,256, 256, 3))
63
  prediction = np.argmax(y_pred[0], axis=2).reshape(256,256)
 
67
  #color_prediction = np.stack([false_negative*.7, intersection*.7, false_possitive*.7], axis=2).reshape(256,256,3)
68
  seg_info = [(prediction, 'contrails')]
69
  return(ash_image, seg_info)
70
+
71
+
72
 
73
 
74
  if __name__ == "__main__":
 
77
  with gr.Blocks(title="Contrail Predictions") as demo:
78
  gr.Markdown("""<h1><center>Predict Contrails in Satellite Images</center></h1>""")
79
  with gr.Row():
80
+ img_input = gr.Image(type="filepath", height=256, width=256, label="Input image")
81
  img_output = gr.AnnotatedImage(label="Predictions", height=256, width=256, color_map=class2hexcolor)
82
 
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 + "*.npy")
87
  examples = [i for i in images_dir]
88
  gr.Examples(examples=examples, inputs=img_input, outputs=img_output)
89