Created
May 12, 2022 20:44
-
-
Save zeke/5583ff3fa738c76312f69df6ef704fcc to your computer and use it in GitHub Desktop.
A contrived example of a Cog predictor that produces multiple outputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/replicate/cog/blob/main/docs/python.md#output | |
from cog import BasePredictor, BaseModel, File | |
class Output(BaseModel): | |
image: File | |
coords: str | |
class Predictor(BasePredictor): | |
def predict(self, source_image: Path = Input(description="Image in which to detect objects")) -> Path: | |
raw_coords = my_detector(source_image) | |
coords = json.dumps(raw_coords, indent=2) | |
image = Path(tempfile.mkdtemp()) / "demo.png" | |
return Output(coords=coords, image=image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment