Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,24 @@ import gradio as gr
|
|
4 |
def debias(gendered_word1,gendered_word2,occupation,model):
|
5 |
return 'test','test','test'
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
demo = gr.Interface(
|
8 |
debias,
|
9 |
inputs = [
|
@@ -17,6 +35,6 @@ demo = gr.Interface(
|
|
17 |
description = '<a href="https://arxiv.org/abs/2103.00453">Self-Diagnosis and Self-Debiasing: A Proposal for Reducing Corpus-Based Bias in NLP</a>'
|
18 |
)
|
19 |
if __name__ == '__main__':
|
20 |
-
urllib.request.urlretrieve("https://cdn-lfs.huggingface.co/repos/51/d0/51d02f0735de2187e78af7db593c8d71efbcddfe9f5e45cfa1c77904daf0dfdf/20dac974c73413d4b4f463f9b28eabfb326793d2732c108a9cd1262f2a055dc3?response-content-disposition=attachment%3B%20filename%3D%22glove_debiased_300d.txt%22", "
|
|
|
21 |
demo.launch()
|
22 |
-
|
|
|
4 |
def debias(gendered_word1,gendered_word2,occupation,model):
|
5 |
return 'test','test','test'
|
6 |
|
7 |
+
def load_glove(path):
|
8 |
+
with open(path) as f:
|
9 |
+
lines = f.readlines()
|
10 |
+
|
11 |
+
wv = []
|
12 |
+
vocab = []
|
13 |
+
for line in lines:
|
14 |
+
|
15 |
+
tokens = line.strip().split(" ")
|
16 |
+
assert len(tokens) == 301
|
17 |
+
vocab.append(tokens[0])
|
18 |
+
wv.append([float(elem) for elem in tokens[1:]])
|
19 |
+
w2i = {w: i for i, w in enumerate(vocab)}
|
20 |
+
wv = np.array(wv).astype(float)
|
21 |
+
print(len(vocab), wv.shape, len(w2i))
|
22 |
+
|
23 |
+
return wv, w2i, vocab
|
24 |
+
|
25 |
demo = gr.Interface(
|
26 |
debias,
|
27 |
inputs = [
|
|
|
35 |
description = '<a href="https://arxiv.org/abs/2103.00453">Self-Diagnosis and Self-Debiasing: A Proposal for Reducing Corpus-Based Bias in NLP</a>'
|
36 |
)
|
37 |
if __name__ == '__main__':
|
38 |
+
urllib.request.urlretrieve("https://cdn-lfs.huggingface.co/repos/51/d0/51d02f0735de2187e78af7db593c8d71efbcddfe9f5e45cfa1c77904daf0dfdf/20dac974c73413d4b4f463f9b28eabfb326793d2732c108a9cd1262f2a055dc3?response-content-disposition=attachment%3B%20filename%3D%22glove_debiased_300d.txt%22", "glove_debiased_300d.txt")
|
39 |
+
wv, w2i, vocab = load_glove('glove_debiased_300d.txt')
|
40 |
demo.launch()
|
|