Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (45 loc) · 2.44 KB
/
Copy pathMakefile
File metadata and controls
56 lines (45 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include config.py
all: create_adv_attacks generate_images
gpu_1: generate_images_1
gpu_2: generate_images_2
metrics: save_to_wandb
ATTACK_NAMES = "naive_char" "char" "delete_char" "duplicate_char" "typo_char" "homoglyphs_char" "synonym_word" "homophone_word" "homophone_word_2"
ATTACK_NAMES_1 = "naive_char" "char" "delete_char" "duplicate_char"
ATTACK_NAMES_2 = "typo_char" "homoglyphs_char" "synonym_word" "homophone_word" "homophone_word_2"
clean:
@echo "Deleting image_outputs and permutations folder"
rm -r image_outputs || true
rm -r permutations || true
rm -r image_captions || true
rm -r logs || true
mkdir -p logs
create_adv_attacks:
@echo "Creating permutation files"
mkdir -p permutations
python3 prompt_permutation.py 2> ./logs/prompt_log.txt
generate_images:
@echo "Generate images for the original and permutation prompts"
python3 generate_images.py -f permutations/original_prompts.txt -o ./image_outputs/original_images -t $(hf_acc_token) 2>> ./logs/image_log.txt
python3 generate_images.py -f permutations/original_prompts.txt -o ./image_outputs/original_control_images -t $(hf_acc_token) -s 1 2>> ./logs/image_log.txt
for i in $(ATTACK_NAMES); do \
echo $$i | xargs -I '{}' python3 generate_images.py -f permutations/'{}'_prompts.txt -o ./image_outputs/'{}'_images -t $(hf_acc_token) 2>> ./logs/image_log.txt ;\
done
generate_images_1:
@echo "Generate images for the original prompts and attacks 1 - 4"
python3 generate_images.py -f permutations/original_prompts.txt -o ./image_outputs/original_images -t $(hf_acc_token) 2>> ./logs/image_1_log.txt
python3 generate_images.py -f permutations/original_prompts.txt -o ./image_outputs/original_control_images -t $(hf_acc_token) -s 1 2>> ./logs/image_1_log.txt
for i in $(ATTACK_NAMES_1); do \
echo $$i | xargs -I '{}' python3 generate_images.py -f permutations/'{}'_prompts.txt -o ./image_outputs/'{}'_images -t $(hf_acc_token) 2>> ./logs/image_1_log.txt ;\
done
generate_images_2:
@echo "Generate images for attacks 5 - 9"
for i in $(ATTACK_NAMES_2); do \
echo $$i | xargs -I '{}' python3 generate_images.py -f permutations/'{}'_prompts.txt -o ./image_outputs/'{}'_images -t $(hf_acc_token) 2>> ./logs/image_2_log.txt ;\
done
save_to_wandb:
@echo "Save images to wandb"
python3 apply_metrics_on_images.py 2> ./logs/metrics_log.txt
captions:
@echo "Create image captions with BLIP-2"
mkdir -p image_captions
python3 create_image_captions.py 2> ./logs/captions_log.txt