Spaces:
Runtime error
Runtime error
modifying image_posterior
Browse files- app.py +5 -5
- image_posterior.py +3 -0
app.py
CHANGED
@@ -38,9 +38,9 @@ def get_image_data(image_name):
|
|
38 |
def segmentation_generation(image_name, c_width, n_top, n_gif_imgs):
|
39 |
print("Inputs Received:", image_name, c_width, n_top, n_gif_imgs)
|
40 |
|
41 |
-
cred_width = c_width
|
42 |
-
n_top_segs = n_top
|
43 |
-
n_gif_images = n_gif_imgs
|
44 |
image, model_and_data = get_image_data(image_name)
|
45 |
print("model_and_data", model_and_data)
|
46 |
# Unpack datax
|
@@ -78,12 +78,12 @@ def segmentation_generation(image_name, c_width, n_top, n_gif_imgs):
|
|
78 |
rout = exp_init.explain(classifier_f=cur_model,
|
79 |
data=np.ones_like(xtrain[0]),
|
80 |
label=label,
|
81 |
-
cred_width=
|
82 |
focus_sample=False,
|
83 |
l2=False)
|
84 |
|
85 |
# Create the gif of the explanation
|
86 |
-
return create_gif(rout['blr'], image_name, segments, instance,
|
87 |
|
88 |
def image_mod(image):
|
89 |
return image.rotate(45)
|
|
|
38 |
def segmentation_generation(image_name, c_width, n_top, n_gif_imgs):
|
39 |
print("Inputs Received:", image_name, c_width, n_top, n_gif_imgs)
|
40 |
|
41 |
+
# cred_width = c_width
|
42 |
+
# n_top_segs = n_top
|
43 |
+
# n_gif_images = n_gif_imgs
|
44 |
image, model_and_data = get_image_data(image_name)
|
45 |
print("model_and_data", model_and_data)
|
46 |
# Unpack datax
|
|
|
78 |
rout = exp_init.explain(classifier_f=cur_model,
|
79 |
data=np.ones_like(xtrain[0]),
|
80 |
label=label,
|
81 |
+
cred_width=c_width,
|
82 |
focus_sample=False,
|
83 |
l2=False)
|
84 |
|
85 |
# Create the gif of the explanation
|
86 |
+
return create_gif(rout['blr'], image_name, segments, instance, n_gif_imgs, n_top)
|
87 |
|
88 |
def image_mod(image):
|
89 |
return image.rotate(45)
|
image_posterior.py
CHANGED
@@ -69,6 +69,9 @@ def create_gif(explanation_blr, img_name, segments, image, n_images=20, n_max=5)
|
|
69 |
# https://stackoverflow.com/questions/61716066/creating-an-animation-out-of-matplotlib-pngs
|
70 |
print(f"Saving gif to {img_name}_explanation.gif")
|
71 |
|
|
|
|
|
|
|
72 |
ims = [imageio.imread(f) for f in paths]
|
73 |
imageio.mimwrite(f'{img_name}_explanation.gif', ims)
|
74 |
|
|
|
69 |
# https://stackoverflow.com/questions/61716066/creating-an-animation-out-of-matplotlib-pngs
|
70 |
print(f"Saving gif to {img_name}_explanation.gif")
|
71 |
|
72 |
+
if(os.path.exists(f'file/{img_name}_explanation.gif')):
|
73 |
+
os.remove(f'file/{img_name}_explanation.gif')
|
74 |
+
|
75 |
ims = [imageio.imread(f) for f in paths]
|
76 |
imageio.mimwrite(f'{img_name}_explanation.gif', ims)
|
77 |
|