Skip to content

Commit eb48eee

Browse files
committed
bug fix
1 parent 7cbe9c9 commit eb48eee

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

app.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
app.config['MAX_CONTENT_LENGTH'] = MAX_CONTENT_LENGTH
3131

3232

33-
logging.basicConfig(filename="logfile.log", level=logging.INFO)
34-
logging.info("APP: APP started at " + str(datetime.datetime.now()))
35-
print("logging configured")
33+
# logging.basicConfig(filename="logfile.log", level=logging.INFO)
34+
# logging.info("APP: APP started at " + str(datetime.datetime.now()))
35+
# print("logging configured")
3636

3737

3838
# API-Connection Test

debiasing/debiasing_controller.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import logging
2+
3+
import numpy as np
4+
25
import augmentation_retrieval
36
import calculation
47
import json_controller
@@ -8,7 +11,6 @@
811

912
def debiasing(methods, content, bar):
1013
logging.info("Debiasing-Engine: Started")
11-
1214
# bar params: lower, uploaded, pca, space
1315
if content is None:
1416
return 'BAD REQUEST - NO BIAS SPEC JSON FOUND', 400
@@ -21,6 +23,7 @@ def debiasing(methods, content, bar):
2123
lex = 'false'
2224
if 'space' in bar:
2325
space = bar['space']
26+
print(space)
2427
if 'uploaded' in bar:
2528
uploaded = bar['uploaded']
2629
if 'lower' in bar:
@@ -32,23 +35,19 @@ def debiasing(methods, content, bar):
3235
t1_list, t2_list, a1_list, a2_list, aug1_list, aug2_list = json_controller.json_to_debias_spec(content)
3336
if len(aug1_list) == 0:
3437
aug1_list, computed = augmentation_retrieval.retrieve_multiple_augmentations(t1_list)
35-
print("here")
3638
if len(aug2_list) == 0:
3739
aug2_list, computed = augmentation_retrieval.retrieve_multiple_augmentations(t2_list)
38-
print("here")
3940
if lower == 'true':
4041
t1_list = [x.lower() for x in t1_list]
4142
t2_list = [x.lower() for x in t2_list]
4243
a1_list = [x.lower() for x in a1_list]
4344
a2_list = [x.lower() for x in a2_list]
4445
aug1_list = [x.lower() for x in aug1_list]
4546
aug2_list = [x.lower() for x in aug2_list]
46-
print(aug1_list)
47-
print(aug2_list)
4847
equality_sets = []
49-
for i in range(len(aug1_list)):
50-
for j in range(len(aug2_list)):
51-
equality_sets.append([aug1_list[i], aug2_list[j]])
48+
for t1 in aug1_list:
49+
for t2 in aug2_list:
50+
equality_sets.append((t1, t2))
5251

5352
t1, t2, a1, a2, aug1, aug2, not_found, deleted = specification_controller. \
5453
get_vectors_for_spec(space, lower, uploaded, t1_list, t2_list, a1_list, a2_list, aug1_list, aug2_list)
@@ -59,9 +58,8 @@ def debiasing(methods, content, bar):
5958
else:
6059
vocab, vecs = calculation.create_vocab_and_vecs(t1, t2, a1, a2, aug1, aug2)
6160

62-
t1_deb, t2_deb, a1_deb, a2_deb, new_vecs= [], [], [], [], []
61+
t1_deb, t2_deb, a1_deb, a2_deb, new_vecs = [], [], [], [], []
6362
# print("Debiasing-Engine: Specs loaded, starting computing")
64-
6563
if methods == 'bam':
6664
t1_deb, t2_deb, a1_deb, a2_deb, new_vecs = debiasing_bam(equality_sets, vocab, vecs, t1_list, t2_list, a1_list,
6765
a2_list)

debiasing/gbdd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def get_bias_direction(equality_sets, vecs, vocab):
77
logging.info("Debi-Engine: GBDD Debiasing started")
88
dir_vecs = []
99
vecs_norm = vecs / np.transpose([np.linalg.norm(vecs, 2, 1)])
10+
print(vocab)
1011
for eq in equality_sets:
1112
if eq[0] in vocab and eq[1] in vocab:
1213
dir_vecs.append(vecs_norm[vocab[eq[0]]] - vecs_norm[vocab[eq[1]]])
1314
q = np.array(dir_vecs)
1415
u, sigma, v = np.linalg.svd(q)
15-
1616
v_b = v[0]
1717
return v_b
1818

specification_controller.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ def get_vectors_for_spec(space, lower, uploaded, t1, t2, a1, a2, aug1=None, aug2
102102
a1, a2, a_del = format_set_sizes(a1_found, a2_found)
103103
deleted_keys = t_del + a_del
104104
if aug1 is not None and aug2 is not None:
105-
aug1, aug2, aug_del = format_set_sizes(aug1_found, aug2_found)
106-
deleted_keys += aug_del
105+
# aug1, aug2, aug_del = format_set_sizes(aug1_found, aug2_found)
106+
# deleted_keys += aug_del
107+
aug1 = aug1_found
108+
aug2 = aug2_found
107109
logging.info("SpecController: Returning found vectors")
108110
logging.info("SpecController: NotFound: " + str(not_found) + " ; DeletedKeys: " + str(deleted_keys))
109111
return t1, t2, a1, a2, aug1, aug2, not_found, deleted_keys

0 commit comments

Comments
 (0)