Skip to content

Commit

Permalink
simple blur model
Browse files Browse the repository at this point in the history
  • Loading branch information
kharioki committed Jun 19, 2023
0 parents commit ba02c8c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
output.png
.cog
__pycache__
.DS_Store
31 changes: 31 additions & 0 deletions cog.yaml
@@ -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"
22 changes: 22 additions & 0 deletions predict.py
@@ -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
Binary file added samples/house.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ba02c8c

Please sign in to comment.