tnk2908 commited on
Commit
0852a55
1 Parent(s): 9bd2dae

Add comments and update README.md

Browse files
Files changed (4) hide show
  1. README.md +6 -1
  2. analyse.py +0 -3
  3. notebooks/plot.ipynb +0 -0
  4. stegno.py +12 -1
README.md CHANGED
@@ -34,6 +34,10 @@ python api.py
34
  ```Bash
35
  python main.py -h
36
  ```
 
 
 
 
37
  ## Documentation
38
  - To access the documentation for the RestAPI, launch the RestAPI and go to <http://localhost:6969/docs>
39
  ## Configuration
@@ -55,8 +59,9 @@ python main.py -h
55
  - [x] Hashing schemes.
56
  - [x] Rest API.
57
  - [x] Basic Demo.
58
- - [ ] Statistical experiments.
59
  - [ ] Attack strategies
60
  - [ ] White-box
61
  - [ ] Black-box
62
 
 
 
34
  ```Bash
35
  python main.py -h
36
  ```
37
+ - To run analysis, see the help message by:
38
+ ```Bash
39
+ python analysis.py -h
40
+ ```
41
  ## Documentation
42
  - To access the documentation for the RestAPI, launch the RestAPI and go to <http://localhost:6969/docs>
43
  ## Configuration
 
59
  - [x] Hashing schemes.
60
  - [x] Rest API.
61
  - [x] Basic Demo.
62
+ - [x] Statistical experiments.
63
  - [ ] Attack strategies
64
  - [ ] White-box
65
  - [ ] Black-box
66
 
67
+
analyse.py CHANGED
@@ -537,9 +537,6 @@ def main(args):
537
  processor.run()
538
  processor.plot(args.figs_dir)
539
 
540
- # if args.figs_dir:
541
- # process_results(results, args.figs_dir)
542
-
543
 
544
  if __name__ == "__main__":
545
  args = create_args()
 
537
  processor.run()
538
  processor.plot(args.figs_dir)
539
 
 
 
 
540
 
541
  if __name__ == "__main__":
542
  args = create_args()
notebooks/plot.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
stegno.py CHANGED
@@ -26,19 +26,28 @@ def generate(
26
  generator: torch.Generator | None = None,
27
  ):
28
  """
29
- Generate the sequence containing the hidden data.
30
 
31
  Args:
32
  tokenizer: tokenizer to use.
33
  model: generative model to use.
34
  prompt: input prompt.
35
  msg: message to hide in the text.
 
36
  delta: bias add to scores of token in valid list.
37
  msg_base: base of the message.
38
  seed_scheme: scheme used to compute the seed.
39
  window_length: length of window to compute the seed.
40
  salt_key: salt to add to the seed.
41
  private_key: private key used to compute the seed.
 
 
 
 
 
 
 
 
42
  """
43
  if len(start_pos_p) == 1:
44
  start_pos = start_pos_p[0]
@@ -134,6 +143,8 @@ def decrypt(
134
  window_length: length of window to compute the seed.
135
  salt_key: salt to add to the seed.
136
  private_key: private key used to compute the seed.
 
 
137
  """
138
  tokenized_input = tokenizer(text, return_tensors="pt").to(device)
139
 
 
26
  generator: torch.Generator | None = None,
27
  ):
28
  """
29
+ Generate the sequence containing the hidden data. This supports batch input/output.
30
 
31
  Args:
32
  tokenizer: tokenizer to use.
33
  model: generative model to use.
34
  prompt: input prompt.
35
  msg: message to hide in the text.
36
+ start_pos_p: start position to hide message.
37
  delta: bias add to scores of token in valid list.
38
  msg_base: base of the message.
39
  seed_scheme: scheme used to compute the seed.
40
  window_length: length of window to compute the seed.
41
  salt_key: salt to add to the seed.
42
  private_key: private key used to compute the seed.
43
+ min_new_tokens_ratio: ratio between min generated tokens and required token length.
44
+ min_new_tokens_ratio: ratio between max generated tokens and required token length.
45
+ do_sample: whether to do sampling or greedy generation.
46
+ num_beams: number of beams used in beam search.
47
+ repetition_penalty: penalty to avoid repetitiveness.
48
+ generator: generation used to genereate. This is mainly used to produce deterministic results.
49
+ Returns:
50
+ generated texts, hidden message rates, tokens information
51
  """
52
  if len(start_pos_p) == 1:
53
  start_pos = start_pos_p[0]
 
143
  window_length: length of window to compute the seed.
144
  salt_key: salt to add to the seed.
145
  private_key: private key used to compute the seed.
146
+ Returns:
147
+ shifted versions of the message
148
  """
149
  tokenized_input = tokenizer(text, return_tensors="pt").to(device)
150