Spaces:
Runtime error
Runtime error
cuda doesn't work
Browse files- bayes/models.py +3 -2
- data/mnist/mnist_model.py +1 -1
bayes/models.py
CHANGED
@@ -42,7 +42,7 @@ def process_imagenet_get_model(data):
|
|
42 |
# Get the vgg16 model, used in the experiments
|
43 |
model = models.vgg16(pretrained=True)
|
44 |
model.eval()
|
45 |
-
model.cuda()
|
46 |
|
47 |
xtest = data['X']
|
48 |
ytest = data['y'].astype(int)
|
@@ -72,11 +72,12 @@ def process_imagenet_get_model(data):
|
|
72 |
perturbed_image[segments==i, 1] = background
|
73 |
perturbed_image[segments==i, 2] = background
|
74 |
perturbed_images.append(transf(perturbed_image)[None, :])
|
75 |
-
perturbed_images = torch.from_numpy(np.concatenate(perturbed_images, axis=0)).float()
|
76 |
predictions = []
|
77 |
for q in range(0, perturbed_images.shape[0], batch_size):
|
78 |
predictions.append(softmax(model(perturbed_images[q:q+batch_size])).cpu().detach().numpy())
|
79 |
predictions = np.concatenate(predictions, axis=0)
|
|
|
80 |
return predictions
|
81 |
return wrapped_model
|
82 |
|
|
|
42 |
# Get the vgg16 model, used in the experiments
|
43 |
model = models.vgg16(pretrained=True)
|
44 |
model.eval()
|
45 |
+
# model.cuda()
|
46 |
|
47 |
xtest = data['X']
|
48 |
ytest = data['y'].astype(int)
|
|
|
72 |
perturbed_image[segments==i, 1] = background
|
73 |
perturbed_image[segments==i, 2] = background
|
74 |
perturbed_images.append(transf(perturbed_image)[None, :])
|
75 |
+
perturbed_images = torch.from_numpy(np.concatenate(perturbed_images, axis=0)).float()
|
76 |
predictions = []
|
77 |
for q in range(0, perturbed_images.shape[0], batch_size):
|
78 |
predictions.append(softmax(model(perturbed_images[q:q+batch_size])).cpu().detach().numpy())
|
79 |
predictions = np.concatenate(predictions, axis=0)
|
80 |
+
print("Predictions made in models.py:", predictions)
|
81 |
return predictions
|
82 |
return wrapped_model
|
83 |
|
data/mnist/mnist_model.py
CHANGED
@@ -94,7 +94,7 @@ def main():
|
|
94 |
parser.add_argument('--save-model', action='store_true', default=False,
|
95 |
help='For Saving the current Model')
|
96 |
args = parser.parse_args()
|
97 |
-
use_cuda =
|
98 |
|
99 |
torch.manual_seed(args.seed)
|
100 |
|
|
|
94 |
parser.add_argument('--save-model', action='store_true', default=False,
|
95 |
help='For Saving the current Model')
|
96 |
args = parser.parse_args()
|
97 |
+
use_cuda = False # not args.no_cuda and torch.cuda.is_available()
|
98 |
|
99 |
torch.manual_seed(args.seed)
|
100 |
|