Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from transformers import pipeline | |
app = FastAPI(docs_url="/") | |
def calculate_human_years_endpoint(weight: int, dogyears: int): | |
size_to_years = { | |
"Less than 20": { | |
1: 15, 2: 24, 3: 28, 4: 32, 5: 36, 6: 40, | |
7: 44, 8: 48, 9: 52, 10: 56, 11: 60, 12: 64 | |
}, | |
"20 to 50": { | |
1: 15, 2: 24, 3: 28, 4: 32, 5: 36, 6: 42, | |
7: 47, 8: 51, 9: 56, 10: 60, 11: 65, 12: 69 | |
}, | |
"50 to 100": { | |
1: 15, 2: 24, 3: 28, 4: 32, 5: 36, 6: 45, | |
7: 50, 8: 55, 9: 61, 10: 66, 11: 72, 12: 77 | |
}, | |
"Above 100": { | |
1: 15, 2: 22, 3: 28, 4: 31, 5: 36, 6: 45, | |
7: 49, 8: 55, 9: 61, 10: 66, 11: 72, 12: 77 | |
} | |
} | |
if weight < 20: | |
category = "Less than 20" | |
elif 20 <= weight <= 50: | |
category = "20 to 50" | |
elif 50 < weight <= 100: | |
category = "50 to 100" | |
else: | |
category = "Above 100" | |
if dogyears in size_to_years[category]: | |
return size_to_years[category][dogyears] | |
else: | |
return 0 | |