Skip to content

Commit

Permalink
GitLab Release: TAG=0.4.1, SHA=181da6c8, PIPE=21471
Browse files Browse the repository at this point in the history
  • Loading branch information
lockwoodar committed Aug 14, 2024
1 parent b875054 commit 3a8ef52
Show file tree
Hide file tree
Showing 23 changed files with 1,616 additions and 1,229 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = 'HEART-library'
copyright = '2024, IBM'
author = 'IBM'
release = '0.4.0'
release = '0.4.1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
18 changes: 9 additions & 9 deletions gradio/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@


def update_patch_sliders(*args):
from typing import Dict

x_location, y_location, patch_dim, dataset_type, dataset_path, dataset_split, image = args

Expand Down Expand Up @@ -167,7 +168,6 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
from functools import partial
import requests
from heart_library.estimators.object_detection import JaticPyTorchObjectDetectionOutput
from typing import Dict, Tuple, Any
from secrets import SystemRandom
from heart_library.utils import process_inputs_for_art

Expand Down Expand Up @@ -745,7 +745,7 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
out_imgs = []
for i in range(len(adv_detections)):
preds_orig = extract_predictions(adv_detections[i], box_thresh)
out_img = plot_image_with_boxes(img=adv_x[i].transpose(1,2,0).copy(),
out_img = plot_image_with_boxes(img=adv_x[0][i].transpose(1,2,0).copy(),
boxes=preds_orig[1], pred_cls=preds_orig[0], title="Detections")
if out_img.max() > 1:
out_img = out_img.astype(np.uint8)
Expand Down Expand Up @@ -845,7 +845,7 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
out_imgs_adv = []
for i in range(len(adv_detections)):
preds_orig = extract_predictions(adv_detections[i], box_thresh)
out_img = plot_image_with_boxes(img=adv_x[i].transpose(1,2,0).copy(),
out_img = plot_image_with_boxes(img=adv_x[0][i].transpose(1,2,0).copy(),
boxes=preds_orig[1], pred_cls=preds_orig[0], title="Detections")
if out_img.max() > 1:
out_img = out_img.astype(np.uint8)
Expand Down Expand Up @@ -1005,17 +1005,17 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]


# transform to probabilities
preds = softmax(torch.from_numpy(preds), dim=1)
preds = softmax(torch.from_numpy(preds[0]), dim=1)
labels = {}
for i, label in enumerate(clf_labels):
labels[label] = preds[0][i]

adv_preds = softmax(torch.from_numpy(adv_preds), dim=1)
adv_preds = softmax(torch.from_numpy(adv_preds[0]), dim=1)
adv_labels = {}
for i, label in enumerate(clf_labels):
adv_labels[label] = adv_preds[0][i]

adv_imgs = [img.transpose(1,2,0) for img in x_adv]
adv_imgs = [img.transpose(1,2,0) for img in x_adv[0]]

image_list = []

Expand Down Expand Up @@ -1090,13 +1090,13 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
perturbation_added = float(result["mean_delta"])

# transform to probabilities
preds = softmax(torch.from_numpy(preds), dim=1)
preds = softmax(torch.from_numpy(preds[0]), dim=1)

labels = {}
for i, label in enumerate(clf_labels):
labels[label] = preds[0][i]

adv_preds = softmax(torch.from_numpy(adv_preds), dim=1)
adv_preds = softmax(torch.from_numpy(adv_preds[0]), dim=1)
adv_labels = {}
for i, label in enumerate(clf_labels):
adv_labels[label] = adv_preds[0][i]
Expand All @@ -1106,7 +1106,7 @@ def __getitem__(self, ind: int) -> Tuple[np.ndarray, np.ndarray, Dict[str, Any]]
robust_accuracy = float(robust_accuracy)
perturbation_added = float(perturbation_added)

adv_imgs = [img.transpose(1,2,0) for img in x_adv]
adv_imgs = [img.transpose(1,2,0) for img in x_adv[0]]

image_list = []

Expand Down
44 changes: 22 additions & 22 deletions notebooks/0_get_started_heart.ipynb

Large diffs are not rendered by default.

150 changes: 83 additions & 67 deletions notebooks/1_get_started_pgd_attack.ipynb

Large diffs are not rendered by default.

932 changes: 559 additions & 373 deletions notebooks/2_get_started_auto_attack.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 3a8ef52

Please sign in to comment.