Skip to content

Instantly share code, notes, and snippets.

@caleb-kaiser
Created December 11, 2020 16:41
import cortex
class PythonPredictor:
def __init__(self, config):
self.model = # Download model from any source (can also be configured in API spec).
def predict(self, payload):
return self.model(payload["input"])
requirements = ["torch"] # Add any requirements
api_spec = {"name": "example_api", "kind": "RealtimeAPI"} # Configure API specifics
cx = cortex.client("local")
cx.create_api(api_spec, predictor=PythonPredictor, requirements=requirements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment