Replicate
Most popular AI cloud service
Introduction
- Run models in the cloud at scale
- Replicate allows running ML models with minimal coding, without deep understanding of ML.
curl -s -X POST \
-d '{"version": "db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", \
"input": { "prompt": "an astronaut riding on a horse" } }' \
-H "Authorization: Token $REPLICATE_API_TOKEN" \
-H 'Content-Type: application/json' \
https://api.replicate.com/v1/predictions- It has thousands of ready-to-use models shared by its community.
- Push: Package ML models easily
- Cog, an open-source tool by Replicate, packages ML models into production-ready containers
- only 4 steps to push your model into cloud
- define the environment your model runs in with
cog.yaml
- define the environment your model runs in with
build:
gpu: true
system_packages:
- "libgl1-mesa-glx"
- "libglib2.0-0"
python_version: "3.10"
python_packages:
- "torch==1.13.1"
predict: "predict.py:Predictor"- define how predictions are run on your model with
predict.py
from cog import BasePredictor, Input, Path
import torch
class Predictor(BasePredictor):
def setup(self):
"""Load the model into memory to make running multiple predictions efficient"""
self.model = torch.load("./weights.pth")
# The arguments and types the model takes as input
def predict(self,
image: Path = Input(description="Grayscale input image")
) -> Path:
"""Run a single prediction on the model"""
processed_image = preprocess(image)
output = self.model(processed_image)
return postprocess(output)- then you can run predictions on this model locally
cog predict -i @input.jpg - Finally, push your model to Replicate, and you can run it in the cloud with a few lines of code
cog push- Scale: Deploy ML models at scale
- scaling is 100% your choice
- Automatic scale
- Automatic API
- Pay by second billing system