Spaces:
Runtime error
Runtime error
import requests | |
import random | |
import time | |
def func2(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 |