kritsg commited on
Commit
8e67e6e
·
1 Parent(s): 2f036cb

starting to implement image_posterior model code

Browse files
Files changed (2) hide show
  1. app.py +2 -4
  2. image_posterior.py +2 -2
app.py CHANGED
@@ -5,6 +5,7 @@ import argparse
5
  import os
6
  from os.path import exists, dirname
7
  import sys
 
8
 
9
  parent_dir = dirname(os.path.abspath(os.getcwd()))
10
  sys.path.append(parent_dir)
@@ -78,11 +79,8 @@ def image_mod(image):
78
 
79
 
80
  if __name__ == "__main__":
81
- args = parser.parse_args()
82
- # main(args)
83
-
84
  inp = gr.inputs.Image(label="Input Image", type="pil")
85
- out = gr.outputs.Image()
86
 
87
  iface = gr.Interface(segmentation_generation, inputs=inp, outputs=out, examples=[["./imagenet_diego.png"]])
88
  iface.launch()
 
5
  import os
6
  from os.path import exists, dirname
7
  import sys
8
+ import flask
9
 
10
  parent_dir = dirname(os.path.abspath(os.getcwd()))
11
  sys.path.append(parent_dir)
 
79
 
80
 
81
  if __name__ == "__main__":
 
 
 
82
  inp = gr.inputs.Image(label="Input Image", type="pil")
83
+ out = gr.outputs.Video(label="Output Image")
84
 
85
  iface = gr.Interface(segmentation_generation, inputs=inp, outputs=out, examples=[["./imagenet_diego.png"]])
86
  iface.launch()
image_posterior.py CHANGED
@@ -18,7 +18,7 @@ import numpy as np
18
  from skimage.segmentation import mark_boundaries
19
  import tempfile
20
  from tqdm import tqdm
21
-
22
  import lime.lime_tabular as baseline_lime_tabular
23
  import shap
24
 
@@ -67,7 +67,7 @@ def create_gif(explanation_blr, segments, image, n_images=20, n_max=5):
67
 
68
  # Save to gif
69
  # https://stackoverflow.com/questions/61716066/creating-an-animation-out-of-matplotlib-pngs
70
- print(f"Saving gif to {save_loc}")
71
  ims = [imageio.imread(f) for f in paths]
72
  return imageio.mimwrite(imageio.RETURN_BYTES, ims)
73
 
 
18
  from skimage.segmentation import mark_boundaries
19
  import tempfile
20
  from tqdm import tqdm
21
+ import ffmpeg
22
  import lime.lime_tabular as baseline_lime_tabular
23
  import shap
24
 
 
67
 
68
  # Save to gif
69
  # https://stackoverflow.com/questions/61716066/creating-an-animation-out-of-matplotlib-pngs
70
+ # print(f"Saving gif to {save_loc}")
71
  ims = [imageio.imread(f) for f in paths]
72
  return imageio.mimwrite(imageio.RETURN_BYTES, ims)
73