Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ba02c8c
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output.png | ||
.cog | ||
__pycache__ | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Configuration for Cog ⚙️ | ||
# Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md | ||
|
||
build: | ||
# set to true if your model requires a GPU | ||
gpu: false | ||
|
||
# a list of ubuntu apt packages to install | ||
system_packages: | ||
- "libpng-dev" | ||
- "libjpeg-dev" | ||
# - "libgl1-mesa-glx" | ||
# - "libglib2.0-0" | ||
|
||
# python version in the form '3.8' or '3.8.12' | ||
python_version: "3.8" | ||
|
||
# a list of packages in the format <package-name>==<version> | ||
python_packages: | ||
- "pillow==8.2.0" | ||
# - "numpy==1.19.4" | ||
# - "torch==1.8.0" | ||
# - "torchvision==0.9.0" | ||
|
||
# commands run after the environment is setup | ||
# run: | ||
# - "echo env is ready!" | ||
# - "echo another command if needed" | ||
|
||
# predict.py defines how predictions are run on your model | ||
predict: "predict.py:Predictor" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Prediction interface for Cog ⚙️ | ||
# https://github.com/replicate/cog/blob/main/docs/python.md | ||
|
||
import tempfile | ||
|
||
from cog import BasePredictor, Input, Path | ||
from PIL import Image, ImageFilter | ||
|
||
|
||
class Predictor(BasePredictor): | ||
def predict( | ||
self, | ||
image: Path = Input(description="Input image"), | ||
blur: float = Input(description="Blur radius", default=5), | ||
) -> Path: | ||
if blur == 0: | ||
return input | ||
im = Image.open(str(image)) | ||
im = im.filter(ImageFilter.BoxBlur(blur)) | ||
out_path = Path(tempfile.mkdtemp()) / "out.png" | ||
im.save(str(out_path)) | ||
return out_path |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.