papayaga's picture
demo
a8467fc
raw
history blame contribute delete
No virus
487 Bytes
import requests
import json
import os
from pprint import pprint
HF_TOKEN = os.getenv("HF_TOKEN")
API_URL = "https://api-inference.huggingface.co/models/rizvandwiki/gender-classification-2"
headers = {"Authorization": "Bearer "+HF_TOKEN}
def get_gender(filename):
with open(filename, "rb") as f:
data = f.read()
response = requests.post(API_URL, headers=headers, data=data)
gender_prediction = response.json()
return gender_prediction[0]['label']