Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhentingWang committed May 23, 2024
1 parent 157fefb commit 5ebdf63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ python run_write_re_loss_to_txt.py --gpu 4 --filePath ./sdv15_generated_imgs/ --
--num_iter 100 --write_txt_path ./ReconstructionLosses_Model_sdv2base_Images_sdv15Generated.txt
```

# Visualization the Distributions of the Reconstruction Losses
# Belonging Detection and Visualization the Distributions of the Reconstruction Losses

```bash
python draw_distributions_from_txt.py \
python detection.py \
--txt_1 ./ReconstructionLosses_Model_sdv2base_Images_sdv2baseGenerated.txt \
--txt_2 ./ReconstructionLosses_Model_sdv2base_Images_sdv15Generated.txt \
--label_1 'Belongings' \
Expand Down
17 changes: 1 addition & 16 deletions draw_distributions_from_txt.py → detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

list_1.sort()
threshold = list_1[-int(0.05*len(list_1))]
#threshold = list_1[-int(0.15*len(list_1))]
print(threshold)

fp=0
Expand All @@ -51,33 +50,19 @@

print("tp,fp,fn,tn:",tp,fp,fn,tn)

#bins_1 = 5
#bins_1 = 7

bins_1 = 30
bins_2 = 150
plt.hist(list_1, bins_1, weights=np.ones(len(list_1)) / len(list_1), alpha=0.5, label=args.label_1)
plt.hist(list_2, bins_2, weights=np.ones(len(list_2)) / len(list_2), alpha=0.5, label=args.label_2)
#plt.hist(avg_score_diff_clean_list, bins,alpha=0.5, label='w/o Trojan')
#plt.hist(avg_score_diff_trojan_list, bins,alpha=0.5, label='w/ Trojan')

#plt.legend(loc='upper right', fontsize = 22)
#plt.legend(loc='best', fontsize = 20)
'''plt.legend(loc='best', fontsize = 18)
plt.tick_params(labelsize=12)
plt.xlabel('Reconstructed MSE Loss', fontsize = 18)
plt.ylabel('Percentage', fontsize = 18)'''
#plt.title('avg_score_diff', fontsize = 20)

plt.legend(loc='best', fontsize = 14)
plt.tick_params(labelsize=22)
plt.xlabel('Reconstructed MSE Loss', fontsize = 22)
plt.ylabel('Percentage', fontsize = 22)

plt.gca().xaxis.set_major_formatter(ticker.FormatStrFormatter('%.4f'))
#plt.gca().xaxis.set_major_formatter(ticker.FormatStrFormatter('%.2f'))
plt.gca().yaxis.set_major_formatter(ticker.FormatStrFormatter('%.2f'))
#plt.xlim((0, 5))
#plt.xlim((0, 1.95))
plt.tight_layout()
plt.savefig(args.save_name, dpi=600)
plt.close('all')

0 comments on commit 5ebdf63

Please sign in to comment.