Spaces:
Runtime error
Runtime error
testing embedding html vids
Browse files- app.py +9 -0
- bayes/data_routines.py +3 -3
- image_posterior.py +1 -1
app.py
CHANGED
@@ -39,6 +39,15 @@ def get_image_data():
|
|
39 |
|
40 |
def segmentation_generation(image_name, c_width, n_top, n_gif_imgs):
|
41 |
print("GRADIO INPUTS:", image_name, c_width, n_top, n_gif_imgs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
cred_width = c_width
|
43 |
n_top_segs = n_top
|
44 |
n_gif_images = n_gif_imgs
|
|
|
39 |
|
40 |
def segmentation_generation(image_name, c_width, n_top, n_gif_imgs):
|
41 |
print("GRADIO INPUTS:", image_name, c_width, n_top, n_gif_imgs)
|
42 |
+
|
43 |
+
html = '''
|
44 |
+
<div style='max-width:100%; max-height:360px; overflow:auto'>
|
45 |
+
<video width="320" height="240" autoplay>
|
46 |
+
<source src="./test.mp4" type=video/mp4>
|
47 |
+
</video>
|
48 |
+
</div>'''
|
49 |
+
return html
|
50 |
+
|
51 |
cred_width = c_width
|
52 |
n_top_segs = n_top
|
53 |
n_gif_images = n_gif_imgs
|
bayes/data_routines.py
CHANGED
@@ -38,7 +38,7 @@ def get_and_preprocess_compas_data():
|
|
38 |
POSITIVE_OUTCOME = PARAMS['positive_outcome']
|
39 |
NEGATIVE_OUTCOME = PARAMS['negative_outcome']
|
40 |
|
41 |
-
compas_df = pd.read_csv("
|
42 |
compas_df = compas_df.loc[(compas_df['days_b_screening_arrest'] <= 30) &
|
43 |
(compas_df['days_b_screening_arrest'] >= -30) &
|
44 |
(compas_df['is_recid'] != -1) &
|
@@ -87,7 +87,7 @@ def get_and_preprocess_german():
|
|
87 |
POSITIVE_OUTCOME = PARAMS['positive_outcome']
|
88 |
NEGATIVE_OUTCOME = PARAMS['negative_outcome']
|
89 |
|
90 |
-
X = pd.read_csv("
|
91 |
y = X["GoodCustomer"]
|
92 |
|
93 |
X = X.drop(["GoodCustomer", "PurposeOfLoan"], axis=1)
|
@@ -172,7 +172,7 @@ def get_mnist(num):
|
|
172 |
"""
|
173 |
|
174 |
# Get the mnist data
|
175 |
-
test_loader = torch.utils.data.DataLoader(datasets.MNIST('
|
176 |
train=False,
|
177 |
download=True,
|
178 |
transform=transforms.Compose([transforms.ToTensor(),
|
|
|
38 |
POSITIVE_OUTCOME = PARAMS['positive_outcome']
|
39 |
NEGATIVE_OUTCOME = PARAMS['negative_outcome']
|
40 |
|
41 |
+
compas_df = pd.read_csv("./data/compas-scores-two-years.csv", index_col=0)
|
42 |
compas_df = compas_df.loc[(compas_df['days_b_screening_arrest'] <= 30) &
|
43 |
(compas_df['days_b_screening_arrest'] >= -30) &
|
44 |
(compas_df['is_recid'] != -1) &
|
|
|
87 |
POSITIVE_OUTCOME = PARAMS['positive_outcome']
|
88 |
NEGATIVE_OUTCOME = PARAMS['negative_outcome']
|
89 |
|
90 |
+
X = pd.read_csv("./data/german_processed.csv")
|
91 |
y = X["GoodCustomer"]
|
92 |
|
93 |
X = X.drop(["GoodCustomer", "PurposeOfLoan"], axis=1)
|
|
|
172 |
"""
|
173 |
|
174 |
# Get the mnist data
|
175 |
+
test_loader = torch.utils.data.DataLoader(datasets.MNIST('./data/mnist',
|
176 |
train=False,
|
177 |
download=True,
|
178 |
transform=transforms.Compose([transforms.ToTensor(),
|
image_posterior.py
CHANGED
@@ -64,7 +64,7 @@ def create_gif(explanation_blr, segments, image, n_images=20, n_max=5):
|
|
64 |
plt.imshow(c_image, alpha=0.3)
|
65 |
paths.append(os.path.join(tmpdirname, f"{i}.png"))
|
66 |
plt.savefig(paths[-1])
|
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}")
|
|
|
64 |
plt.imshow(c_image, alpha=0.3)
|
65 |
paths.append(os.path.join(tmpdirname, f"{i}.png"))
|
66 |
plt.savefig(paths[-1])
|
67 |
+
print("CREATING VIDEO NOW")
|
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}")
|