Spaces:
Sleeping
Sleeping
File size: 822 Bytes
b51f064 70c8769 b51f064 70c8769 b51f064 70c8769 b51f064 70c8769 b51f064 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from classification.classifier import Classifier
import json
cls = Classifier()
# Lambda handler (proxy integration option unchecked on AWS API Gateway)
def lambda_handler(event, context):
try:
features = event.get('features', {})
if not features:
raise ValueError("'features' key missing")
response = cls.load_and_test(features)
return {
'statusCode': 200,
'headers': {
'Content-Type': 'application/json'
},
'body': json.dumps({
'predictions': response["predictions"],
'probabilities': response["probabilities"]
})
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps({'error': str(e)})
}
|