Skip to content

Commit acf4db0

Browse files
author
Yi Zhang
committed
update
1 parent 0dd8617 commit acf4db0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

config.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
num_inference_steps = 50
44
num_batch = 5
55
batch_size = 12
6+
sample_num = 800
67
model_id = "runwayml/stable-diffusion-v1-5"
78

89
e_threshold = 0.08

version_defence.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pandas as pd
1616
torch.cuda.empty_cache()
1717
from config import (
18-
e_threshold, origin_prompt_path, sigma,
18+
sample_num, origin_prompt_path, sigma,
1919
num_inference_steps, num_batch, batch_size,
2020
model_id
2121
)
@@ -184,7 +184,7 @@ def defence_autocorrect(influent_sentence):
184184
logger.info(f"disturb_num: {sample_data[0]}")
185185
n = 1
186186
epsilon = 1000
187-
for count in range(400):
187+
for count in range(sample_num):
188188
selected = random.choices(strings, k=1)[0]
189189
disturb_prompt = defence_spellchecker(selected)
190190
if disturb_prompt == ori_prompt:

version_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pandas as pd
1717
torch.cuda.empty_cache()
1818
from config import (
19-
e_threshold, origin_prompt_path, sigma,
19+
sample_num, origin_prompt_path, sigma,
2020
num_inference_steps, num_batch, batch_size,
2121
model_id
2222
)
@@ -165,7 +165,7 @@ def get_origin_prompt(origin_prompt_path):
165165
logger.info(f"disturb_num: {sample_data[0]}")
166166
n = 1
167167
epsilon = 1000
168-
for count in range(400):
168+
for count in range(sample_num):
169169
disturb_prompt = random.choices(strings, k=1)[0]
170170
L_distance.append(Levenshtein.distance(ori_prompt, disturb_prompt))
171171
whether_robust = cal_loss(ori_loss, disturb_prompt, ori_prompt)

0 commit comments

Comments
 (0)