diff --git a/blur/cog.yaml b/blur/cog.yaml index 4eeb3fb..38de2f9 100644 --- a/blur/cog.yaml +++ b/blur/cog.yaml @@ -1,18 +1,8 @@ -model: cog_predict.py:Model -examples: - - input: - image: "@examples/lena.png" - blur: 0 - output: "@examples/lena.png" - - input: - image: "@examples/lena.png" - blur: 2.0 - output: "@examples/lena-blur.png" -environment: +build: + python_version: "3.8" python_packages: - - pillow==8.2.0 + - "pillow==8.2.0" system_packages: - - libpng-dev - - libjpeg-dev - architectures: - - cpu + - "libpng-dev" + - "libjpeg-dev" +predict: "predict.py:Predictor" diff --git a/blur/cog_predict.py b/blur/predict.py similarity index 55% rename from blur/cog_predict.py rename to blur/predict.py index 0354b76..6640659 100644 --- a/blur/cog_predict.py +++ b/blur/predict.py @@ -5,16 +5,16 @@ import cog -class Model(cog.Model): +class Predictor(cog.Predictor): def setup(self): pass - @cog.input("image", type=Path, help="Input image") - @cog.input("blur", type=float, help="Blur radius") - def predict(self, image, blur): + @cog.input("input", type=Path, help="Input image") + @cog.input("blur", type=float, help="Blur radius", default=5) + def predict(self, input, blur): if blur == 0: - return image - im = Image.open(str(image)) + return input + im = Image.open(str(input)) im = im.filter(ImageFilter.BoxBlur(blur)) out_path = Path(tempfile.mkdtemp()) / "out.png" im.save(str(out_path)) diff --git a/hello-world/cog.yaml b/hello-world/cog.yaml index 829aa12..ce62284 100644 --- a/hello-world/cog.yaml +++ b/hello-world/cog.yaml @@ -1,11 +1,3 @@ -model: cog_predict.py:Model -examples: - - input: - text: "foo" - output: "hello foo" - - input: - text: "bar" - output: "hello bar" -environment: - architectures: - - cpu +build: + python_version: "3.8" +predict: "predict.py:Predictor" diff --git a/hello-world/cog_predict.py b/hello-world/cog_predict.py deleted file mode 100644 index 0c6f997..0000000 --- a/hello-world/cog_predict.py +++ /dev/null @@ -1,10 +0,0 @@ -import cog - - -class Model(cog.Model): - def setup(self): - self.prefix = "hello" - - @cog.input("text", type=str, help="Text that will get prefixed by 'hello '") - def predict(self, text): - return self.prefix + " " + text diff --git a/hello-world/predict.py b/hello-world/predict.py new file mode 100644 index 0000000..447081d --- /dev/null +++ b/hello-world/predict.py @@ -0,0 +1,10 @@ +import cog + + +class Predictor(cog.Predictor): + def setup(self): + self.prefix = "hello" + + @cog.input("input", type=str, help="Text that will get prefixed by 'hello '") + def predict(self, input): + return self.prefix + " " + input