Spaces:
Runtime error
Runtime error
Download PyPatchMatch/examples/py_example_global_mask.py from lnyan/stablediffusion-infinity: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/lnyan/stablediffusion-infinity/resolve/refs%2Fpr%2F6/PyPatchMatch/examples/py_example_global_mask.py
- Command line
-
hf download hf://spaces/lnyan/stablediffusion-infinity@refs/pr/6/PyPatchMatch/examples/py_example_global_mask.py
-
curl -L -o py_example_global_mask.py https://huggingface.co/spaces/lnyan/stablediffusion-infinity/resolve/refs%2Fpr%2F6/PyPatchMatch/examples/py_example_global_mask.py
721 Bytes
| #! /usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| # File : test.py | |
| # Author : Jiayuan Mao | |
| # Email : maojiayuan@gmail.com | |
| # Date : 01/09/2020 | |
| # | |
| # Distributed under terms of the MIT license. | |
| import numpy as np | |
| from PIL import Image | |
| import sys | |
| sys.path.insert(0, '../') | |
| import patch_match | |
| if __name__ == '__main__': | |
| patch_match.set_verbose(True) | |
| source = Image.open('./images/forest_pruned.bmp') | |
| source = np.array(source) | |
| source[:100, :100] = 255 | |
| global_mask = np.zeros_like(source[..., 0]) | |
| global_mask[:100, :100] = 1 | |
| result = patch_match.inpaint(source, global_mask=global_mask, patch_size=3) | |
| Image.fromarray(result).save('./images/forest_recovered.bmp') | |