Skip to content

Commit 1fdff82

Browse files
zekebfirsh
authored andcommitted
update cog init predictor template
Signed-off-by: Zeke Sikelianos <[email protected]>
1 parent b212209 commit 1fdff82

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

pkg/cli/init-templates/predict.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Prediction interface for Cog ⚙️
2-
# Reference: https://github.com/replicate/cog/blob/main/docs/python.md
2+
# https://github.com/replicate/cog/blob/main/docs/python.md
33

4-
import cog
5-
# import torch
4+
from cog import BasePredictor, Input, Path
65

7-
class Predictor(cog.Predictor):
6+
7+
class Predictor(BasePredictor):
88
def setup(self):
9-
"""Load the model into memory to make running multiple predictions efficient"""
10-
# self.model = torch.load("./weights.pth")
9+
"""Load the model into memory to make running multiple predictions efficient"""
10+
# self.model = torch.load("./weights.pth")
1111

12-
@cog.input("image", type=cog.Path, help="Grayscale input image")
13-
@cog.input("scale", type=float, default=1.5, help="Factor to scale image by")
14-
def predict(self, image):
12+
def predict(
13+
self,
14+
input: Path = Input(title="Grayscale input image"),
15+
scale: float = Input(
16+
title="Factor to scale image by", gt=0, lt=10, default=1.5
17+
),
18+
) -> Path:
1519
"""Run a single prediction on the model"""
16-
# processed_input = preprocess(image)
17-
# output = self.model(processed_input)
18-
# return post_processing(output)
20+
# processed_input = preprocess(input)
21+
# output = self.model(processed_input, scale)
22+
# return postprocess(output)

0 commit comments

Comments
 (0)