Spaces:
Runtime error
Runtime error
debugging inability to produce correct gif depending on parameters
Browse files- image_posterior.py +7 -2
image_posterior.py
CHANGED
@@ -21,6 +21,7 @@ from tqdm import tqdm
|
|
21 |
import ffmpeg
|
22 |
import lime.lime_tabular as baseline_lime_tabular
|
23 |
import shap
|
|
|
24 |
|
25 |
# Make sure we can get bayes explanations
|
26 |
parent_dir = dirname(os.path.abspath(os.getcwd()))
|
@@ -55,8 +56,12 @@ def create_gif(explanation_blr, img_name, segments, image, n_images=20, n_max=5)
|
|
55 |
draws = explanation_blr.draw_posterior_samples(n_images)
|
56 |
# Setup temporary directory to store paths in
|
57 |
print("tempfile.tempdir:", tempfile.TemporaryDirectory())
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
|
61 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
62 |
paths = []
|
|
|
21 |
import ffmpeg
|
22 |
import lime.lime_tabular as baseline_lime_tabular
|
23 |
import shap
|
24 |
+
import shutil
|
25 |
|
26 |
# Make sure we can get bayes explanations
|
27 |
parent_dir = dirname(os.path.abspath(os.getcwd()))
|
|
|
56 |
draws = explanation_blr.draw_posterior_samples(n_images)
|
57 |
# Setup temporary directory to store paths in
|
58 |
print("tempfile.tempdir:", tempfile.TemporaryDirectory())
|
59 |
+
temp_path = tempfile.TemporaryDirectory()
|
60 |
+
for root, dirs, files in os.walk(temp_path):
|
61 |
+
for f in files:
|
62 |
+
os.unlink(os.path.join(root, f))
|
63 |
+
for d in dirs:
|
64 |
+
shutil.rmtree(os.path.join(root, d))
|
65 |
|
66 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
67 |
paths = []
|