Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
imagenet10_valdir = 'C:/Users\Rui\Pictures/transfer_imgnet_10/val'

models_path = './models/'
adv_img_path = './images/0526/adv/'

adv_img_path = './images/0526/adv/'
2 changes: 1 addition & 1 deletion data/imagenet10_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_data_loaders():
# Normalization transform: scales the image tensors to a standard range
# These mean and std values are commonly used for ImageNet datasets
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]) # Standard ImageNet normalization values
std=[0.229, 0.224, 0.225])

# Define the data loader for the training dataset
train_loader = torch.utils.data.DataLoader(
Expand Down
1 change: 1 addition & 0 deletions deepsecure/adv_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ def train(self, train_dataloader, epochs):
netG_file_name = models_path + 'netG_epoch_' + str(epoch) + '.pth'
torch.save(self.generator.state_dict(), netG_file_name)


print("check")
2 changes: 1 addition & 1 deletion deepsecure/cat_adv_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
# loss_img_sum += loss_img_batch


# # print statistics


# torchvision.utils.save_image(torch.cat((adv_img[:7], images[:7], (images[idx])[:7])),
# adv_img_path + str(epoch) + ".png",
Expand Down
2 changes: 1 addition & 1 deletion deepsecure/catted_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self, num_encoder_layers, fix_encoder, tagged):
nn.Tanh()
]

# Create sequential decoder module
# Create sequential decoder module
self.decoder = nn.Sequential(*decoder_lis)

def forward(self, x1, x2):
Expand Down
1 change: 1 addition & 0 deletions deepsecure/regular_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ def forward(self, x):
x_t[:, :, :cfg.tag_size, :cfg.tag_size] = x_t.max()
out = self.decoder(x_t)


return out, x_t

3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
else:
# Initialize the regular generator
# Create adversarial generator with concatenated architecture
# False parameter indicates no regular generator for noise

generator = regular_generator(cfg.num_layers_ext, cfg.ext_fixed, cfg.G_tagged)
# Create an instance of Adv_Gen with the regular generator

advGen = Adv_Gen(device, feature_ext, generator)