JRQi's picture
Duplicate from GroNLP/LM-Explanation-Demo
4ba4a77
raw
history blame
555 Bytes
import requests
import random
import time
def func3(text):
filter = False
API_URL = "https://api-inference.huggingface.co/models/Abderrahim2/bert-finetuned-gender_classification"
headers = {"Authorization": "Bearer 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"}
response = requests.post(API_URL, headers=headers, json=text)
output = response.json()
result = dict()
for out in output[0]:
label = out['label']
if label == 'undefined' and filter: continue
result[label] = out['score']
return result