Spaces:
Runtime error
Runtime error
Download PyPatchMatch/examples/cpp_example.cpp from lnyan/stablediffusion-infinity: direct link, hf CLI and curl.
- Browser
- Download file 946 Bytes
-
https://huggingface.co/spaces/lnyan/stablediffusion-infinity/resolve/refs%2Fpr%2F6/PyPatchMatch/examples/cpp_example.cpp
- Command line
-
hf download hf://spaces/lnyan/stablediffusion-infinity@refs/pr/6/PyPatchMatch/examples/cpp_example.cpp
-
curl -L -o cpp_example.cpp https://huggingface.co/spaces/lnyan/stablediffusion-infinity/resolve/refs%2Fpr%2F6/PyPatchMatch/examples/cpp_example.cpp
946 Bytes
| int main() { | |
| auto source = cv::imread("./images/forest_pruned.bmp", cv::IMREAD_COLOR); | |
| auto mask = cv::Mat(source.size(), CV_8UC1); | |
| mask = cv::Scalar::all(0); | |
| for (int i = 0; i < source.size().height; ++i) { | |
| for (int j = 0; j < source.size().width; ++j) { | |
| auto source_ptr = source.ptr<unsigned char>(i, j); | |
| if (source_ptr[0] == 255 && source_ptr[1] == 255 && source_ptr[2] == 255) { | |
| mask.at<unsigned char>(i, j) = 1; | |
| } | |
| } | |
| } | |
| auto metric = PatchSSDDistanceMetric(3); | |
| auto result = Inpainting(source, mask, &metric).run(true, true); | |
| // cv::imwrite("./images/forest_recovered.bmp", result); | |
| // cv::imshow("Result", result); | |
| // cv::waitKey(); | |
| return 0; | |
| } | |