diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..7db6dcf23696008a74af8cafcfd3d9d3595172aa --- /dev/null +++ b/.gitattributes @@ -0,0 +1,39 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +**.png filter=lfs diff=lfs merge=lfs -text +**.gif filter=lfs diff=lfs merge=lfs -text +**.jpg filter=lfs diff=lfs merge=lfs -text +third_party/** filter=lfs diff=lfs merge=lfs -text +pretrained_models/** filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..90f1a173d15a2fea3232452ad26d0567a7db889a --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# Python byte code, etc. +__pycache__/ + +# C/C++ object files/libraries +*.o +*.so + +# macOS +**/.DS_Store + +# tmp +~* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d9e84fb131f23cbfd12091f4b26cba2b6370379f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +--- +title: Inpaint Anything +emoji: ⚡ +colorFrom: red +colorTo: red +sdk: gradio +sdk_version: 3.27.0 +app_file: app.py +pinned: false +license: apache-2.0 +duplicated_from: InpaintAI/Inpaint-Anything +--- + +Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..2463f20871ad057325389168043efe13e4599025 --- /dev/null +++ b/app.py @@ -0,0 +1,231 @@ +import os +import sys +# sys.path.append(os.path.abspath(os.path.dirname(os.getcwd()))) +# os.chdir("../") +import gradio as gr +import numpy as np +from pathlib import Path +from matplotlib import pyplot as plt +import torch +import tempfile +from lama_inpaint import inpaint_img_with_lama, build_lama_model, inpaint_img_with_builded_lama +from utils import load_img_to_array, save_array_to_img, dilate_mask, \ + show_mask, show_points +from PIL import Image +sys.path.insert(0, str(Path(__file__).resolve().parent / "third_party" / "segment-anything")) +from segment_anything import SamPredictor, sam_model_registry +import argparse + +def setup_args(parser): + parser.add_argument( + "--lama_config", type=str, + default="./third_party/lama/configs/prediction/default.yaml", + help="The path to the config file of lama model. " + "Default: the config of big-lama", + ) + parser.add_argument( + "--lama_ckpt", type=str, + default="pretrained_models/big-lama", + help="The path to the lama checkpoint.", + ) + parser.add_argument( + "--sam_ckpt", type=str, + default="./pretrained_models/sam_vit_h_4b8939.pth", + help="The path to the SAM checkpoint to use for mask generation.", + ) +def mkstemp(suffix, dir=None): + fd, path = tempfile.mkstemp(suffix=f"{suffix}", dir=dir) + os.close(fd) + return Path(path) + + +def get_sam_feat(img): + model['sam'].set_image(img) + features = model['sam'].features + orig_h = model['sam'].orig_h + orig_w = model['sam'].orig_w + input_h = model['sam'].input_h + input_w = model['sam'].input_w + model['sam'].reset_image() + return features, orig_h, orig_w, input_h, input_w + + +def get_masked_img(img, w, h, features, orig_h, orig_w, input_h, input_w, dilate_kernel_size): + point_coords = [w, h] + point_labels = [1] + + model['sam'].is_image_set = True + model['sam'].features = features + model['sam'].orig_h = orig_h + model['sam'].orig_w = orig_w + model['sam'].input_h = input_h + model['sam'].input_w = input_w + + # model['sam'].set_image(img) # todo : update here for accelerating + masks, _, _ = model['sam'].predict( + point_coords=np.array([point_coords]), + point_labels=np.array(point_labels), + multimask_output=True, + ) + + masks = masks.astype(np.uint8) * 255 + + # dilate mask to avoid unmasked edge effect + if dilate_kernel_size is not None: + masks = [dilate_mask(mask, dilate_kernel_size) for mask in masks] + else: + masks = [mask for mask in masks] + + figs = [] + for idx, mask in enumerate(masks): + # save the pointed and masked image + tmp_p = mkstemp(".png") + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + fig = plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_points(plt.gca(), [point_coords], point_labels, + size=(width*0.04)**2) + show_mask(plt.gca(), mask, random_color=False) + plt.tight_layout() + plt.savefig(tmp_p, bbox_inches='tight', pad_inches=0) + figs.append(fig) + plt.close() + return *figs, *masks + + +def get_inpainted_img(img, mask0, mask1, mask2): + lama_config = args.lama_config + device = "cuda" if torch.cuda.is_available() else "cpu" + out = [] + for mask in [mask0, mask1, mask2]: + if len(mask.shape)==3: + mask = mask[:,:,0] + img_inpainted = inpaint_img_with_builded_lama( + model['lama'], img, mask, lama_config, device=device) + out.append(img_inpainted) + return out + + +# get args +parser = argparse.ArgumentParser() +setup_args(parser) +args = parser.parse_args(sys.argv[1:]) +# build models +model = {} +# build the sam model +model_type="vit_h" +ckpt_p=args.sam_ckpt +model_sam = sam_model_registry[model_type](checkpoint=ckpt_p) +device = "cuda" if torch.cuda.is_available() else "cpu" +model_sam.to(device=device) +model['sam'] = SamPredictor(model_sam) + +# build the lama model +lama_config = args.lama_config +lama_ckpt = args.lama_ckpt +device = "cuda" if torch.cuda.is_available() else "cpu" +model['lama'] = build_lama_model(lama_config, lama_ckpt, device=device) + +button_size = (100,50) +with gr.Blocks() as demo: + features = gr.State(None) + orig_h = gr.State(None) + orig_w = gr.State(None) + input_h = gr.State(None) + input_w = gr.State(None) + + with gr.Row().style(mobile_collapse=False, equal_height=True): + with gr.Column(variant="panel"): + with gr.Row(): + gr.Markdown("## Input Image") + with gr.Row(): + img = gr.Image(label="Input Image").style(height="200px") + with gr.Column(variant="panel"): + with gr.Row(): + gr.Markdown("## Pointed Image") + with gr.Row(): + img_pointed = gr.Plot(label='Pointed Image') + with gr.Column(variant="panel"): + with gr.Row(): + gr.Markdown("## Control Panel") + with gr.Row(): + w = gr.Number(label="Point Coordinate W") + h = gr.Number(label="Point Coordinate H") + dilate_kernel_size = gr.Slider(label="Dilate Kernel Size", minimum=0, maximum=100, step=1, value=15) + sam_mask = gr.Button("Predict Mask", variant="primary").style(full_width=True, size="sm") + lama = gr.Button("Inpaint Image", variant="primary").style(full_width=True, size="sm") + clear_button_image = gr.Button(value="Reset", label="Reset", variant="secondary").style(full_width=True, size="sm") + + # todo: maybe we can delete this row, for it's unnecessary to show the original mask for customers + with gr.Row(variant="panel"): + with gr.Column(): + with gr.Row(): + gr.Markdown("## Segmentation Mask") + with gr.Row(): + mask_0 = gr.outputs.Image(type="numpy", label="Segmentation Mask 0").style(height="200px") + mask_1 = gr.outputs.Image(type="numpy", label="Segmentation Mask 1").style(height="200px") + mask_2 = gr.outputs.Image(type="numpy", label="Segmentation Mask 2").style(height="200px") + + with gr.Row(variant="panel"): + with gr.Column(): + with gr.Row(): + gr.Markdown("## Image with Mask") + with gr.Row(): + img_with_mask_0 = gr.Plot(label="Image with Segmentation Mask 0") + img_with_mask_1 = gr.Plot(label="Image with Segmentation Mask 1") + img_with_mask_2 = gr.Plot(label="Image with Segmentation Mask 2") + + with gr.Row(variant="panel"): + with gr.Column(): + with gr.Row(): + gr.Markdown("## Image Removed with Mask") + with gr.Row(): + img_rm_with_mask_0 = gr.outputs.Image( + type="numpy", label="Image Removed with Segmentation Mask 0").style(height="200px") + img_rm_with_mask_1 = gr.outputs.Image( + type="numpy", label="Image Removed with Segmentation Mask 1").style(height="200px") + img_rm_with_mask_2 = gr.outputs.Image( + type="numpy", label="Image Removed with Segmentation Mask 2").style(height="200px") + + + def get_select_coords(img, evt: gr.SelectData): + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + fig = plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + plt.tight_layout() + show_points(plt.gca(), [[evt.index[0], evt.index[1]]], [1], + size=(width*0.04)**2) + return evt.index[0], evt.index[1], fig + + img.select(get_select_coords, [img], [w, h, img_pointed]) + img.upload(get_sam_feat, [img], [features, orig_h, orig_w, input_h, input_w]) + + sam_mask.click( + get_masked_img, + [img, w, h, features, orig_h, orig_w, input_h, input_w, dilate_kernel_size], + [img_with_mask_0, img_with_mask_1, img_with_mask_2, mask_0, mask_1, mask_2] + ) + + lama.click( + get_inpainted_img, + [img, mask_0, mask_1, mask_2], + [img_rm_with_mask_0, img_rm_with_mask_1, img_rm_with_mask_2] + ) + + + def reset(*args): + return [None for _ in args] + + clear_button_image.click( + reset, + [img, features, img_pointed, w, h, mask_0, mask_1, mask_2, img_with_mask_0, img_with_mask_1, img_with_mask_2, img_rm_with_mask_0, img_rm_with_mask_1, img_rm_with_mask_2], + [img, features, img_pointed, w, h, mask_0, mask_1, mask_2, img_with_mask_0, img_with_mask_1, img_with_mask_2, img_rm_with_mask_0, img_rm_with_mask_1, img_rm_with_mask_2] + ) + +if __name__ == "__main__": + demo.launch() + \ No newline at end of file diff --git a/fill_anything.py b/fill_anything.py new file mode 100644 index 0000000000000000000000000000000000000000..cc601fb87931cc02a7d81c4f698438d5ece4d85b --- /dev/null +++ b/fill_anything.py @@ -0,0 +1,128 @@ +import cv2 +import sys +import argparse +import numpy as np +import torch +from pathlib import Path +from matplotlib import pyplot as plt +from typing import Any, Dict, List + +from sam_segment import predict_masks_with_sam +from stable_diffusion_inpaint import fill_img_with_sd +from utils import load_img_to_array, save_array_to_img, dilate_mask, \ + show_mask, show_points + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--point_coords", type=float, nargs='+', required=True, + help="The coordinate of the point prompt, [coord_W coord_H].", + ) + parser.add_argument( + "--point_labels", type=int, nargs='+', required=True, + help="The labels of the point prompt, 1 or 0.", + ) + parser.add_argument( + "--text_prompt", type=str, required=True, + help="Text prompt", + ) + parser.add_argument( + "--dilate_kernel_size", type=int, default=None, + help="Dilate kernel size. Default: None", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--sam_model_type", type=str, + default="vit_h", choices=['vit_h', 'vit_l', 'vit_b'], + help="The type of sam model to load. Default: 'vit_h" + ) + parser.add_argument( + "--sam_ckpt", type=str, required=True, + help="The path to the SAM checkpoint to use for mask generation.", + ) + parser.add_argument( + "--seed", type=int, + help="Specify seed for reproducibility.", + ) + parser.add_argument( + "--deterministic", action="store_true", + help="Use deterministic algorithms for reproducibility.", + ) + + + +if __name__ == "__main__": + """Example usage: + python fill_anything.py \ + --input_img FA_demo/FA1_dog.png \ + --point_coords 750 500 \ + --point_labels 1 \ + --text_prompt "a teddy bear on a bench" \ + --dilate_kernel_size 15 \ + --output_dir ./results \ + --sam_model_type "vit_h" \ + --sam_ckpt sam_vit_h_4b8939.pth + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + img = load_img_to_array(args.input_img) + + masks, _, _ = predict_masks_with_sam( + img, + [args.point_coords], + args.point_labels, + model_type=args.sam_model_type, + ckpt_p=args.sam_ckpt, + device=device, + ) + masks = masks.astype(np.uint8) * 255 + + # dilate mask to avoid unmasked edge effect + if args.dilate_kernel_size is not None: + masks = [dilate_mask(mask, args.dilate_kernel_size) for mask in masks] + + # visualize the segmentation results + img_stem = Path(args.input_img).stem + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + for idx, mask in enumerate(masks): + # path to the results + mask_p = out_dir / f"mask_{idx}.png" + img_points_p = out_dir / f"with_points.png" + img_mask_p = out_dir / f"with_{Path(mask_p).name}" + + # save the mask + save_array_to_img(mask, mask_p) + + # save the pointed and masked image + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_points(plt.gca(), [args.point_coords], args.point_labels, + size=(width*0.04)**2) + plt.savefig(img_points_p, bbox_inches='tight', pad_inches=0) + show_mask(plt.gca(), mask, random_color=False) + plt.savefig(img_mask_p, bbox_inches='tight', pad_inches=0) + plt.close() + + # fill the masked image + for idx, mask in enumerate(masks): + if args.seed is not None: + torch.manual_seed(args.seed) + mask_p = out_dir / f"mask_{idx}.png" + img_filled_p = out_dir / f"filled_with_{Path(mask_p).name}" + img_filled = fill_img_with_sd( + img, mask, args.text_prompt, device=device) + save_array_to_img(img_filled, img_filled_p) \ No newline at end of file diff --git a/lama_inpaint.py b/lama_inpaint.py new file mode 100644 index 0000000000000000000000000000000000000000..517012a4461e9896fbe564d44c2ec59c43ffdd0a --- /dev/null +++ b/lama_inpaint.py @@ -0,0 +1,205 @@ +import os +import sys +import numpy as np +import torch +import yaml +import glob +import argparse +from PIL import Image +from omegaconf import OmegaConf +from pathlib import Path + +os.environ['OMP_NUM_THREADS'] = '1' +os.environ['OPENBLAS_NUM_THREADS'] = '1' +os.environ['MKL_NUM_THREADS'] = '1' +os.environ['VECLIB_MAXIMUM_THREADS'] = '1' +os.environ['NUMEXPR_NUM_THREADS'] = '1' + +sys.path.insert(0, str(Path(__file__).resolve().parent / "third_party" / "lama")) + +from saicinpainting.evaluation.utils import move_to_device +from saicinpainting.training.trainers import load_checkpoint +from saicinpainting.evaluation.data import pad_tensor_to_modulo + +from utils import load_img_to_array, save_array_to_img + + +@torch.no_grad() +def inpaint_img_with_lama( + img: np.ndarray, + mask: np.ndarray, + config_p: str, + ckpt_p: str, + mod=8, + device="cuda" +): + assert len(mask.shape) == 2 + if np.max(mask) == 1: + mask = mask * 255 + img = torch.from_numpy(img).float().div(255.) + mask = torch.from_numpy(mask).float() + predict_config = OmegaConf.load(config_p) + predict_config.model.path = ckpt_p + # device = torch.device(predict_config.device) + device = torch.device(device) + + train_config_path = os.path.join( + predict_config.model.path, 'config.yaml') + + with open(train_config_path, 'r') as f: + train_config = OmegaConf.create(yaml.safe_load(f)) + + train_config.training_model.predict_only = True + train_config.visualizer.kind = 'noop' + + checkpoint_path = os.path.join( + predict_config.model.path, 'models', + predict_config.model.checkpoint + ) + model = load_checkpoint( + train_config, checkpoint_path, strict=False, map_location=device) + model.freeze() + if not predict_config.get('refine', False): + model.to(device) + + batch = {} + batch['image'] = img.permute(2, 0, 1).unsqueeze(0) + batch['mask'] = mask[None, None] + unpad_to_size = [batch['image'].shape[2], batch['image'].shape[3]] + batch['image'] = pad_tensor_to_modulo(batch['image'], mod) + batch['mask'] = pad_tensor_to_modulo(batch['mask'], mod) + batch = move_to_device(batch, device) + batch['mask'] = (batch['mask'] > 0) * 1 + + batch = model(batch) + cur_res = batch[predict_config.out_key][0].permute(1, 2, 0) + cur_res = cur_res.detach().cpu().numpy() + + if unpad_to_size is not None: + orig_height, orig_width = unpad_to_size + cur_res = cur_res[:orig_height, :orig_width] + + cur_res = np.clip(cur_res * 255, 0, 255).astype('uint8') + return cur_res + + +def build_lama_model( + config_p: str, + ckpt_p: str, + device="cuda" +): + predict_config = OmegaConf.load(config_p) + predict_config.model.path = ckpt_p + # device = torch.device(predict_config.device) + device = torch.device(device) + + train_config_path = os.path.join( + predict_config.model.path, 'config.yaml') + + with open(train_config_path, 'r') as f: + train_config = OmegaConf.create(yaml.safe_load(f)) + + train_config.training_model.predict_only = True + train_config.visualizer.kind = 'noop' + + checkpoint_path = os.path.join( + predict_config.model.path, 'models', + predict_config.model.checkpoint + ) + model = load_checkpoint( + train_config, checkpoint_path, strict=False, map_location=device) + model.freeze() + if not predict_config.get('refine', False): + model.to(device) + + return model + + +@torch.no_grad() +def inpaint_img_with_builded_lama( + model, + img: np.ndarray, + mask: np.ndarray, + config_p: str, + mod=8, + device="cuda" +): + assert len(mask.shape) == 2 + if np.max(mask) == 1: + mask = mask * 255 + img = torch.from_numpy(img).float().div(255.) + mask = torch.from_numpy(mask).float() + predict_config = OmegaConf.load(config_p) + + batch = {} + batch['image'] = img.permute(2, 0, 1).unsqueeze(0) + batch['mask'] = mask[None, None] + unpad_to_size = [batch['image'].shape[2], batch['image'].shape[3]] + batch['image'] = pad_tensor_to_modulo(batch['image'], mod) + batch['mask'] = pad_tensor_to_modulo(batch['mask'], mod) + batch = move_to_device(batch, device) + batch['mask'] = (batch['mask'] > 0) * 1 + + batch = model(batch) + cur_res = batch[predict_config.out_key][0].permute(1, 2, 0) + cur_res = cur_res.detach().cpu().numpy() + + if unpad_to_size is not None: + orig_height, orig_width = unpad_to_size + cur_res = cur_res[:orig_height, :orig_width] + + cur_res = np.clip(cur_res * 255, 0, 255).astype('uint8') + return cur_res + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--input_mask_glob", type=str, required=True, + help="Glob to input masks", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--lama_config", type=str, + default="./third_party/lama/configs/prediction/default.yaml", + help="The path to the config file of lama model. " + "Default: the config of big-lama", + ) + parser.add_argument( + "--lama_ckpt", type=str, required=True, + help="The path to the lama checkpoint.", + ) + + +if __name__ == "__main__": + """Example usage: + python lama_inpaint.py \ + --input_img FA_demo/FA1_dog.png \ + --input_mask_glob "results/FA1_dog/mask*.png" \ + --output_dir results \ + --lama_config lama/configs/prediction/default.yaml \ + --lama_ckpt big-lama + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + img_stem = Path(args.input_img).stem + mask_ps = sorted(glob.glob(args.input_mask_glob)) + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + + img = load_img_to_array(args.input_img) + for mask_p in mask_ps: + mask = load_img_to_array(mask_p) + img_inpainted_p = out_dir / f"inpainted_with_{Path(mask_p).name}" + img_inpainted = inpaint_img_with_lama( + img, mask, args.lama_config, args.lama_ckpt, device=device) + save_array_to_img(img_inpainted, img_inpainted_p) \ No newline at end of file diff --git a/pretrained_models/.gitkeep b/pretrained_models/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..19653e5d6482444d59dc54b5afd234808be5a6a7 --- /dev/null +++ b/pretrained_models/.gitkeep @@ -0,0 +1 @@ +# Put pretrained models into this directory \ No newline at end of file diff --git a/pretrained_models/big-lama/config.yaml b/pretrained_models/big-lama/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f6e26797da566bdfac97a099dc9b87ec95ad5384 --- /dev/null +++ b/pretrained_models/big-lama/config.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fdeed49926e13b101c4dd9e193acec9e58677dfdb4ba49dd6a3a8927964e2a7 +size 3947 diff --git a/pretrained_models/big-lama/models/best.ckpt b/pretrained_models/big-lama/models/best.ckpt new file mode 100644 index 0000000000000000000000000000000000000000..da3a1c3db995ee150d5b9e61ad621345778a49ab --- /dev/null +++ b/pretrained_models/big-lama/models/best.ckpt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fccb7adffd53ec0974ee5503c3731c2c2f1e7e07856fd9228cdcc0b46fd5d423 +size 410046389 diff --git a/pretrained_models/sam_vit_h_4b8939.pth b/pretrained_models/sam_vit_h_4b8939.pth new file mode 100644 index 0000000000000000000000000000000000000000..8523acce9ddab1cf7e355628a08b1aab8ce08a72 --- /dev/null +++ b/pretrained_models/sam_vit_h_4b8939.pth @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7bf3b02f3ebf1267aba913ff637d9a2d5c33d3173bb679e46d9f338c26f262e +size 2564550879 diff --git a/remove_anything.py b/remove_anything.py new file mode 100644 index 0000000000000000000000000000000000000000..124b066e481180aa41ecd5d9a97d947a8a03f4e5 --- /dev/null +++ b/remove_anything.py @@ -0,0 +1,122 @@ +import torch +import sys +import argparse +import numpy as np +from pathlib import Path +from matplotlib import pyplot as plt + +from sam_segment import predict_masks_with_sam +from lama_inpaint import inpaint_img_with_lama +from utils import load_img_to_array, save_array_to_img, dilate_mask, \ + show_mask, show_points + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--point_coords", type=float, nargs='+', required=True, + help="The coordinate of the point prompt, [coord_W coord_H].", + ) + parser.add_argument( + "--point_labels", type=int, nargs='+', required=True, + help="The labels of the point prompt, 1 or 0.", + ) + parser.add_argument( + "--dilate_kernel_size", type=int, default=None, + help="Dilate kernel size. Default: None", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--sam_model_type", type=str, + default="vit_h", choices=['vit_h', 'vit_l', 'vit_b'], + help="The type of sam model to load. Default: 'vit_h" + ) + parser.add_argument( + "--sam_ckpt", type=str, required=True, + help="The path to the SAM checkpoint to use for mask generation.", + ) + parser.add_argument( + "--lama_config", type=str, + default="./lama/configs/prediction/default.yaml", + help="The path to the config file of lama model. " + "Default: the config of big-lama", + ) + parser.add_argument( + "--lama_ckpt", type=str, required=True, + help="The path to the lama checkpoint.", + ) + + +if __name__ == "__main__": + """Example usage: + python remove_anything.py \ + --input_img FA_demo/FA1_dog.png \ + --point_coords 750 500 \ + --point_labels 1 \ + --dilate_kernel_size 15 \ + --output_dir ./results \ + --sam_model_type "vit_h" \ + --sam_ckpt sam_vit_h_4b8939.pth \ + --lama_config lama/configs/prediction/default.yaml \ + --lama_ckpt big-lama + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + img = load_img_to_array(args.input_img) + + masks, _, _ = predict_masks_with_sam( + img, + [args.point_coords], + args.point_labels, + model_type=args.sam_model_type, + ckpt_p=args.sam_ckpt, + device=device, + ) + masks = masks.astype(np.uint8) * 255 + + # dilate mask to avoid unmasked edge effect + if args.dilate_kernel_size is not None: + masks = [dilate_mask(mask, args.dilate_kernel_size) for mask in masks] + + # visualize the segmentation results + img_stem = Path(args.input_img).stem + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + for idx, mask in enumerate(masks): + # path to the results + mask_p = out_dir / f"mask_{idx}.png" + img_points_p = out_dir / f"with_points.png" + img_mask_p = out_dir / f"with_{Path(mask_p).name}" + + # save the mask + save_array_to_img(mask, mask_p) + + # save the pointed and masked image + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_points(plt.gca(), [args.point_coords], args.point_labels, + size=(width*0.04)**2) + plt.savefig(img_points_p, bbox_inches='tight', pad_inches=0) + show_mask(plt.gca(), mask, random_color=False) + plt.savefig(img_mask_p, bbox_inches='tight', pad_inches=0) + plt.close() + + # inpaint the masked image + for idx, mask in enumerate(masks): + mask_p = out_dir / f"mask_{idx}.png" + img_inpainted_p = out_dir / f"inpainted_with_{Path(mask_p).name}" + img_inpainted = inpaint_img_with_lama( + img, mask, args.lama_config, args.lama_ckpt, device=device) + save_array_to_img(img_inpainted, img_inpainted_p) diff --git a/replace_anything.py b/replace_anything.py new file mode 100644 index 0000000000000000000000000000000000000000..e08cb0497bdee5ad5e9cc4689d6c9cd02a64f28f --- /dev/null +++ b/replace_anything.py @@ -0,0 +1,126 @@ +import cv2 +import sys +import argparse +import numpy as np +import torch +from pathlib import Path +from matplotlib import pyplot as plt +from typing import Any, Dict, List +from sam_segment import predict_masks_with_sam +from stable_diffusion_inpaint import replace_img_with_sd +from utils import load_img_to_array, save_array_to_img, dilate_mask, \ + show_mask, show_points + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--point_coords", type=float, nargs='+', required=True, + help="The coordinate of the point prompt, [coord_W coord_H].", + ) + parser.add_argument( + "--point_labels", type=int, nargs='+', required=True, + help="The labels of the point prompt, 1 or 0.", + ) + parser.add_argument( + "--text_prompt", type=str, required=True, + help="Text prompt", + ) + parser.add_argument( + "--dilate_kernel_size", type=int, default=None, + help="Dilate kernel size. Default: None", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--sam_model_type", type=str, + default="vit_h", choices=['vit_h', 'vit_l', 'vit_b'], + help="The type of sam model to load. Default: 'vit_h" + ) + parser.add_argument( + "--sam_ckpt", type=str, required=True, + help="The path to the SAM checkpoint to use for mask generation.", + ) + parser.add_argument( + "--seed", type=int, + help="Specify seed for reproducibility.", + ) + parser.add_argument( + "--deterministic", action="store_true", + help="Use deterministic algorithms for reproducibility.", + ) + + + +if __name__ == "__main__": + """Example usage: + python replace_anything.py \ + --input_img FA_demo/FA1_dog.png \ + --point_coords 750 500 \ + --point_labels 1 \ + --text_prompt "sit on the swing" \ + --output_dir ./results \ + --sam_model_type "vit_h" \ + --sam_ckpt sam_vit_h_4b8939.pth + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + img = load_img_to_array(args.input_img) + + masks, _, _ = predict_masks_with_sam( + img, + [args.point_coords], + args.point_labels, + model_type=args.sam_model_type, + ckpt_p=args.sam_ckpt, + device=device, + ) + masks = masks.astype(np.uint8) * 255 + + # dilate mask to avoid unmasked edge effect + if args.dilate_kernel_size is not None: + masks = [dilate_mask(mask, args.dilate_kernel_size) for mask in masks] + + # visualize the segmentation results + img_stem = Path(args.input_img).stem + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + for idx, mask in enumerate(masks): + # path to the results + mask_p = out_dir / f"mask_{idx}.png" + img_points_p = out_dir / f"with_points.png" + img_mask_p = out_dir / f"with_{Path(mask_p).name}" + + # save the mask + save_array_to_img(mask, mask_p) + + # save the pointed and masked image + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_points(plt.gca(), [args.point_coords], args.point_labels, + size=(width*0.04)**2) + plt.savefig(img_points_p, bbox_inches='tight', pad_inches=0) + show_mask(plt.gca(), mask, random_color=False) + plt.savefig(img_mask_p, bbox_inches='tight', pad_inches=0) + plt.close() + + # fill the masked image + for idx, mask in enumerate(masks): + if args.seed is not None: + torch.manual_seed(args.seed) + mask_p = out_dir / f"mask_{idx}.png" + img_replaced_p = out_dir / f"replaced_with_{Path(mask_p).name}" + img_replaced = replace_img_with_sd( + img, mask, args.text_prompt, device=device) + save_array_to_img(img_replaced, img_replaced_p) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..77ad5b8ee2dd317b81ea5a7c89684c1360be6081 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,23 @@ +torch +torchvision +opencv-python +matplotlib +tensorflow +pyyaml +tqdm +numpy +easydict +scikit-image +scikit-learn +opencv-python +joblib +matplotlib +pandas +albumentations==0.5.2 +hydra-core +pytorch-lightning +tabulate +kornia==0.5.0 +webdataset +packaging +wldhx.yadisk-direct diff --git a/sam_segment.py b/sam_segment.py new file mode 100644 index 0000000000000000000000000000000000000000..4aada27d4758bc742017ec7d13addaf037d23c57 --- /dev/null +++ b/sam_segment.py @@ -0,0 +1,127 @@ +import sys +import argparse +import numpy as np +from pathlib import Path +from matplotlib import pyplot as plt +from typing import Any, Dict, List +import torch + +sys.path.insert(0, str(Path(__file__).resolve().parent / "third_party" / "segment-anything")) + +from segment_anything import SamPredictor, sam_model_registry +from utils import load_img_to_array, save_array_to_img, dilate_mask, \ + show_mask, show_points + + +def predict_masks_with_sam( + img: np.ndarray, + point_coords: List[List[float]], + point_labels: List[int], + model_type: str, + ckpt_p: str, + device="cuda" +): + point_coords = np.array(point_coords) + point_labels = np.array(point_labels) + sam = sam_model_registry[model_type](checkpoint=ckpt_p) + sam.to(device=device) + predictor = SamPredictor(sam) + + predictor.set_image(img) + masks, scores, logits = predictor.predict( + point_coords=point_coords, + point_labels=point_labels, + multimask_output=True, + ) + return masks, scores, logits + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--point_coords", type=float, nargs='+', required=True, + help="The coordinate of the point prompt, [coord_W coord_H].", + ) + parser.add_argument( + "--point_labels", type=int, nargs='+', required=True, + help="The labels of the point prompt, 1 or 0.", + ) + parser.add_argument( + "--dilate_kernel_size", type=int, default=None, + help="Dilate kernel size. Default: None", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--sam_model_type", type=str, + default="vit_h", choices=['vit_h', 'vit_l', 'vit_b'], + help="The type of sam model to load. Default: 'vit_h" + ) + parser.add_argument( + "--sam_ckpt", type=str, required=True, + help="The path to the SAM checkpoint to use for mask generation.", + ) + + +if __name__ == "__main__": + """Example usage: + python sam_segment.py \ + --input_img FA_demo/FA1_dog.png \ + --point_coords 750 500 \ + --point_labels 1 \ + --dilate_kernel_size 15 \ + --output_dir ./results \ + --sam_model_type "vit_h" \ + --sam_ckpt sam_vit_h_4b8939.pth + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + img = load_img_to_array(args.input_img) + + masks, _, _ = predict_masks_with_sam( + img, + [args.point_coords], + args.point_labels, + model_type=args.sam_model_type, + ckpt_p=args.sam_ckpt, + device=device, + ) + masks = masks.astype(np.uint8) * 255 + + # dilate mask to avoid unmasked edge effect + if args.dilate_kernel_size is not None: + masks = [dilate_mask(mask, args.dilate_kernel_size) for mask in masks] + + # visualize the segmentation results + img_stem = Path(args.input_img).stem + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + for idx, mask in enumerate(masks): + # path to the results + mask_p = out_dir / f"mask_{idx}.png" + img_points_p = out_dir / f"with_points.png" + img_mask_p = out_dir / f"with_{Path(mask_p).name}" + + # save the mask + save_array_to_img(mask, mask_p) + + # save the pointed and masked image + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_points(plt.gca(), [args.point_coords], args.point_labels, + size=(width*0.04)**2) + plt.savefig(img_points_p, bbox_inches='tight', pad_inches=0) + show_mask(plt.gca(), mask, random_color=False) + plt.savefig(img_mask_p, bbox_inches='tight', pad_inches=0) + plt.close() \ No newline at end of file diff --git a/stable_diffusion_inpaint.py b/stable_diffusion_inpaint.py new file mode 100644 index 0000000000000000000000000000000000000000..384a2967bd702ca529602a980ec10784b44b88ab --- /dev/null +++ b/stable_diffusion_inpaint.py @@ -0,0 +1,117 @@ +import os +import sys +import glob +import argparse +import torch +import numpy as np +import PIL.Image as Image +from pathlib import Path +from diffusers import StableDiffusionInpaintPipeline +from utils.mask_processing import crop_for_filling_pre, crop_for_filling_post +from utils.crop_for_replacing import recover_size, resize_and_pad +from utils import load_img_to_array, save_array_to_img + + +def fill_img_with_sd( + img: np.ndarray, + mask: np.ndarray, + text_prompt: str, + device="cuda" +): + pipe = StableDiffusionInpaintPipeline.from_pretrained( + "stabilityai/stable-diffusion-2-inpainting", + torch_dtype=torch.float32, + ).to(device) + img_crop, mask_crop = crop_for_filling_pre(img, mask) + img_crop_filled = pipe( + prompt=text_prompt, + image=Image.fromarray(img_crop), + mask_image=Image.fromarray(mask_crop) + ).images[0] + img_filled = crop_for_filling_post(img, mask, np.array(img_crop_filled)) + return img_filled + + +def replace_img_with_sd( + img: np.ndarray, + mask: np.ndarray, + text_prompt: str, + step: int = 50, + device="cuda" +): + pipe = StableDiffusionInpaintPipeline.from_pretrained( + "stabilityai/stable-diffusion-2-inpainting", + torch_dtype=torch.float32, + ).to(device) + img_padded, mask_padded, padding_factors = resize_and_pad(img, mask) + img_padded = pipe( + prompt=text_prompt, + image=Image.fromarray(img_padded), + mask_image=Image.fromarray(255 - mask_padded), + num_inference_steps=step, + ).images[0] + height, width, _ = img.shape + img_resized, mask_resized = recover_size( + np.array(img_padded), mask_padded, (height, width), padding_factors) + mask_resized = np.expand_dims(mask_resized, -1) / 255 + img_resized = img_resized * (1-mask_resized) + img * mask_resized + return img_resized + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--text_prompt", type=str, required=True, + help="Text prompt", + ) + parser.add_argument( + "--input_mask_glob", type=str, required=True, + help="Glob to input masks", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + parser.add_argument( + "--seed", type=int, + help="Specify seed for reproducibility.", + ) + parser.add_argument( + "--deterministic", action="store_true", + help="Use deterministic algorithms for reproducibility.", + ) + +if __name__ == "__main__": + """Example usage: + python lama_inpaint.py \ + --input_img FA_demo/FA1_dog.png \ + --input_mask_glob "results/FA1_dog/mask*.png" \ + --text_prompt "a teddy bear on a bench" \ + --output_dir results + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + device = "cuda" if torch.cuda.is_available() else "cpu" + + if args.deterministic: + os.environ["CUBLAS_WORKSPACE_CONFIG"] = ":4096:8" + torch.use_deterministic_algorithms(True) + + img_stem = Path(args.input_img).stem + mask_ps = sorted(glob.glob(args.input_mask_glob)) + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + + img = load_img_to_array(args.input_img) + for mask_p in mask_ps: + if args.seed is not None: + torch.manual_seed(args.seed) + mask = load_img_to_array(mask_p) + img_filled_p = out_dir / f"filled_with_{Path(mask_p).name}" + img_filled = fill_img_with_sd( + img, mask, args.text_prompt, device=device) + save_array_to_img(img_filled, img_filled_p) \ No newline at end of file diff --git a/third_party/.gitkeep b/third_party/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..be2098f635c6eebe331a5726194a8f47b8f7ecec --- /dev/null +++ b/third_party/.gitkeep @@ -0,0 +1 @@ +# Put third party packages into this directory \ No newline at end of file diff --git a/third_party/lama/.gitignore b/third_party/lama/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a7c6d448ddd64da433445c0ea33eb72356c586c3 --- /dev/null +++ b/third_party/lama/.gitignore @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbe005fc6c62133aee2511011dad6e169d913bba51490d29d36659566c7d84e9 +size 1865 diff --git a/third_party/lama/LICENSE b/third_party/lama/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c2ca2932070936c269cf1f607a1731dd84a660bc --- /dev/null +++ b/third_party/lama/LICENSE @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ceeeac5a802e86c413c22b16cce8e9a22027b0250c97e6f8ac97c14cf0542c0 +size 11348 diff --git a/third_party/lama/README.md b/third_party/lama/README.md new file mode 100644 index 0000000000000000000000000000000000000000..418329d4e1755a454029f53ffaf8215946c08075 --- /dev/null +++ b/third_party/lama/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54b097c25246f2193703790ca10f3da7a134ca9cd6fee6f7f14d1e03c016df3a +size 16575 diff --git a/third_party/lama/bin/analyze_errors.py b/third_party/lama/bin/analyze_errors.py new file mode 100644 index 0000000000000000000000000000000000000000..b71588187491b9b52f14dc643911d9fc96dec767 --- /dev/null +++ b/third_party/lama/bin/analyze_errors.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9019332b8309090906f49ac63fe6a6e5f1a5a03e2eedf3e56c8be6cfd6fb2dcc +size 17698 diff --git a/third_party/lama/bin/blur_predicts.py b/third_party/lama/bin/blur_predicts.py new file mode 100644 index 0000000000000000000000000000000000000000..e202846189729fe75e23c68b8e2f0c9e9828be36 --- /dev/null +++ b/third_party/lama/bin/blur_predicts.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed0863c166ba510175e89a373f7b950550e8008ed4b328e6b7d2c53e7237889a +size 2191 diff --git a/third_party/lama/bin/calc_dataset_stats.py b/third_party/lama/bin/calc_dataset_stats.py new file mode 100644 index 0000000000000000000000000000000000000000..8d82701781d1dfc8698ed5071eacf968923bb9bb --- /dev/null +++ b/third_party/lama/bin/calc_dataset_stats.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53e279cba5626e01ffaa7984b775603f64cdf149a72fa16a0f58000a3bcbc4ec +size 3627 diff --git a/third_party/lama/bin/debug/analyze_overlapping_masks.sh b/third_party/lama/bin/debug/analyze_overlapping_masks.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1b5bfab9345197da17de306904582d0c08f006f --- /dev/null +++ b/third_party/lama/bin/debug/analyze_overlapping_masks.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c368f947b87d27ecda000ba96d2dd81437aa24215064f1cae1df92c86f0f1c52 +size 1132 diff --git a/third_party/lama/bin/evaluate_predicts.py b/third_party/lama/bin/evaluate_predicts.py new file mode 100644 index 0000000000000000000000000000000000000000..069706b66bdefb95378a25cecddf1b194dccc9e6 --- /dev/null +++ b/third_party/lama/bin/evaluate_predicts.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67458a187713e1455dd1ff013bd678d608979ae49f637a22f24ee92d40de0e8b +size 3530 diff --git a/third_party/lama/bin/evaluator_example.py b/third_party/lama/bin/evaluator_example.py new file mode 100644 index 0000000000000000000000000000000000000000..ee51c9da84685eb75f4436dd607e5e0b89828825 --- /dev/null +++ b/third_party/lama/bin/evaluator_example.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3c88b5a0d15bfa6e81b60c963aa8f32ff752b853ae3cf38966d24cccdfc8b931 +size 2359 diff --git a/third_party/lama/bin/extract_masks.py b/third_party/lama/bin/extract_masks.py new file mode 100644 index 0000000000000000000000000000000000000000..c72cbae7a3bb9132bf4f9fbbd7d59956847a2b10 --- /dev/null +++ b/third_party/lama/bin/extract_masks.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e90a3197316ee22fd33b01ce1df8b8e21be39288e1669ec1c9f4d7e6e0fcd19 +size 1627 diff --git a/third_party/lama/bin/filter_sharded_dataset.py b/third_party/lama/bin/filter_sharded_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..13c14ece3aae982de71cf47aad9b4b50f81832e4 --- /dev/null +++ b/third_party/lama/bin/filter_sharded_dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48c820e8ec725ffbc1b625d6924dab43c5134f955e0a32bc3ee756f437e6c2f1 +size 2346 diff --git a/third_party/lama/bin/gen_debug_mask_dataset.py b/third_party/lama/bin/gen_debug_mask_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..9f3a66a9a9aa0f2f71dc27b0199482aebe02dafe --- /dev/null +++ b/third_party/lama/bin/gen_debug_mask_dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea1b7f9144b3716ebe676bb89efd9ae052e4831670ba65c3b1f05ef770da5e76 +size 1909 diff --git a/third_party/lama/bin/gen_mask_dataset.py b/third_party/lama/bin/gen_mask_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..56597c6f5dd6e09819515b1eb90029e6a3adbf10 --- /dev/null +++ b/third_party/lama/bin/gen_mask_dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f0ab3421b1b5f69b00e2e8faec6ac6ef7f980dc8ce8aed340bd99e3e5bd5a1b +size 5609 diff --git a/third_party/lama/bin/gen_mask_dataset_hydra.py b/third_party/lama/bin/gen_mask_dataset_hydra.py new file mode 100644 index 0000000000000000000000000000000000000000..71fadb1bb266bc0c3f22111c713b2d312ee5c12c --- /dev/null +++ b/third_party/lama/bin/gen_mask_dataset_hydra.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d732574c27a74fa64c66a1afea6497e4fd87103d7da3d58e3dc83f7bb59ad46e +size 5340 diff --git a/third_party/lama/bin/gen_outpainting_dataset.py b/third_party/lama/bin/gen_outpainting_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..b55a876b5ee9d2a754ba1e9c04273b8c4b0a5e7e --- /dev/null +++ b/third_party/lama/bin/gen_outpainting_dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7457d08e1f495c3bee3de2413fdb735f252d3fe342b5e54e5372af73b1598211 +size 3226 diff --git a/third_party/lama/bin/make_checkpoint.py b/third_party/lama/bin/make_checkpoint.py new file mode 100644 index 0000000000000000000000000000000000000000..196d533628324bb31e83b548418fcc99e9f05dd1 --- /dev/null +++ b/third_party/lama/bin/make_checkpoint.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d86903c380809c4c266a0ea39cae4d2fb4aa4fcae9ca51491053ac28a72c2edf +size 3097 diff --git a/third_party/lama/bin/mask_example.py b/third_party/lama/bin/mask_example.py new file mode 100644 index 0000000000000000000000000000000000000000..1c17869f05b9a27d8c73918e099acdeb6847d3ae --- /dev/null +++ b/third_party/lama/bin/mask_example.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a3d14ee869193ebb1b5ac68ea92c9506e7f9bba280ca9c4581fb170cd6ccd789 +size 466 diff --git a/third_party/lama/bin/paper_runfiles/blur_tests.sh b/third_party/lama/bin/paper_runfiles/blur_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..25b2cb2f9c13f8026036950eb9fe3606d713f42b --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/blur_tests.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c8ec2117f3e600321150ed0f24d385c71edb14f2c221a2c32afe6d61a833cfc +size 1491 diff --git a/third_party/lama/bin/paper_runfiles/env.sh b/third_party/lama/bin/paper_runfiles/env.sh new file mode 100644 index 0000000000000000000000000000000000000000..36f1cd88fcb44e8d0165e00c13b470cac9502e82 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/env.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:669a5d8d21c3c4400225ef11a4d424d79de578cd5fa923ef55fb930e743a7094 +size 170 diff --git a/third_party/lama/bin/paper_runfiles/find_best_checkpoint.py b/third_party/lama/bin/paper_runfiles/find_best_checkpoint.py new file mode 100644 index 0000000000000000000000000000000000000000..ab60286c8082de85c1b14f9782449dca9549b291 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/find_best_checkpoint.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42d198b58e58ec822e1aac66d66251b87c519f8b9ec178a1c0f810f0891841ae +size 2075 diff --git a/third_party/lama/bin/paper_runfiles/generate_test_celeba-hq.sh b/third_party/lama/bin/paper_runfiles/generate_test_celeba-hq.sh new file mode 100644 index 0000000000000000000000000000000000000000..82257acd085c8fb45f1a64488b3e6387f447fdb8 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/generate_test_celeba-hq.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecde53349bd3df42ce1e2659578ab493f78a521760168c1458c746b06c304fe9 +size 603 diff --git a/third_party/lama/bin/paper_runfiles/generate_test_ffhq.sh b/third_party/lama/bin/paper_runfiles/generate_test_ffhq.sh new file mode 100644 index 0000000000000000000000000000000000000000..4807ad0ca6c2a3e6c6ea604f090443f0364aaa30 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/generate_test_ffhq.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27abaa6c56ac539bea34bac171d31558826399e1ea2e69742ac0bb9f93364413 +size 580 diff --git a/third_party/lama/bin/paper_runfiles/generate_test_paris.sh b/third_party/lama/bin/paper_runfiles/generate_test_paris.sh new file mode 100644 index 0000000000000000000000000000000000000000..83782dba98cb7d0fe9424523cac63821344dee01 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/generate_test_paris.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b48c06f2d0197d5b52fd6dbaa3c3b24ec41d19e8ae485e920eab1f85b9e2d0c +size 593 diff --git a/third_party/lama/bin/paper_runfiles/generate_test_paris_256.sh b/third_party/lama/bin/paper_runfiles/generate_test_paris_256.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f8e66d0123e43b70ca0ad91d6372c154af74ccc --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/generate_test_paris_256.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:174c38fc6663c4bb6eb7b259a81ec6e4b1d16df0ae40cd4329b2fb4656306a74 +size 598 diff --git a/third_party/lama/bin/paper_runfiles/generate_val_test.sh b/third_party/lama/bin/paper_runfiles/generate_val_test.sh new file mode 100644 index 0000000000000000000000000000000000000000..70a26c40b24f7c15dfac6019b4ea150aeecaf47f --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/generate_val_test.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13ea073dbdec3dcab2af58f39099f1e23f7a93e7f445ba00d3091070ab1cd329 +size 1045 diff --git a/third_party/lama/bin/paper_runfiles/predict_inner_features.sh b/third_party/lama/bin/paper_runfiles/predict_inner_features.sh new file mode 100644 index 0000000000000000000000000000000000000000..69498fb406868ea7f8681c4c58506f214c805749 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/predict_inner_features.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eebdbcad0999666cc465eea6cf5154bd90a933a044da95888de6e6f1fdf5b15a +size 841 diff --git a/third_party/lama/bin/paper_runfiles/update_test_data_stats.sh b/third_party/lama/bin/paper_runfiles/update_test_data_stats.sh new file mode 100644 index 0000000000000000000000000000000000000000..6da3548bcd574f5d55db5ef6a3a74ef69f656835 --- /dev/null +++ b/third_party/lama/bin/paper_runfiles/update_test_data_stats.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:686112f14750df31bb8dec7d603088b40a2b6b2083df6688817640c7d26d788c +size 927 diff --git a/third_party/lama/bin/predict.py b/third_party/lama/bin/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..ce161e73a4f79445a608434184932696d212c73a --- /dev/null +++ b/third_party/lama/bin/predict.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d7cff7b5f498e895830f97fc076f33ad61bf62c5a117f2028932b267e9d13f7 +size 4092 diff --git a/third_party/lama/bin/predict_inner_features.py b/third_party/lama/bin/predict_inner_features.py new file mode 100644 index 0000000000000000000000000000000000000000..3d6932b48e8d2609e53e3d3fc1a65ec801124560 --- /dev/null +++ b/third_party/lama/bin/predict_inner_features.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2754aedde8a69795dca8cb2ee2919ba6237397b1d0501061f684e347d35128ac +size 4938 diff --git a/third_party/lama/bin/report_from_tb.py b/third_party/lama/bin/report_from_tb.py new file mode 100644 index 0000000000000000000000000000000000000000..fb7efb4a7be7c64b5903f090a112a9d9f0b204b5 --- /dev/null +++ b/third_party/lama/bin/report_from_tb.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c110718a1f0c37ed143eeac317a4bd3522350060e178ea655fd5d0bd32804dfc +size 2588 diff --git a/third_party/lama/bin/sample_from_dataset.py b/third_party/lama/bin/sample_from_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..5cdd3ea734ee514217f8123bc34f07270b373395 --- /dev/null +++ b/third_party/lama/bin/sample_from_dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb5507435eb50c10e50f96707e77f5109b8c8f73f14c520a24b321b24b6fc642 +size 3044 diff --git a/third_party/lama/bin/side_by_side.py b/third_party/lama/bin/side_by_side.py new file mode 100644 index 0000000000000000000000000000000000000000..2844a33016cf3d3672716fe16fa6bbd299bc7667 --- /dev/null +++ b/third_party/lama/bin/side_by_side.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9eaec563dbc98868725083fd560f729e3e50dc263b71a6ff1bbfd9f627df0b5d +size 2826 diff --git a/third_party/lama/bin/split_tar.py b/third_party/lama/bin/split_tar.py new file mode 100644 index 0000000000000000000000000000000000000000..a4d5f519d55b8e9f0a2dd5ff89d2ef3047ec8f33 --- /dev/null +++ b/third_party/lama/bin/split_tar.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4703b7bc32216cbf08b423db5f79b92f44ecbaa73a91ebc8523302ae33064291 +size 470 diff --git a/third_party/lama/bin/to_jit.py b/third_party/lama/bin/to_jit.py new file mode 100644 index 0000000000000000000000000000000000000000..bae725f23dd7f5a8b5115eb38990e2398e7d67d8 --- /dev/null +++ b/third_party/lama/bin/to_jit.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d38126c069b3a1091baf117ddb5b89a76b8042e9fe60945fac456674d4a90628 +size 2155 diff --git a/third_party/lama/bin/train.py b/third_party/lama/bin/train.py new file mode 100644 index 0000000000000000000000000000000000000000..1d56ba45b280a16af287fa51d53f60db5c63f116 --- /dev/null +++ b/third_party/lama/bin/train.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c831397ca8351bba57c77104a434ac1b14b1de60328e8f85a0bd33faa02311f5 +size 2609 diff --git a/third_party/lama/colab/LaMa_inpainting.ipynb b/third_party/lama/colab/LaMa_inpainting.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..c391da0130a871b50aaddf1584e2ac837180f21c --- /dev/null +++ b/third_party/lama/colab/LaMa_inpainting.ipynb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9ff06f0acc792e5df6a105f319c63012ba16652e138f6f2fe0337c5db60672a +size 4656224 diff --git a/third_party/lama/conda_env.yml b/third_party/lama/conda_env.yml new file mode 100644 index 0000000000000000000000000000000000000000..cb463fc8622d56066598b65ef6742bd9ccd2885f --- /dev/null +++ b/third_party/lama/conda_env.yml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ecbf273c3d3c537f627319a2f1485cc3ba23f1d6e13de2da3564d3703568bbd +size 5074 diff --git a/third_party/lama/configs/analyze_mask_errors.yaml b/third_party/lama/configs/analyze_mask_errors.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9b2de8aa23efec5f80ca9e4647999a55c1a32f07 --- /dev/null +++ b/third_party/lama/configs/analyze_mask_errors.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12848aaa11ea09820526a7ff2cc434734ad42ad89c1bf8102efe368ded82cdc2 +size 129 diff --git a/third_party/lama/configs/data_gen/random_medium_256.yaml b/third_party/lama/configs/data_gen/random_medium_256.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8272a6155c1a64138e508ffad830d20780830e95 --- /dev/null +++ b/third_party/lama/configs/data_gen/random_medium_256.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dfb4e402334890d4dc11fc94980229203173136226570422512e02c5d3d40d0 +size 503 diff --git a/third_party/lama/configs/data_gen/random_medium_512.yaml b/third_party/lama/configs/data_gen/random_medium_512.yaml new file mode 100644 index 0000000000000000000000000000000000000000..47007704ce971e2669276c64665310df3ed9cb7e --- /dev/null +++ b/third_party/lama/configs/data_gen/random_medium_512.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd2127ef11a3065dcbdff8e6044ea86eead96a0d57cf3c46c0d98871240a77f8 +size 506 diff --git a/third_party/lama/configs/data_gen/random_thick_256.yaml b/third_party/lama/configs/data_gen/random_thick_256.yaml new file mode 100644 index 0000000000000000000000000000000000000000..05499d46bcf4861c40a94f975ff9fcdd9a87049b --- /dev/null +++ b/third_party/lama/configs/data_gen/random_thick_256.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f00ec6113bfedcab80650106e2530068c7229d5d7532dc91b66ee4babec27c63 +size 506 diff --git a/third_party/lama/configs/data_gen/random_thick_512.yaml b/third_party/lama/configs/data_gen/random_thick_512.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c4312fcf0a196659818b49c18107b065bcb3952a --- /dev/null +++ b/third_party/lama/configs/data_gen/random_thick_512.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9be861ace6c532d5bf17b206d0983e0a9abec22f35239f7e3230da2aa2e0b2be +size 506 diff --git a/third_party/lama/configs/data_gen/random_thin_256.yaml b/third_party/lama/configs/data_gen/random_thin_256.yaml new file mode 100644 index 0000000000000000000000000000000000000000..adff14590ddf6436cfba154d2c3ce35b51b376ab --- /dev/null +++ b/third_party/lama/configs/data_gen/random_thin_256.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36f704b1545607ea51010a47362c78485e9ea5d6d0090ce7055ec870a2cbf54a +size 393 diff --git a/third_party/lama/configs/data_gen/random_thin_512.yaml b/third_party/lama/configs/data_gen/random_thin_512.yaml new file mode 100644 index 0000000000000000000000000000000000000000..70d639346b80f2c40bc9a3e903fab43a3cd8c666 --- /dev/null +++ b/third_party/lama/configs/data_gen/random_thin_512.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c9ade05222805dda751b027de3cf5f0c63b7f57e03e99449753385470bfd7e4 +size 394 diff --git a/third_party/lama/configs/debug_mask_gen.yaml b/third_party/lama/configs/debug_mask_gen.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d16dd3ee98ee5dd52f06b310491efddf97b514f5 --- /dev/null +++ b/third_party/lama/configs/debug_mask_gen.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d3a9a6fb45fb913369a8dd02d9348ef38d232c63a27a401c9255b8ae3cdffb0 +size 56 diff --git a/third_party/lama/configs/eval1.yaml b/third_party/lama/configs/eval1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5c929a931afecc5a048bb65bf830acdb37f8c3ff --- /dev/null +++ b/third_party/lama/configs/eval1.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9886df4d30c2e24c4adb2dd4834e044f71ec340342546403e7a5e7d36b8a2eb0 +size 94 diff --git a/third_party/lama/configs/eval2.yaml b/third_party/lama/configs/eval2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b6ca4b91d19802dcc0d1b2571721565599614d14 --- /dev/null +++ b/third_party/lama/configs/eval2.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3922578af55f78bb22e39ef8f32770e4e5166f6a084f3fdbabcca6d27aed2b2f +size 109 diff --git a/third_party/lama/configs/eval2_cpu.yaml b/third_party/lama/configs/eval2_cpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecbb6cb7c09f4487b25dc01bbb45171cbaa6dea3 --- /dev/null +++ b/third_party/lama/configs/eval2_cpu.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:515ef01285cd1f3797d1d544ebca33fd91d3982dc232305eeeef3456b7e0204f +size 108 diff --git a/third_party/lama/configs/eval2_gpu.yaml b/third_party/lama/configs/eval2_gpu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3c8ea5a3133d789062ddaf00b06ca2e829e10a5b --- /dev/null +++ b/third_party/lama/configs/eval2_gpu.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:994d6f15d91c4984d1d1db4868a4719b5d2d1d77caa95624e731aea1a3be9115 +size 96 diff --git a/third_party/lama/configs/eval2_jpg.yaml b/third_party/lama/configs/eval2_jpg.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5c929a931afecc5a048bb65bf830acdb37f8c3ff --- /dev/null +++ b/third_party/lama/configs/eval2_jpg.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9886df4d30c2e24c4adb2dd4834e044f71ec340342546403e7a5e7d36b8a2eb0 +size 94 diff --git a/third_party/lama/configs/eval2_segm.yaml b/third_party/lama/configs/eval2_segm.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e2a9a6289432a481d2c60372b406bf1dcb30864c --- /dev/null +++ b/third_party/lama/configs/eval2_segm.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54aacbae544564c75d2c899575e0930207a40ded0161851919f130aed57b36d7 +size 155 diff --git a/third_party/lama/configs/eval2_segm_test.yaml b/third_party/lama/configs/eval2_segm_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d3600158e67a2449239169bab8e47a0989256c11 --- /dev/null +++ b/third_party/lama/configs/eval2_segm_test.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae8f4b290ae2f40762ab82f430193376b2cd6a93811d194130c20117473fcad4 +size 184 diff --git a/third_party/lama/configs/eval2_test.yaml b/third_party/lama/configs/eval2_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..063e254a756b433c424a55253496240c5eb248df --- /dev/null +++ b/third_party/lama/configs/eval2_test.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f94c1106b66bb48fd2557e826dc10dba01886c028d188d69ea76d12d53b6524f +size 124 diff --git a/third_party/lama/configs/places2-categories_157.txt b/third_party/lama/configs/places2-categories_157.txt new file mode 100644 index 0000000000000000000000000000000000000000..80eebd8a495e0abec9afcd18c883b7ff811f8afa --- /dev/null +++ b/third_party/lama/configs/places2-categories_157.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d33167797151b72c133e96a94f9561a1c200ce4d67a88adedcda0da8f83505ca +size 3154 diff --git a/third_party/lama/configs/prediction/default.yaml b/third_party/lama/configs/prediction/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac7515f541d82eb1fb458bd58f9082cd9a62d6c4 --- /dev/null +++ b/third_party/lama/configs/prediction/default.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7733ceadd0be2210008f97b786772d10e866a6b5f7cd272d3ec5a2160e01e2c +size 783 diff --git a/third_party/lama/configs/test_large_30k.lst b/third_party/lama/configs/test_large_30k.lst new file mode 100644 index 0000000000000000000000000000000000000000..c39e741b1a45f700e3b4b290aded8213a6a7f7fc --- /dev/null +++ b/third_party/lama/configs/test_large_30k.lst @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ef334bc9177927e990f5bc443cf01bd3bde5f15998c3a0518f80a9301d7e869 +size 840000 diff --git a/third_party/lama/configs/training/ablv2_work.yaml b/third_party/lama/configs/training/ablv2_work.yaml new file mode 100644 index 0000000000000000000000000000000000000000..51cd5ff175a3b6fe9556d0865770640a13c4c58a --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a68b0310b518595d71be21f5dd81e4236037d8cbfd4d2161266de2b2f7611158 +size 731 diff --git a/third_party/lama/configs/training/ablv2_work_ffc075.yaml b/third_party/lama/configs/training/ablv2_work_ffc075.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2d95afc0ab8fe2c3bb86f263111f301ff886c918 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_ffc075.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83da114135143bd28f4c7745f074d39fdbc94182a68fb7f7f023e050e01ff3e0 +size 721 diff --git a/third_party/lama/configs/training/ablv2_work_md.yaml b/third_party/lama/configs/training/ablv2_work_md.yaml new file mode 100644 index 0000000000000000000000000000000000000000..be57a4fce7a30c47b52d83dda131c88afd9b9621 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_md.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:843ab95b074419fdf487f3a4b17e04aedaa84909375be78ff993c69866593a34 +size 753 diff --git a/third_party/lama/configs/training/ablv2_work_no_fm.yaml b/third_party/lama/configs/training/ablv2_work_no_fm.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0e79bbe248540b326ab3d0f3b1ebe259862a78f6 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_fm.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ffbdeee1dfd764b7df640e2304d42ddad0507e9275bcabf5f2b8c79591f484e +size 736 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e7ffdad10b498342fc19b3411cad14da4503344c --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfa8506f792ab94f4dff9c152650eb25e86ebc38ece53ca2e832e973e8328f43 +size 731 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a81072bc8c469c6faf6f5b497da85462fdfc38a8 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66f013536d10f1811c2b724f1d752b8ce2eac93b579d9c6c4efcb41f8267ffba +size 728 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl_celeba_csdilirpl1_new.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl_celeba_csdilirpl1_new.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6ac65a9e909b142e761c8e521b2e015b1c61f633 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_csdilirpl_celeba_csdilirpl1_new.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33e0b77a87007299607aa99c976aee301f539fc378d2aa2a16f5fa952cb5ab93 +size 731 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4885b7bf8ef9dfd9b7adf398b317d4c31fde49c --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f6a264d683ddf1fcc89b656e55c2ca3a61faef37720ebd9899ce7c1cf56a710 +size 749 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl_celeba_csirpl03_new.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl_celeba_csirpl03_new.yaml new file mode 100644 index 0000000000000000000000000000000000000000..160d16a47a87542578ee0e6db2b4ab96e54774f1 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_csirpl_celeba_csirpl03_new.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee4d44df29b8f6bbe90c89981bac4ea52f6bf4920d42e6d8c2cac541f2a48795 +size 761 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f10b46b5bdaed993b776f22518dbc02e383813a2 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7dcdb7faa0b8a2537baa9f7f8d725bfa31c9b92e6422da7fd6d88ea39fa07df8 +size 734 diff --git a/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg_celeba_l2_vgg003_new.yaml b/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg_celeba_l2_vgg003_new.yaml new file mode 100644 index 0000000000000000000000000000000000000000..600571324319cb2b393729543c6a8298e492e48e --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_no_segmpl_vgg_celeba_l2_vgg003_new.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4533cbd36675aa257cb0bdb45341bceb864d381065f046e235d83bf081653c04 +size 737 diff --git a/third_party/lama/configs/training/ablv2_work_nodil_segmpl.yaml b/third_party/lama/configs/training/ablv2_work_nodil_segmpl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc9ff997cb9a04557735e5da62746ce0f8dcfd98 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_nodil_segmpl.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:63e82f1c4efd7d47a6b100a382072c4cff53f4459d4a725aada2f84556c16af1 +size 758 diff --git a/third_party/lama/configs/training/ablv2_work_small_holes.yaml b/third_party/lama/configs/training/ablv2_work_small_holes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..297e7d5d7a227826027d67651a54909cdfc9e310 --- /dev/null +++ b/third_party/lama/configs/training/ablv2_work_small_holes.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e85983347335d6915f0b8959e9ec6d6dc36e9aa67fa3635e88f701cb5b6028a +size 727 diff --git a/third_party/lama/configs/training/big-lama-celeba.yaml b/third_party/lama/configs/training/big-lama-celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b3d9826a06eb1ed5bbc4d456e79e82b8b103ede --- /dev/null +++ b/third_party/lama/configs/training/big-lama-celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:986ed65a5cc7e28c76faf1b82dba7dd7045ab716c9f9d2ce49f44faa3e7b86b9 +size 1197 diff --git a/third_party/lama/configs/training/big-lama-regular-celeba.yaml b/third_party/lama/configs/training/big-lama-regular-celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0082395ce323c39f5b389355b7d643d58b6a8e40 --- /dev/null +++ b/third_party/lama/configs/training/big-lama-regular-celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef962ab8a6d41f53b2ebc4686dd6cbbb89ad320d0f9823914115b1a4401737de +size 859 diff --git a/third_party/lama/configs/training/big-lama-regular.yaml b/third_party/lama/configs/training/big-lama-regular.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f669a2d415f353512b14fb4f2ec9b826bd8d1a78 --- /dev/null +++ b/third_party/lama/configs/training/big-lama-regular.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23e3e58a1accb2fea69e450aa1d44ffb6d24c1ddf887b57f2f14a248b99e757f +size 845 diff --git a/third_party/lama/configs/training/big-lama.yaml b/third_party/lama/configs/training/big-lama.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6ad8c9bdf417d0676d67fe1e43eb3293fb7ca026 --- /dev/null +++ b/third_party/lama/configs/training/big-lama.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ef2fb8e7cea812070f6c66d9ac162f1a8a6caffdafae213ecd5436ecdcb9947 +size 1183 diff --git a/third_party/lama/configs/training/data/abl-02-thin-bb.yaml b/third_party/lama/configs/training/data/abl-02-thin-bb.yaml new file mode 100644 index 0000000000000000000000000000000000000000..458cfc946b480a4c0a0d2974f78e3b502cca08a4 --- /dev/null +++ b/third_party/lama/configs/training/data/abl-02-thin-bb.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efee8b5b6441a29e4280b1f4c3c6ccd9aae5ac00e8fee44c42a1610499cfabb4 +size 3696 diff --git a/third_party/lama/configs/training/data/abl-04-256-mh-dist-celeba.yaml b/third_party/lama/configs/training/data/abl-04-256-mh-dist-celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d150c6878c92cd362f161602f982826606f9b745 --- /dev/null +++ b/third_party/lama/configs/training/data/abl-04-256-mh-dist-celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85974f49244d5ba46c9efe778413dca5f0bd825b1b26f317bb184f3623a265c9 +size 881 diff --git a/third_party/lama/configs/training/data/abl-04-256-mh-dist-web.yaml b/third_party/lama/configs/training/data/abl-04-256-mh-dist-web.yaml new file mode 100644 index 0000000000000000000000000000000000000000..02692b9da8355b5786428fca6f999d386899e924 --- /dev/null +++ b/third_party/lama/configs/training/data/abl-04-256-mh-dist-web.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b766dea3201525b27d79d532b56f000f9aa26286f1aae083e115130d7ae344b +size 3055 diff --git a/third_party/lama/configs/training/data/abl-04-256-mh-dist.yaml b/third_party/lama/configs/training/data/abl-04-256-mh-dist.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b7f1afde2a0324903769261340ddb48b0acbacd --- /dev/null +++ b/third_party/lama/configs/training/data/abl-04-256-mh-dist.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1012a5358180f3be15009c227c26866726559104c1567936d5b619beacb41cb +size 2927 diff --git a/third_party/lama/configs/training/discriminator/pix2pixhd_nlayer.yaml b/third_party/lama/configs/training/discriminator/pix2pixhd_nlayer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f220be1c73882eb2dbec555bbaab3a5130ba33b6 --- /dev/null +++ b/third_party/lama/configs/training/discriminator/pix2pixhd_nlayer.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b6038f57816946c61b9c712ac0a495f7504222ae848270a7c7c15077035150a +size 74 diff --git a/third_party/lama/configs/training/evaluator/default_inpainted.yaml b/third_party/lama/configs/training/evaluator/default_inpainted.yaml new file mode 100644 index 0000000000000000000000000000000000000000..173fa0fdc8e4a137857d8717088832a6dd136029 --- /dev/null +++ b/third_party/lama/configs/training/evaluator/default_inpainted.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0017051501e11be5729063506ee90ff771e629fd0574ad22d63dce2657de6f4 +size 180 diff --git a/third_party/lama/configs/training/generator/ffc_resnet_075.yaml b/third_party/lama/configs/training/generator/ffc_resnet_075.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8e9fe81eb38aac6bb655474e5badc2b2b88e787a --- /dev/null +++ b/third_party/lama/configs/training/generator/ffc_resnet_075.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87ecc2e4ad7e63f8a78e0a2aa38f495c33ea461fb0f0d59ffbe2d76e228d947d +size 464 diff --git a/third_party/lama/configs/training/generator/pix2pixhd_global.yaml b/third_party/lama/configs/training/generator/pix2pixhd_global.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29c1b3a4f6b4252203d24388ea600ada166e1251 --- /dev/null +++ b/third_party/lama/configs/training/generator/pix2pixhd_global.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27396da01c99de1b249c8d8aafa3c39da5c9a6c290b491127a86000c51e37466 +size 123 diff --git a/third_party/lama/configs/training/generator/pix2pixhd_global_sigmoid.yaml b/third_party/lama/configs/training/generator/pix2pixhd_global_sigmoid.yaml new file mode 100644 index 0000000000000000000000000000000000000000..424aec7467f684ea4f3c299b842dc8d1cb6e4a2c --- /dev/null +++ b/third_party/lama/configs/training/generator/pix2pixhd_global_sigmoid.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01677c9a3299306ec79d350aeed22829eb4e3c955a2ad2079ec151e9d305c1b7 +size 145 diff --git a/third_party/lama/configs/training/generator/pix2pixhd_multidilated_catin_4dil_9b.yaml b/third_party/lama/configs/training/generator/pix2pixhd_multidilated_catin_4dil_9b.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cf90c8a267451a7b5ca53edf8cc98ecc35090c0a --- /dev/null +++ b/third_party/lama/configs/training/generator/pix2pixhd_multidilated_catin_4dil_9b.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f126c934b42ed574d15b746ce8fedf3af1d0e4f36e3ab240645665835965d75f +size 211 diff --git a/third_party/lama/configs/training/hydra/no_time.yaml b/third_party/lama/configs/training/hydra/no_time.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f5247cc17133c260cd0230ddfaf926e276feaca7 --- /dev/null +++ b/third_party/lama/configs/training/hydra/no_time.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90bf746615e2dc3c1fd91878c2991fffc12eb7362478967fa4492f7a7f692917 +size 188 diff --git a/third_party/lama/configs/training/hydra/overrides.yaml b/third_party/lama/configs/training/hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c6cc077feb7c3e54320ec9193e066ce30f2f51bb --- /dev/null +++ b/third_party/lama/configs/training/hydra/overrides.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54e903bc3aa23fb48f796cd3060fb49fe2a122834fbd8830147c20895a8612ee +size 213 diff --git a/third_party/lama/configs/training/lama-fourier-celeba.yaml b/third_party/lama/configs/training/lama-fourier-celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2533e010b1ac10519e6964520f1264e2f97876cb --- /dev/null +++ b/third_party/lama/configs/training/lama-fourier-celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2101eda0948398f632884ef7da7fae389df198b7395917a168c03cde436f85f +size 733 diff --git a/third_party/lama/configs/training/lama-fourier.yaml b/third_party/lama/configs/training/lama-fourier.yaml new file mode 100644 index 0000000000000000000000000000000000000000..043bad56b87df68abe9d19f4c78ccc305863d1a6 --- /dev/null +++ b/third_party/lama/configs/training/lama-fourier.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc9e86f7459791831c111e577bf7331547eb64a72e78524fef2aadb75830f965 +size 719 diff --git a/third_party/lama/configs/training/lama-regular-celeba.yaml b/third_party/lama/configs/training/lama-regular-celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..96adeac581e257ec8ee26bc540a700a22c3e94db --- /dev/null +++ b/third_party/lama/configs/training/lama-regular-celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f27e9d25b3b7ab2944137ce7046ad1567aa9a98c6f0af7a8ba95a10d8714786 +size 744 diff --git a/third_party/lama/configs/training/lama-regular.yaml b/third_party/lama/configs/training/lama-regular.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5fc00574b1184678368f629bc4fe7370eb7c760 --- /dev/null +++ b/third_party/lama/configs/training/lama-regular.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:125ea9226124fd50cf53f734100996660307a6edd7d67d782c022eb737fb4c78 +size 730 diff --git a/third_party/lama/configs/training/lama_small_train_masks.yaml b/third_party/lama/configs/training/lama_small_train_masks.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2393fbff83c67f638e2613b5066f47f3b4277174 --- /dev/null +++ b/third_party/lama/configs/training/lama_small_train_masks.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c5f5570970f6d0d763b950e0744e2c6c801f703b9c4a0d1bf52afecf4eb75e1 +size 719 diff --git a/third_party/lama/configs/training/location/celeba_example.yaml b/third_party/lama/configs/training/location/celeba_example.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e2d0fde7e595022889bb4cc2b0dfa59d1938393f --- /dev/null +++ b/third_party/lama/configs/training/location/celeba_example.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ddb785c3c0bed35fd7d5da0135d008bb11fff8ec1fcdb1944e6860ffc255f7e +size 181 diff --git a/third_party/lama/configs/training/location/docker.yaml b/third_party/lama/configs/training/location/docker.yaml new file mode 100644 index 0000000000000000000000000000000000000000..abb7b38cb4831772c46ed5ce32c21c204a143d24 --- /dev/null +++ b/third_party/lama/configs/training/location/docker.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95cbc4330938eb48c56f0a89a9c4eb3b152dfb9d8953c5360dd9fd8527fa813d +size 129 diff --git a/third_party/lama/configs/training/location/places_example.yaml b/third_party/lama/configs/training/location/places_example.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9db39a1e10d77c329aeed95162a02312864573d9 --- /dev/null +++ b/third_party/lama/configs/training/location/places_example.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:551a72ad524aa3a2328404079d65421b6d6747546ae8f3688ae77714733eed31 +size 229 diff --git a/third_party/lama/configs/training/optimizers/default_optimizers.yaml b/third_party/lama/configs/training/optimizers/default_optimizers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..245ae6ac90cdb9df8e88f14ff7febd5aeb659ea0 --- /dev/null +++ b/third_party/lama/configs/training/optimizers/default_optimizers.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78740788da2d011c2de637aede1f15af3704f015093e7b54fb0500fe54e6453f +size 96 diff --git a/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final.yaml b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e1c9ffb076206c81efc9d19666bb6b857c792c41 --- /dev/null +++ b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2918792ff8c6995aa6af84a5fe04c0c1348024aee6991bebf5ff3e9b26695989 +size 916 diff --git a/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_benchmark.yaml b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_benchmark.yaml new file mode 100644 index 0000000000000000000000000000000000000000..af1aa80c11399ac1cbb60e564fb9d78d425c069d --- /dev/null +++ b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_benchmark.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:447e062d1e7db633fd0efdd66eb89cc8ce7428af93c8598aa5408b3cd4dcf690 +size 935 diff --git a/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_celeba.yaml b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_celeba.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7b8e6178b0166d7dc6755c29e58e5afcad512e09 --- /dev/null +++ b/third_party/lama/configs/training/trainer/any_gpu_large_ssim_ddp_final_celeba.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf5940900a88825183173c64e196e2b9bf863bb39f7be27627ab4775cc0aeb91 +size 460 diff --git a/third_party/lama/configs/training/visualizer/directory.yaml b/third_party/lama/configs/training/visualizer/directory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..193919822c0e9d61dc63ac6a9f783fe22751b3f9 --- /dev/null +++ b/third_party/lama/configs/training/visualizer/directory.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a242acabd7440c5c8481428a6a3961e1e387383099a47435ba7e9a24103c8859 +size 208 diff --git a/third_party/lama/docker/1_generate_masks_from_raw_images.sh b/third_party/lama/docker/1_generate_masks_from_raw_images.sh new file mode 100644 index 0000000000000000000000000000000000000000..50893cf7a18337b1a174c5a2bbd4e21449a16a27 --- /dev/null +++ b/third_party/lama/docker/1_generate_masks_from_raw_images.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6b09ffd3be6186dab7f87f00ccf4c876e4631e896c3b0099553aab936176572 +size 756 diff --git a/third_party/lama/docker/2_predict.sh b/third_party/lama/docker/2_predict.sh new file mode 100644 index 0000000000000000000000000000000000000000..11b065d22d0cfa1081cd3d89b9780ce7b7db4782 --- /dev/null +++ b/third_party/lama/docker/2_predict.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1106e9b4d740cc8cffbd5019b354925b8cdcbc10a8e442971c43171766112239 +size 799 diff --git a/third_party/lama/docker/3_evaluate.sh b/third_party/lama/docker/3_evaluate.sh new file mode 100644 index 0000000000000000000000000000000000000000..1eb5e1e87c2455c4b4e1edfd751f194394643c79 --- /dev/null +++ b/third_party/lama/docker/3_evaluate.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edfd01a4aeac911f3e230a88816540734a590aa97f05b3ec6d9b901a1ed5429e +size 882 diff --git a/third_party/lama/docker/Dockerfile b/third_party/lama/docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..01dc61bc9c65918238f438d1b8b61170d182f614 --- /dev/null +++ b/third_party/lama/docker/Dockerfile @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65ec796246ba0cd62051ee6000ab9223c0a8b45291efc58ed762fe466510b81e +size 1570 diff --git a/third_party/lama/docker/Dockerfile-cuda111 b/third_party/lama/docker/Dockerfile-cuda111 new file mode 100644 index 0000000000000000000000000000000000000000..3524d954ae4a41c935b5b1ea777446311c7b6513 --- /dev/null +++ b/third_party/lama/docker/Dockerfile-cuda111 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15c2f9bb5fdd817ba72e58bce21686ce7f9500a7ebde0d8ca71b480bb297db72 +size 1664 diff --git a/third_party/lama/docker/build-cuda111.sh b/third_party/lama/docker/build-cuda111.sh new file mode 100644 index 0000000000000000000000000000000000000000..6df4d125e71c3f0db26bb248e28e5ddb716563b4 --- /dev/null +++ b/third_party/lama/docker/build-cuda111.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc31dbbaf0e17e9187dec5a0c8af90e7f8d3da32f690768f68161c9086b1e5d6 +size 120 diff --git a/third_party/lama/docker/build.sh b/third_party/lama/docker/build.sh new file mode 100644 index 0000000000000000000000000000000000000000..2770b74feca56c320ff189b06dc62d69bf35fbfa --- /dev/null +++ b/third_party/lama/docker/build.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01aad8f1e47ae970228d966d1bc6f6fcf466f036bfbcc0563967d2a85c56f0da +size 104 diff --git a/third_party/lama/docker/entrypoint.sh b/third_party/lama/docker/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a1fab70960079417f2f191df4c7db04d763edde --- /dev/null +++ b/third_party/lama/docker/entrypoint.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3f085ef6365f9e47d0f35b720c4d4499ef4d7e247e9ec9c7ee04abd31b4990d +size 21 diff --git a/third_party/lama/fetch_data/celebahq_dataset_prepare.sh b/third_party/lama/fetch_data/celebahq_dataset_prepare.sh new file mode 100644 index 0000000000000000000000000000000000000000..7df0c32311d64dc8e3b6facea4165503c9fae184 --- /dev/null +++ b/third_party/lama/fetch_data/celebahq_dataset_prepare.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c8281b90c60bb9d5f55d3bf0709177f87b6e0bab4e356b3c1099fb3771081ac +size 1517 diff --git a/third_party/lama/fetch_data/celebahq_gen_masks.sh b/third_party/lama/fetch_data/celebahq_gen_masks.sh new file mode 100644 index 0000000000000000000000000000000000000000..412e2015ba2cbd69272a29d9bd1173df3e6fba4f --- /dev/null +++ b/third_party/lama/fetch_data/celebahq_gen_masks.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25fcfa95ad9b881e61f63164cc6a797632b9226f6e85bd802600bc5f1e26f787 +size 1025 diff --git a/third_party/lama/fetch_data/eval_sampler.py b/third_party/lama/fetch_data/eval_sampler.py new file mode 100644 index 0000000000000000000000000000000000000000..ed110b8b94fb7d107ad6606dc4f433ead1422ee4 --- /dev/null +++ b/third_party/lama/fetch_data/eval_sampler.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d2ed7a8ff4abc29df29eae606b2fb7e79c68daebb4bb9734a7024aa0a528545 +size 782 diff --git a/third_party/lama/fetch_data/places_challenge_train_download.sh b/third_party/lama/fetch_data/places_challenge_train_download.sh new file mode 100644 index 0000000000000000000000000000000000000000..9a88d0edf884756afb66668e71387383439a3e9b --- /dev/null +++ b/third_party/lama/fetch_data/places_challenge_train_download.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83b1dccb158dc1f2a9f7c105e876cfed747eec77e9a7d00495e1c22f0e0dc4f2 +size 375 diff --git a/third_party/lama/fetch_data/places_standard_evaluation_prepare_data.sh b/third_party/lama/fetch_data/places_standard_evaluation_prepare_data.sh new file mode 100644 index 0000000000000000000000000000000000000000..a53adcdc7d3637a20c0410f4947d453c05779c27 --- /dev/null +++ b/third_party/lama/fetch_data/places_standard_evaluation_prepare_data.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:028d0a753588b0cfea0f95e4e1c91e5846661974a9116d6f11d3c1116c0c58a8 +size 1806 diff --git a/third_party/lama/fetch_data/places_standard_test_val_gen_masks.sh b/third_party/lama/fetch_data/places_standard_test_val_gen_masks.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7c320cb5ff4219ab0ea33e3ec8d3c149275e3c1 --- /dev/null +++ b/third_party/lama/fetch_data/places_standard_test_val_gen_masks.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e450cecd7d6b994b82ac9b59eb5482759dd35aac01b8ef0a428ddb91f97dc2e5 +size 398 diff --git a/third_party/lama/fetch_data/places_standard_test_val_prepare.sh b/third_party/lama/fetch_data/places_standard_test_val_prepare.sh new file mode 100644 index 0000000000000000000000000000000000000000..500f34bd29a61852f0075f3c697fe3f034bbd70c --- /dev/null +++ b/third_party/lama/fetch_data/places_standard_test_val_prepare.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0fed85d48b20f6d65f21e1afa7b90f120379d0d2f2ebf3e58ff439761385570c +size 226 diff --git a/third_party/lama/fetch_data/places_standard_test_val_sample.sh b/third_party/lama/fetch_data/places_standard_test_val_sample.sh new file mode 100644 index 0000000000000000000000000000000000000000..74b0f0911beae4d690b253208c7d98e511f0c648 --- /dev/null +++ b/third_party/lama/fetch_data/places_standard_test_val_sample.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:024e7a76e94c96f845be56b765d49e343ac284d0768428395332b0feee554d87 +size 497 diff --git a/third_party/lama/fetch_data/places_standard_train_prepare.sh b/third_party/lama/fetch_data/places_standard_train_prepare.sh new file mode 100644 index 0000000000000000000000000000000000000000..d54ddded442cb7ff3c8335ee3b7056bbc209b185 --- /dev/null +++ b/third_party/lama/fetch_data/places_standard_train_prepare.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d824db9bafae73d0cfe1c8104fa9f4ea8e013d23cd65adae115ef38c8e8c0c9 +size 534 diff --git a/third_party/lama/fetch_data/sampler.py b/third_party/lama/fetch_data/sampler.py new file mode 100644 index 0000000000000000000000000000000000000000..3789aee078b3a0dc4607ad56b82ac2414e5e9feb --- /dev/null +++ b/third_party/lama/fetch_data/sampler.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32f4ad753464d8eeb72cca1e6f033bf92570814743f457989ab372d854b6d294 +size 1540 diff --git a/third_party/lama/fetch_data/train_shuffled.flist b/third_party/lama/fetch_data/train_shuffled.flist new file mode 100644 index 0000000000000000000000000000000000000000..d0e4123db72d16abe053c08ebbf96dd9fd242867 --- /dev/null +++ b/third_party/lama/fetch_data/train_shuffled.flist @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a37add8e1f9a6ea4dcd45a4ade2ca856400fcc53f79f96da1b6028a06be004b8 +size 269624 diff --git a/third_party/lama/fetch_data/val_shuffled.flist b/third_party/lama/fetch_data/val_shuffled.flist new file mode 100644 index 0000000000000000000000000000000000000000..29732fc30947d4bc4cd3b38d37461f1fb5bcdc53 --- /dev/null +++ b/third_party/lama/fetch_data/val_shuffled.flist @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cdde2843dfce0e11b5711a0e4ae12674cf2d01a9dffc967538a2237eb0966ebf +size 19266 diff --git a/third_party/lama/models/ade20k/__init__.py b/third_party/lama/models/ade20k/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e70dc70238b00e0842de8448cd3f7fb23a6b5f2d --- /dev/null +++ b/third_party/lama/models/ade20k/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18b74c1ac9b9fc29c04f2875f40b76d0799bd4cb1766f3f136f83bd1b1d80a19 +size 19 diff --git a/third_party/lama/models/ade20k/base.py b/third_party/lama/models/ade20k/base.py new file mode 100644 index 0000000000000000000000000000000000000000..0f740945938c6652cd7955e5bae8ce53004bf3f1 --- /dev/null +++ b/third_party/lama/models/ade20k/base.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:63243e82571e7aaf0cd2a37f3b9635266c5f4ae2d0ba53e5738f6ce533c43db6 +size 23010 diff --git a/third_party/lama/models/ade20k/color150.mat b/third_party/lama/models/ade20k/color150.mat new file mode 100644 index 0000000000000000000000000000000000000000..129c082344c5cb5ada490513c6b051cd3e354e2e --- /dev/null +++ b/third_party/lama/models/ade20k/color150.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a097d3e11a763134a19cc9fd6e1ddd45570b93187c151d6b3925afe8d8a146f6 +size 502 diff --git a/third_party/lama/models/ade20k/mobilenet.py b/third_party/lama/models/ade20k/mobilenet.py new file mode 100644 index 0000000000000000000000000000000000000000..c934e5807c67b66533ff0a6c7f7908faf54e1626 --- /dev/null +++ b/third_party/lama/models/ade20k/mobilenet.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c630ff713805a70514028bc8084e77d457704928e9e02704d241994ef2737b30 +size 4932 diff --git a/third_party/lama/models/ade20k/object150_info.csv b/third_party/lama/models/ade20k/object150_info.csv new file mode 100644 index 0000000000000000000000000000000000000000..befbb409278676a38befa20380f6701b3dcb9b53 --- /dev/null +++ b/third_party/lama/models/ade20k/object150_info.csv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62a130b2db22741a03a296418106dd1cd1242f9d27a76677436e77fbba5336bd +size 5804 diff --git a/third_party/lama/models/ade20k/resnet.py b/third_party/lama/models/ade20k/resnet.py new file mode 100644 index 0000000000000000000000000000000000000000..e76468e91ce4fc7064f8108ed650e05a39f7d33b --- /dev/null +++ b/third_party/lama/models/ade20k/resnet.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89605ad5e9a543bbebc71920bdb7a3d0f2d5bff6896a1ebf4f06f10fae969d30 +size 5502 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/__init__.py b/third_party/lama/models/ade20k/segm_lib/nn/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..15d1f36f0df723f6cf6dbfd0d8da1bb88f77fdfe --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2600acab3ede0102ff0bd8e8f8d62b21e4fff97f99a95996aa14679b6ec30d01 +size 110 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/__init__.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..78b19e5f31c145ba44b467d7d794d7ae06610542 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0701e2062245ab6c90b3df6934a21be5c942b44b13c2ebb70695433599af7a15 +size 449 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/batchnorm.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/batchnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..5f80e9363fc4454b196e1698ed8f5512b10d012f --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/batchnorm.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42258e18cef5fb033e63f6e1a06c2897432c095a7177606ac6bb1119f5f2c856 +size 13813 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/comm.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/comm.py new file mode 100644 index 0000000000000000000000000000000000000000..188d8e3e619362de684ccfe4b291f112671775a5 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/comm.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a480d504d651eef51b8419254f00d97d5f0b2d9a4af590713605c0148725b234 +size 4278 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/replicate.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/replicate.py new file mode 100644 index 0000000000000000000000000000000000000000..453bcfb88aca0a11a35104da094d6b57bd7a3bf4 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/replicate.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4498b873404fce05202d4f891262e249a95733816d3877e3aee3d2401138a6af +size 3226 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_numeric_batchnorm.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_numeric_batchnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..ff094fbe865d4a8385f5ba194f9cf338f7368512 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_numeric_batchnorm.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b413dacac05b51017379df1cd27c8553beef1d90605c09c45a126169f545c991 +size 1615 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_sync_batchnorm.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_sync_batchnorm.py new file mode 100644 index 0000000000000000000000000000000000000000..d7401aa322fac2d3e90c6bcfd9d9ce9476a46dde --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/tests/test_sync_batchnorm.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ecfda2a32b39c5f89f66c5d021deaa950d9e05631f418a0688b7ce431567daa +size 3571 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/modules/unittest.py b/third_party/lama/models/ade20k/segm_lib/nn/modules/unittest.py new file mode 100644 index 0000000000000000000000000000000000000000..be9409fd75b8c2efebd1cda5833c90b0a531ca22 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/modules/unittest.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:748f5219d45b2326829ffbc8bfd655450316fd40755ab29595114fa272ef98d2 +size 835 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/parallel/__init__.py b/third_party/lama/models/ade20k/segm_lib/nn/parallel/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f21e36b2584c5110a34307dd5a60bbda5c2fcb27 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/parallel/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa04ce76f0e4d7a130a7cefca60690b53238010bb11d65b1c305221c36d1aaa1 +size 92 diff --git a/third_party/lama/models/ade20k/segm_lib/nn/parallel/data_parallel.py b/third_party/lama/models/ade20k/segm_lib/nn/parallel/data_parallel.py new file mode 100644 index 0000000000000000000000000000000000000000..65757b9a414a7595d20e3a5227618d18c57905a0 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/nn/parallel/data_parallel.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e4075dc485b063be061c308d88134a644d0b3bc1507f42f40abd3fc69977ee4 +size 3399 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/__init__.py b/third_party/lama/models/ade20k/segm_lib/utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..52b812a89b78fb3ab0d78e05e5b09e3f46ca50b1 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20df0c8d7926d2f1572ace008b001ac06e61708215b2867d02130a3cf921418e +size 18 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/data/__init__.py b/third_party/lama/models/ade20k/segm_lib/utils/data/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..23a1997853f1cd43b37b494e3297ab44e408f77d --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/data/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29e0ab4efda5e6df1c707506b08563efb41945843f714e44a0b7e590548fa26a +size 95 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/data/dataloader.py b/third_party/lama/models/ade20k/segm_lib/utils/data/dataloader.py new file mode 100644 index 0000000000000000000000000000000000000000..c5c8c389643505ef6e862a64d36142347b496890 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/data/dataloader.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4761f69cf8d6e2b6dbb85d0902fcd3cff9a7c247c8d450203c820ea4268b0a0d +size 16207 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/data/dataset.py b/third_party/lama/models/ade20k/segm_lib/utils/data/dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..ea2b5abfdf1f420d0f3136000f51ddca87f5c2e4 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/data/dataset.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e6f940d20b64d98b39e853bd55a4727e1e99244da8e187916bc46e42825a2cd +size 3465 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/data/distributed.py b/third_party/lama/models/ade20k/segm_lib/utils/data/distributed.py new file mode 100644 index 0000000000000000000000000000000000000000..ba927af9542fc8663ca8c2426b8b7328d0363c02 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/data/distributed.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6cd8939af8db7b434d403576f5ee5da9ab6658ca2ffbb14a75ca5297e373ca22 +size 1964 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/data/sampler.py b/third_party/lama/models/ade20k/segm_lib/utils/data/sampler.py new file mode 100644 index 0000000000000000000000000000000000000000..3ce82953cfb93906a69ddae180146f4d27fffa69 --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/data/sampler.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3219623a637ff2db6b79da289674e0e511a582b77d2035cbc393e38efef6c74a +size 3761 diff --git a/third_party/lama/models/ade20k/segm_lib/utils/th.py b/third_party/lama/models/ade20k/segm_lib/utils/th.py new file mode 100644 index 0000000000000000000000000000000000000000..9cfe1815c253d8d73a55915c401b07ba7525d7cc --- /dev/null +++ b/third_party/lama/models/ade20k/segm_lib/utils/th.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69d1bc0b5bb0d34bc98457bc170f8541270304f13ba25c5984243a831bd27b33 +size 1237 diff --git a/third_party/lama/models/ade20k/utils.py b/third_party/lama/models/ade20k/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..37f64fed11fefa48e2b75e8a0da21eae69ecc18e --- /dev/null +++ b/third_party/lama/models/ade20k/utils.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:740329112a2ec27db3db528d8204d576118243a6909b7585631f81c6a99d6fdc +size 1229 diff --git a/third_party/lama/models/lpips_models/alex.pth b/third_party/lama/models/lpips_models/alex.pth new file mode 100644 index 0000000000000000000000000000000000000000..fa4067abc5d4da16a7204fd94776506e4868030e --- /dev/null +++ b/third_party/lama/models/lpips_models/alex.pth @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df73285e35b22355a2df87cdb6b70b343713b667eddbda73e1977e0c860835c0 +size 6009 diff --git a/third_party/lama/models/lpips_models/squeeze.pth b/third_party/lama/models/lpips_models/squeeze.pth new file mode 100644 index 0000000000000000000000000000000000000000..f892a84a130828b1c9e2e8156e84fc5a962c665d --- /dev/null +++ b/third_party/lama/models/lpips_models/squeeze.pth @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a5350f23600cb79923ce65bb07cbf57dca461329894153e05a1346bd531cf76 +size 10811 diff --git a/third_party/lama/models/lpips_models/vgg.pth b/third_party/lama/models/lpips_models/vgg.pth new file mode 100644 index 0000000000000000000000000000000000000000..f57dcf5cc764d61c8a460365847fb2137ff0a62d --- /dev/null +++ b/third_party/lama/models/lpips_models/vgg.pth @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a78928a0af1e5f0fcb1f3b9e8f8c3a2a5a3de244d830ad5c1feddc79b8432868 +size 7289 diff --git a/third_party/lama/requirements.txt b/third_party/lama/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3edea10413ef37aca8924461c676cd2a939bd741 --- /dev/null +++ b/third_party/lama/requirements.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e057dba9b5e556b8a4c09359a32fb14ad7d4ebb9ee3bb38a68c3dfbee154430 +size 276 diff --git a/third_party/lama/saicinpainting/__init__.py b/third_party/lama/saicinpainting/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/evaluation/__init__.py b/third_party/lama/saicinpainting/evaluation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..fb87385e040a2800cf56a890208de26ad3dfbbb2 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a42518ee4a67bb4323318d3c75dcdfa1c423211d76dad31d93f8d882e1750557 +size 1201 diff --git a/third_party/lama/saicinpainting/evaluation/data.py b/third_party/lama/saicinpainting/evaluation/data.py new file mode 100644 index 0000000000000000000000000000000000000000..1ed9636a8a15e960b571fc458923140518622337 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/data.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae2d1959b40eeb494bead932a891c6aba718297738bd01664e556611b9ac636a +size 7117 diff --git a/third_party/lama/saicinpainting/evaluation/evaluator.py b/third_party/lama/saicinpainting/evaluation/evaluator.py new file mode 100644 index 0000000000000000000000000000000000000000..8f4255365acd4f54c5308a3bc4d59ebf4fb7f500 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/evaluator.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfd053c5e93710a8da341672471faa80e7a9e2d60ee6e11b359e293ac868b0d5 +size 9733 diff --git a/third_party/lama/saicinpainting/evaluation/losses/__init__.py b/third_party/lama/saicinpainting/evaluation/losses/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/evaluation/losses/base_loss.py b/third_party/lama/saicinpainting/evaluation/losses/base_loss.py new file mode 100644 index 0000000000000000000000000000000000000000..487df458fd0abae28fd6f986b87cb51954217fec --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/losses/base_loss.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44ef63201d35b4e0c44b05f755e18c37e5e07f85e8279a5b9f5c293cd759cf0e +size 23225 diff --git a/third_party/lama/saicinpainting/evaluation/losses/fid/__init__.py b/third_party/lama/saicinpainting/evaluation/losses/fid/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/evaluation/losses/fid/fid_score.py b/third_party/lama/saicinpainting/evaluation/losses/fid/fid_score.py new file mode 100644 index 0000000000000000000000000000000000000000..79acc0e29c31fa8d46926641aa18b8ee2c77c466 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/losses/fid/fid_score.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c31f9a196ef97b8876e9d657ed1066fd21c583c2c98c476da4f769a84f6fc117 +size 12179 diff --git a/third_party/lama/saicinpainting/evaluation/losses/fid/inception.py b/third_party/lama/saicinpainting/evaluation/losses/fid/inception.py new file mode 100644 index 0000000000000000000000000000000000000000..06618df300147af14ebcc11b1111eb57385c7640 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/losses/fid/inception.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4db3a6261243675ee6f34d8fc11c5c0aefb4681371f4e519bbf522de261a3a2 +size 11935 diff --git a/third_party/lama/saicinpainting/evaluation/losses/lpips.py b/third_party/lama/saicinpainting/evaluation/losses/lpips.py new file mode 100644 index 0000000000000000000000000000000000000000..e40cd66d183bba28e7d4a82f008a7f30c12eb637 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/losses/lpips.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e08f6585328813ea74479af136f2d93e3c1ee41cac94571345f858410b302de +size 33612 diff --git a/third_party/lama/saicinpainting/evaluation/losses/ssim.py b/third_party/lama/saicinpainting/evaluation/losses/ssim.py new file mode 100644 index 0000000000000000000000000000000000000000..49a1e02468f9b572a131f5ba22cc25a3095ea71c --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/losses/ssim.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dac724a5393cd97b52e720a91b177c8e2a1fda488ea9f6658b8e6a65d6043c6 +size 2688 diff --git a/third_party/lama/saicinpainting/evaluation/masks/README.md b/third_party/lama/saicinpainting/evaluation/masks/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f7b2ac49ef152bdf7e8c7f1a1646af89d7e203d6 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7ed8371d533a9b5a063a4f036b5094c7bd0f82c3d273a45fce18641d3b31cb8 +size 1064 diff --git a/third_party/lama/saicinpainting/evaluation/masks/__init__.py b/third_party/lama/saicinpainting/evaluation/masks/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/.gitignore b/third_party/lama/saicinpainting/evaluation/masks/countless/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..578d0683f36268c8fde937d8696d0552e250eeb2 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/.gitignore @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c099142bc3186ded72786ba27e9ea6d2da240fb9fd3fe79b479ecf8e734b2850 +size 7 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/README.md b/third_party/lama/saicinpainting/evaluation/masks/countless/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7337cd6f2da15e37e4090e22c8289d7050a1fa10 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9511b1672c95567f5ec9e60d92af57d13eadc645e0f20f063652ecb5d9588a54 +size 567 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/__init__.py b/third_party/lama/saicinpainting/evaluation/masks/countless/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/countless2d.py b/third_party/lama/saicinpainting/evaluation/masks/countless/countless2d.py new file mode 100644 index 0000000000000000000000000000000000000000..e365226dfdb2258103dd744b42164c525a2eca01 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/countless2d.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:890020e5fba1e9fe15d4c41bfe421831abd0ac8674d1c10f2b70fae5ec5ae819 +size 15507 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/countless3d.py b/third_party/lama/saicinpainting/evaluation/masks/countless/countless3d.py new file mode 100644 index 0000000000000000000000000000000000000000..e9a7905d36b51bd21fc5d0cce658f0494c10e7b6 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/countless3d.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c5ab5f80153921aacb9830efee3d6bbe11731f1da280e860a5a8f6808218873 +size 10662 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/images/gcim.jpg b/third_party/lama/saicinpainting/evaluation/masks/countless/images/gcim.jpg new file mode 100644 index 0000000000000000000000000000000000000000..610d9212eb0ba1cc970ea467104dea8f68a7a839 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/images/gcim.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b1ade0a290a0a79aceb49a170d085e28e5d2ea1face4fcd522d39a279d3fb4d +size 2582487 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/images/gray_segmentation.png b/third_party/lama/saicinpainting/evaluation/masks/countless/images/gray_segmentation.png new file mode 100644 index 0000000000000000000000000000000000000000..318271a338b2dbbacfce008f92aef875372e4e0f --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/images/gray_segmentation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6174e00af7b3db4b7159813dcae4fc238367b6d649d0c9be52f234426b4b1704 +size 42682 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/images/segmentation.png b/third_party/lama/saicinpainting/evaluation/masks/countless/images/segmentation.png new file mode 100644 index 0000000000000000000000000000000000000000..2ee46973a3b607909f2baadf114ebde59fb973f9 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/images/segmentation.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04c023203b2ca213ca7c950d0963c3c476d4f3ef9abbb4a372dcd911ee5e4a85 +size 70322 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/images/sparse.png b/third_party/lama/saicinpainting/evaluation/masks/countless/images/sparse.png new file mode 100644 index 0000000000000000000000000000000000000000..bb107205a8211c9304f9695dec3a234ffb3b5491 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/images/sparse.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:851419adb76d46d405d690bc25efe626d72a231ce8c4da7da6f6916ae0cf38fc +size 384 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_gcim_N_1000.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_gcim_N_1000.png new file mode 100644 index 0000000000000000000000000000000000000000..615b74bd43d378b5761329b79be1d874e8ae277c --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_gcim_N_1000.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ae2e4d9ddff8c4dadb64dd278c66ba7a46e4c753f0f563888137abacf8144c3 +size 69454 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_quick_gcim_N_1000.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_quick_gcim_N_1000.png new file mode 100644 index 0000000000000000000000000000000000000000..c5b1bb7fed4f938259fcd1cf894ccc30acf04ffa --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless2d_quick_gcim_N_1000.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fbc0416a1e44963b18d35bc94d7312d5df9335e7ac022bb8b0a46b52d84d1d5f +size 32744 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d.png new file mode 100644 index 0000000000000000000000000000000000000000..d4592a360e831827f678873309197c05fb59adae --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bdde04bfa0a2a8122a9f87a880c4af932516c78de91e70028cfccab58bd95cf +size 44844 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic.png new file mode 100644 index 0000000000000000000000000000000000000000..b62d8b330435f92e2cdfbf4eb439617cf52a503a --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e677b59808cd208d1989c2f6ffe32f8812c538ed3bf06ff063b5a2c7df65ed4 +size 49313 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic_generalized.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic_generalized.png new file mode 100644 index 0000000000000000000000000000000000000000..0cf7f82820e05afff2e1cc0804efc4411bd7a1c1 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_dynamic_generalized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b652f566e426ce0cb747c99f5463eef5f3d9108660572d5de30e2e56f5c54db8 +size 39281 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_generalized.png b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_generalized.png new file mode 100644 index 0000000000000000000000000000000000000000..cef6aa695eb425a2149a2ad340e37016d2fc7f91 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/memprof/countless3d_generalized.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfa386558e387dc3f37027181b1859639ca7d294258c6851849192a26c2b2e53 +size 57456 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/requirements.txt b/third_party/lama/saicinpainting/evaluation/masks/countless/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..7768fb0507d14734d509c78fef50f2964be82b6b --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/requirements.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7bcf6662cd2807d2855b444130e24080f0fb22ec9a8bc06fec3f3115b0169d86 +size 63 diff --git a/third_party/lama/saicinpainting/evaluation/masks/countless/test.py b/third_party/lama/saicinpainting/evaluation/masks/countless/test.py new file mode 100644 index 0000000000000000000000000000000000000000..67da43ad229dd44e3abaeb6f421e5a39d85a6d4e --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/countless/test.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:660e1a8aad4c3cce9bc1d593e360c63e4c94399e4527b89a60c2779934ac3584 +size 5440 diff --git a/third_party/lama/saicinpainting/evaluation/masks/mask.py b/third_party/lama/saicinpainting/evaluation/masks/mask.py new file mode 100644 index 0000000000000000000000000000000000000000..7f8fd4534f49afbf536bc71a84fb69e905eccf3f --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/masks/mask.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:144fe0e1d9cbe9bdde1bb5c01587e2f0191382ea8f9d4e8e0ff3fa186eb9df17 +size 19262 diff --git a/third_party/lama/saicinpainting/evaluation/refinement.py b/third_party/lama/saicinpainting/evaluation/refinement.py new file mode 100644 index 0000000000000000000000000000000000000000..d598c51cc9bb93f5a347070aa08f394ba831581f --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/refinement.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0ba8121690c3d664fdf8478c3867a304bb1f0e2581e268fcd2cc3b1216f6baa +size 11758 diff --git a/third_party/lama/saicinpainting/evaluation/utils.py b/third_party/lama/saicinpainting/evaluation/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..5fdd3c1d0904c88b8984c8b9128f5bccc56c1f39 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/utils.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00b89724b509fdfa1337b8dca0edc6369f0d0eb32bddbdb1687a94cde1866eac +size 689 diff --git a/third_party/lama/saicinpainting/evaluation/vis.py b/third_party/lama/saicinpainting/evaluation/vis.py new file mode 100644 index 0000000000000000000000000000000000000000..73840bf6ff582e9084b719ee64b915bfebcecdd3 --- /dev/null +++ b/third_party/lama/saicinpainting/evaluation/vis.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9aa1ca7d7d4bf418fa9981702b3e0b68c56c82d5f6e45b6736173f77539d2b4f +size 1217 diff --git a/third_party/lama/saicinpainting/training/__init__.py b/third_party/lama/saicinpainting/training/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/training/data/__init__.py b/third_party/lama/saicinpainting/training/data/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/training/data/aug.py b/third_party/lama/saicinpainting/training/data/aug.py new file mode 100644 index 0000000000000000000000000000000000000000..bf7de21d0aae0b6d2b344adfd436472372e926c6 --- /dev/null +++ b/third_party/lama/saicinpainting/training/data/aug.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc2592c7fb2b7278dee5cd36398e8e29117e6a88aacb9d58e7782711287610f5 +size 2694 diff --git a/third_party/lama/saicinpainting/training/data/datasets.py b/third_party/lama/saicinpainting/training/data/datasets.py new file mode 100644 index 0000000000000000000000000000000000000000..2e4af0693eab10c4bbb6091d8535f3cd4ba61365 --- /dev/null +++ b/third_party/lama/saicinpainting/training/data/datasets.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8108ed9007ca5721b91f342f725aac22b0a21d2aada3667bc2dd3bdfa19ced8 +size 13165 diff --git a/third_party/lama/saicinpainting/training/data/masks.py b/third_party/lama/saicinpainting/training/data/masks.py new file mode 100644 index 0000000000000000000000000000000000000000..a9cfb1485887c6548e4086e4e57b489bdb01f715 --- /dev/null +++ b/third_party/lama/saicinpainting/training/data/masks.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ad13ca38747515f2854715b0730e540458b661f1434d848d336d769f1bbb9df +size 13688 diff --git a/third_party/lama/saicinpainting/training/losses/__init__.py b/third_party/lama/saicinpainting/training/losses/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/third_party/lama/saicinpainting/training/losses/adversarial.py b/third_party/lama/saicinpainting/training/losses/adversarial.py new file mode 100644 index 0000000000000000000000000000000000000000..7e66dcab8af662dd9e6ce764a61f90f4d637fb91 --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/adversarial.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:813364230c4a91af29a4cc866f57b75a10da5240bfadfa49ade2bbecb77178ca +size 8593 diff --git a/third_party/lama/saicinpainting/training/losses/constants.py b/third_party/lama/saicinpainting/training/losses/constants.py new file mode 100644 index 0000000000000000000000000000000000000000..41e821126fd17306e6712a9b91c1295a80f4dc52 --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/constants.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94407ac47ebcd188f6ce7ba7e3c07fe53c1f7581023cc291accfe3f2da675175 +size 3061 diff --git a/third_party/lama/saicinpainting/training/losses/distance_weighting.py b/third_party/lama/saicinpainting/training/losses/distance_weighting.py new file mode 100644 index 0000000000000000000000000000000000000000..624098f33ff592b13d0f155a16790ae116adebcd --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/distance_weighting.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:921dd71b5c1e01987be2f39d5ca4e6e2af7fd0e81f9a405631ea52ae2f970514 +size 5451 diff --git a/third_party/lama/saicinpainting/training/losses/feature_matching.py b/third_party/lama/saicinpainting/training/losses/feature_matching.py new file mode 100644 index 0000000000000000000000000000000000000000..ea49f94d998ab99f91d1263ff56981647d7315d8 --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/feature_matching.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6a684971d889e41d5b3b9b5c2ded64d2aebe4b69334a2a477aca36882938915 +size 1313 diff --git a/third_party/lama/saicinpainting/training/losses/perceptual.py b/third_party/lama/saicinpainting/training/losses/perceptual.py new file mode 100644 index 0000000000000000000000000000000000000000..43baa59b9897e4c0057e924e52e28f9dc3607419 --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/perceptual.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7362e7a451a2b5d40317fceab0fce4a44e72c88b291d6be3f3718992b95450dd +size 4125 diff --git a/third_party/lama/saicinpainting/training/losses/segmentation.py b/third_party/lama/saicinpainting/training/losses/segmentation.py new file mode 100644 index 0000000000000000000000000000000000000000..79f3f94112f338cab384407dbc5ae1581d32bd74 --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/segmentation.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48098106afd8336e1be2d449218f82b902c40735c478ee5afe44a8ac965d1366 +size 1946 diff --git a/third_party/lama/saicinpainting/training/losses/style_loss.py b/third_party/lama/saicinpainting/training/losses/style_loss.py new file mode 100644 index 0000000000000000000000000000000000000000..5771134da8ccceefa33efdecdeec9c1fd3c43a3b --- /dev/null +++ b/third_party/lama/saicinpainting/training/losses/style_loss.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0d1b6eb07832ac9807ec507fad3ac4f3b4d38236da30b7b87f185fe1a7223b9 +size 4777 diff --git a/third_party/lama/saicinpainting/training/modules/__init__.py b/third_party/lama/saicinpainting/training/modules/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ab6e7aacf99996be844974fb8cb01e071db50d92 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2027f8bfe20cdc44477dd7d99434b82e82829b6c9794288329cba5c1e445912 +size 972 diff --git a/third_party/lama/saicinpainting/training/modules/base.py b/third_party/lama/saicinpainting/training/modules/base.py new file mode 100644 index 0000000000000000000000000000000000000000..819bf17196ca2f2006efc10aa12dc5ed6454a8c8 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/base.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:526016ea45cd40b17b1bfa812c3be1ae227b735de684cd77382a5788eb5ac4aa +size 2684 diff --git a/third_party/lama/saicinpainting/training/modules/depthwise_sep_conv.py b/third_party/lama/saicinpainting/training/modules/depthwise_sep_conv.py new file mode 100644 index 0000000000000000000000000000000000000000..8b7d976206a6908b1e11a4abcd9ea0595027246e --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/depthwise_sep_conv.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9aa49550f3d34f1682cabbcc92f89d5f131ff0e89ebeefbfde396a85153c5b22 +size 557 diff --git a/third_party/lama/saicinpainting/training/modules/fake_fakes.py b/third_party/lama/saicinpainting/training/modules/fake_fakes.py new file mode 100644 index 0000000000000000000000000000000000000000..b2bd04bc4def302ff915cd7e9ad3ebf4ac263cf1 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/fake_fakes.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24dc08031596f881e5c56492fe05f3ad0cb7291153cf394a387d062552e8529f +size 2141 diff --git a/third_party/lama/saicinpainting/training/modules/ffc.py b/third_party/lama/saicinpainting/training/modules/ffc.py new file mode 100644 index 0000000000000000000000000000000000000000..6e56de35cf017924cb943c33725a96dc6a904d0e --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/ffc.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1647ce037032e533c777fd1d486c61d3ecc0eee7603b8cb96b23d0deffcaf308 +size 17753 diff --git a/third_party/lama/saicinpainting/training/modules/multidilated_conv.py b/third_party/lama/saicinpainting/training/modules/multidilated_conv.py new file mode 100644 index 0000000000000000000000000000000000000000..96c67133f66b856ed7ba20ebb26c5423e8726047 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/multidilated_conv.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26929410919ebe0e024bd65d318978d14bdefcfeef94d079ae9c4d20189f2780 +size 4060 diff --git a/third_party/lama/saicinpainting/training/modules/multiscale.py b/third_party/lama/saicinpainting/training/modules/multiscale.py new file mode 100644 index 0000000000000000000000000000000000000000..1a0915adc75d1b007d0e892df4f58e73bab66550 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/multiscale.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5b37be6ca20715ccbfb44e9603eb71a99a46072a240e4ea7581f05874cbf2e9 +size 10699 diff --git a/third_party/lama/saicinpainting/training/modules/pix2pixhd.py b/third_party/lama/saicinpainting/training/modules/pix2pixhd.py new file mode 100644 index 0000000000000000000000000000000000000000..7b41917c328745fdccdc944f50f5dc86a9682526 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/pix2pixhd.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c064a8c257a3674786b6e99e202b9cfc68033c840300a7c082502e3d599d8111 +size 27964 diff --git a/third_party/lama/saicinpainting/training/modules/spatial_transform.py b/third_party/lama/saicinpainting/training/modules/spatial_transform.py new file mode 100644 index 0000000000000000000000000000000000000000..cd6b2b9f54f4db96de827f1b5c9de3ea0f58afc0 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/spatial_transform.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f479a0c9ba94bd46b197507e8e8cdcc570e84ec29f5a577ade63e542adb43b5 +size 1976 diff --git a/third_party/lama/saicinpainting/training/modules/squeeze_excitation.py b/third_party/lama/saicinpainting/training/modules/squeeze_excitation.py new file mode 100644 index 0000000000000000000000000000000000000000..1e9e911a7ccf4abc8de164f1a8a424f73986c4b1 --- /dev/null +++ b/third_party/lama/saicinpainting/training/modules/squeeze_excitation.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:933c53adb2477b99c58ab325b26b124507a06b8c097ed2dd213c28f5841839fe +size 609 diff --git a/third_party/lama/saicinpainting/training/trainers/__init__.py b/third_party/lama/saicinpainting/training/trainers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5800a6b0c1dab312ecc8922ad498d62a04c69952 --- /dev/null +++ b/third_party/lama/saicinpainting/training/trainers/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15924fed2f31eab72bea2eb1000553615d8b827a010e44a85b4beb6cf7531f8c +size 932 diff --git a/third_party/lama/saicinpainting/training/trainers/base.py b/third_party/lama/saicinpainting/training/trainers/base.py new file mode 100644 index 0000000000000000000000000000000000000000..43fcc8983ceb21f20e6bb99489309a093a64adc2 --- /dev/null +++ b/third_party/lama/saicinpainting/training/trainers/base.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d0a3a8eccd57d1048233a9ec83d561c575617d3ad20ed6bdcf6976cfdd6c912 +size 13893 diff --git a/third_party/lama/saicinpainting/training/trainers/default.py b/third_party/lama/saicinpainting/training/trainers/default.py new file mode 100644 index 0000000000000000000000000000000000000000..f87ed11d744c2144e344ba4e25f285b05e3a0402 --- /dev/null +++ b/third_party/lama/saicinpainting/training/trainers/default.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85e4a9ffaf21d725a48cf6dc066de3224c2168cea51c19696197e2a2f33f24ef +size 9406 diff --git a/third_party/lama/saicinpainting/training/visualizers/__init__.py b/third_party/lama/saicinpainting/training/visualizers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..19efe4c72f480bd77252a3b6d5b379bd674297af --- /dev/null +++ b/third_party/lama/saicinpainting/training/visualizers/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ed33de582e26e641aef0e0b53af24091e089bb09d62937a1fba99b4ede2dc93 +size 431 diff --git a/third_party/lama/saicinpainting/training/visualizers/base.py b/third_party/lama/saicinpainting/training/visualizers/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae2ecfaf92f51fafa8b072cb927d24cc54f31c12 --- /dev/null +++ b/third_party/lama/saicinpainting/training/visualizers/base.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8aac20ed2f58ebff9aa0c600f4e59ac83aa535803eccfa713558d1f560e4d96a +size 2639 diff --git a/third_party/lama/saicinpainting/training/visualizers/colors.py b/third_party/lama/saicinpainting/training/visualizers/colors.py new file mode 100644 index 0000000000000000000000000000000000000000..2f6ba42302eab459183294ede465a92c43147336 --- /dev/null +++ b/third_party/lama/saicinpainting/training/visualizers/colors.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a414a47ea870489aa5ac566c0219f4504a937b173f709e5062d39670d0ceaa2 +size 2945 diff --git a/third_party/lama/saicinpainting/training/visualizers/directory.py b/third_party/lama/saicinpainting/training/visualizers/directory.py new file mode 100644 index 0000000000000000000000000000000000000000..97e17532fdd3e37277eca6e78cb5d97fc73f9fe4 --- /dev/null +++ b/third_party/lama/saicinpainting/training/visualizers/directory.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b7e853724f3611540d0091d2153c51d32ed185fd0c6d9a5a6af22a2886ae146 +size 1602 diff --git a/third_party/lama/saicinpainting/training/visualizers/noop.py b/third_party/lama/saicinpainting/training/visualizers/noop.py new file mode 100644 index 0000000000000000000000000000000000000000..7f8529d21c12059f9d810c4b444f1396c0631217 --- /dev/null +++ b/third_party/lama/saicinpainting/training/visualizers/noop.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90330e764784e1f20d603c0e2aee6ade4db26d506e1d1129571fc38a8ac24a75 +size 247 diff --git a/third_party/lama/saicinpainting/utils.py b/third_party/lama/saicinpainting/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..259903d245cb7e5f760e56ba85bee7be0b944ab8 --- /dev/null +++ b/third_party/lama/saicinpainting/utils.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a399137ac692a8c0eac6b8f1befacdd9d8f3443397d8a0b000845010c2b0cfc +size 5350 diff --git a/third_party/lama_requirements.txt b/third_party/lama_requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..5b8208844ebc5054bb22844c939d170f57281b86 --- /dev/null +++ b/third_party/lama_requirements.txt @@ -0,0 +1,21 @@ +torch +torchvision +tensorflow +pyyaml +tqdm +numpy +easydict +scikit-image +scikit-learn +opencv-python +joblib +matplotlib +pandas +albumentations==0.5.2 +hydra-core +pytorch-lightning +tabulate +kornia==0.5.0 +webdataset +packaging +wldhx.yadisk-direct diff --git a/third_party/segment-anything/.flake8 b/third_party/segment-anything/.flake8 new file mode 100644 index 0000000000000000000000000000000000000000..5fa43c719d44267c37b892c874e0bdd94503a71c --- /dev/null +++ b/third_party/segment-anything/.flake8 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dca6883639e28760c91d18bf835b3616f64f2c9c07ba14376adf7fa400d72743 +size 211 diff --git a/third_party/segment-anything/.gitignore b/third_party/segment-anything/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..21a2685862cd6ea2d550d9e03d50eba15ff42080 --- /dev/null +++ b/third_party/segment-anything/.gitignore @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36f3987a7f7f7289a8520350d3776410300bef8df94892236d23790a674fd03b +size 389 diff --git a/third_party/segment-anything/CODE_OF_CONDUCT.md b/third_party/segment-anything/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000000000000000000000000000000000..08b0137f71c9802e4ccd7abcf9d7913f65615987 --- /dev/null +++ b/third_party/segment-anything/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4d00a8ac00c1735cd2f3fb50ca67c83960ef9123fc5656f2e69056c905ed244 +size 3541 diff --git a/third_party/segment-anything/CONTRIBUTING.md b/third_party/segment-anything/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..d563c6f25a6cb8c2dab7861627bb79611dce11d6 --- /dev/null +++ b/third_party/segment-anything/CONTRIBUTING.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d9d12cc7fcbc300c4f8c55dea9834bd917745eecdb2fbc8ff58cb21636aa0af +size 1400 diff --git a/third_party/segment-anything/LICENSE b/third_party/segment-anything/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..06974d20a76bf416d33438e200c8e11958d4002e --- /dev/null +++ b/third_party/segment-anything/LICENSE @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 +size 11357 diff --git a/third_party/segment-anything/README.md b/third_party/segment-anything/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8c74f44a811920bd482d7833d3825118c5be8780 --- /dev/null +++ b/third_party/segment-anything/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:233748215bfcbbe467d768f11ec3189415a2bea14364a05373b4cc00247e728e +size 8488 diff --git a/third_party/segment-anything/assets/masks1.png b/third_party/segment-anything/assets/masks1.png new file mode 100644 index 0000000000000000000000000000000000000000..559e20feb4ab76b0833d4d52bd16c6be8731eef8 --- /dev/null +++ b/third_party/segment-anything/assets/masks1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:094650248317c2b41ca0279d402253a8d1ae3801f8809e69480561dddd7d9f64 +size 3703371 diff --git a/third_party/segment-anything/assets/masks2.jpg b/third_party/segment-anything/assets/masks2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..61066dfc6a6b2bcef67d47bf9a7785173b4bbd73 --- /dev/null +++ b/third_party/segment-anything/assets/masks2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96d80aae8cae21e6fa9d8081b99cb3ef68d513281f2ec4e360a4e2b3f7e6010c +size 133278 diff --git a/third_party/segment-anything/assets/minidemo.gif b/third_party/segment-anything/assets/minidemo.gif new file mode 100644 index 0000000000000000000000000000000000000000..92d526c1e93430f8e5575e28dd2f008caa85b736 --- /dev/null +++ b/third_party/segment-anything/assets/minidemo.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44ab93e0b59551a3c649cc8a38eb9760545285110f515673c5e7d1e85354125c +size 2015643 diff --git a/third_party/segment-anything/assets/model_diagram.png b/third_party/segment-anything/assets/model_diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..f5673544cba9af0ec90e78b0836f71d395d1a26c --- /dev/null +++ b/third_party/segment-anything/assets/model_diagram.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80f88ccc64fdefc08b28682661b41832e25e4c1612e7e430dc30ed551ee51d86 +size 581875 diff --git a/third_party/segment-anything/assets/notebook1.png b/third_party/segment-anything/assets/notebook1.png new file mode 100644 index 0000000000000000000000000000000000000000..a8f78051eb3a6089e28481c032e4f0cefa0a0685 --- /dev/null +++ b/third_party/segment-anything/assets/notebook1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff397cd575c022eb66fa48e2229eff78035bb144df20fc9df91548f53906b47c +size 874274 diff --git a/third_party/segment-anything/assets/notebook2.png b/third_party/segment-anything/assets/notebook2.png new file mode 100644 index 0000000000000000000000000000000000000000..15bfd9ffbbbf8a8b2172571da09a4d9c9e13ba8f --- /dev/null +++ b/third_party/segment-anything/assets/notebook2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdffadfdddee81d090ec130566eae7de6de0c6d6b2be85974860327c5d860fcc +size 1221706 diff --git a/third_party/segment-anything/demo/README.md b/third_party/segment-anything/demo/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8613595d8f5e8141d6d27bf636664cf468637587 --- /dev/null +++ b/third_party/segment-anything/demo/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a17f8a377e16a377b42932cdeeacab7a84afed5a2ef29907c0427ae5a493fed8 +size 3681 diff --git a/third_party/segment-anything/demo/configs/webpack/common.js b/third_party/segment-anything/demo/configs/webpack/common.js new file mode 100644 index 0000000000000000000000000000000000000000..081dcb941e7f5180df3d4514a5262b6503367aa4 --- /dev/null +++ b/third_party/segment-anything/demo/configs/webpack/common.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f085261110597dbe9bb6ea75920597a2da413257cba5e99d81aa55385a87b6c9 +size 2051 diff --git a/third_party/segment-anything/demo/configs/webpack/dev.js b/third_party/segment-anything/demo/configs/webpack/dev.js new file mode 100644 index 0000000000000000000000000000000000000000..359fc0b5691f018d48fb8a2d3192045b1eb50686 --- /dev/null +++ b/third_party/segment-anything/demo/configs/webpack/dev.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94aeca1a07f6f02b210f7c020b9b549bff38aebfd68931ea04721a7b61e57714 +size 767 diff --git a/third_party/segment-anything/demo/configs/webpack/prod.js b/third_party/segment-anything/demo/configs/webpack/prod.js new file mode 100644 index 0000000000000000000000000000000000000000..9b3e60874f8286dd217eeb47f3b32451a1672a75 --- /dev/null +++ b/third_party/segment-anything/demo/configs/webpack/prod.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c6be50b1f09763b0176abda1215cff8aed5f2d6fa30b5b57750b47a5fa5ad20 +size 636 diff --git a/third_party/segment-anything/demo/package.json b/third_party/segment-anything/demo/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0424949c377617b9b95b4ea18ca99d9cd5065af4 --- /dev/null +++ b/third_party/segment-anything/demo/package.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14f1d1233224c35e71f48cbede096eca89187bb0dc829fce0f380b0c68bfc98c +size 2002 diff --git a/third_party/segment-anything/demo/postcss.config.js b/third_party/segment-anything/demo/postcss.config.js new file mode 100644 index 0000000000000000000000000000000000000000..93e942fc73e5b3a59b1419d9c7922eb873f55126 --- /dev/null +++ b/third_party/segment-anything/demo/postcss.config.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e37ff61d56715fd068fa87ea291ccc249da1d9c3b745ab58763f8bba3f9aa776 +size 339 diff --git a/third_party/segment-anything/demo/src/App.tsx b/third_party/segment-anything/demo/src/App.tsx new file mode 100644 index 0000000000000000000000000000000000000000..b0301c0faaac53c01b135cadde2ef9f5d413157a --- /dev/null +++ b/third_party/segment-anything/demo/src/App.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aab0d86de97774277aca46d1d81696176b2e0cbb68595d36ee33d7f869dd7380 +size 4245 diff --git a/third_party/segment-anything/demo/src/assets/data/dogs.jpg b/third_party/segment-anything/demo/src/assets/data/dogs.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6290ef3999652ea8440c242cadc8e7ec574e1dfd --- /dev/null +++ b/third_party/segment-anything/demo/src/assets/data/dogs.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49b29517d3a6457bf8bd0b83a80cbeb24c2466bf3e5804bd503ebe60e430d784 +size 448722 diff --git a/third_party/segment-anything/demo/src/assets/index.html b/third_party/segment-anything/demo/src/assets/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e7af14f95b80999f9ade4fb17f89165f808c98a0 --- /dev/null +++ b/third_party/segment-anything/demo/src/assets/index.html @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:855449a290c63a7b952cfdb37052d6208e03411f620348c7c37ea012982b684f +size 532 diff --git a/third_party/segment-anything/demo/src/assets/scss/App.scss b/third_party/segment-anything/demo/src/assets/scss/App.scss new file mode 100644 index 0000000000000000000000000000000000000000..c0575d6942802249a01158cd7b01d2e1973e6724 --- /dev/null +++ b/third_party/segment-anything/demo/src/assets/scss/App.scss @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc1a7ad0d019ddb1d32d0ecb588ba0ac26ce41d8625dd6c366348b25f83a28ec +size 59 diff --git a/third_party/segment-anything/demo/src/components/Stage.tsx b/third_party/segment-anything/demo/src/components/Stage.tsx new file mode 100644 index 0000000000000000000000000000000000000000..cbe35029edaf7c388f910d5bf3c7763132fc4358 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/Stage.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a3f0d0c911a2395c13fe4249ac51f8f46db6843ded73af645c1c9f089dca140 +size 1580 diff --git a/third_party/segment-anything/demo/src/components/Tool.tsx b/third_party/segment-anything/demo/src/components/Tool.tsx new file mode 100644 index 0000000000000000000000000000000000000000..efc360f873c6a17d1bc439c3e2e90ef43467ff29 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/Tool.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0162bdbd5adaf79ce8f42f7f65d9127eb744a97febb86471c870fd62821951ed +size 2136 diff --git a/third_party/segment-anything/demo/src/components/helpers/Interfaces.tsx b/third_party/segment-anything/demo/src/components/helpers/Interfaces.tsx new file mode 100644 index 0000000000000000000000000000000000000000..8a502e6b18ab2995d929dff1fef39f0bcfc18cb5 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/helpers/Interfaces.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f5f260ab2e60b64948cc7f707f04d02fa2caa1af27b505a2cb24278aff1ad46 +size 611 diff --git a/third_party/segment-anything/demo/src/components/helpers/maskUtils.tsx b/third_party/segment-anything/demo/src/components/helpers/maskUtils.tsx new file mode 100644 index 0000000000000000000000000000000000000000..d89c37e820462f41afdee2dc69bb8019ff3899d0 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/helpers/maskUtils.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8de4ea63fc84e0e10410a6169e9613b22987dc8477d44979f14fba440fdec85 +size 1616 diff --git a/third_party/segment-anything/demo/src/components/helpers/onnxModelAPI.tsx b/third_party/segment-anything/demo/src/components/helpers/onnxModelAPI.tsx new file mode 100644 index 0000000000000000000000000000000000000000..2710dd1e06f5ed11698748411446144e0990d31b --- /dev/null +++ b/third_party/segment-anything/demo/src/components/helpers/onnxModelAPI.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f52424953656fcbc125f1dddaf0f64623ff74f6c7b4c0b742c604974ff0e07c +size 2198 diff --git a/third_party/segment-anything/demo/src/components/helpers/scaleHelper.tsx b/third_party/segment-anything/demo/src/components/helpers/scaleHelper.tsx new file mode 100644 index 0000000000000000000000000000000000000000..5d25d6076876939c7e90b9665118cd7af85bdcb7 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/helpers/scaleHelper.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c09c180931fb43baedd6c5b240879fa1b5613cf08f6621fb7353ac3d4f97651 +size 614 diff --git a/third_party/segment-anything/demo/src/components/hooks/context.tsx b/third_party/segment-anything/demo/src/components/hooks/context.tsx new file mode 100644 index 0000000000000000000000000000000000000000..1210ecbd8cc69af3f686f1656afd8cc6ebd27725 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/hooks/context.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17cf1e683e30ffc56a3017eb62f86f195ebffda3d82181c0614b7ef71f522cab +size 959 diff --git a/third_party/segment-anything/demo/src/components/hooks/createContext.tsx b/third_party/segment-anything/demo/src/components/hooks/createContext.tsx new file mode 100644 index 0000000000000000000000000000000000000000..4f81fbc8b23254f99d1b3aeebf45ff1bd446fc66 --- /dev/null +++ b/third_party/segment-anything/demo/src/components/hooks/createContext.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4daa14ae82a774ca78f99a7fecafe088e1337e527399baabca37721484762705 +size 736 diff --git a/third_party/segment-anything/demo/src/index.tsx b/third_party/segment-anything/demo/src/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..705b054921a698f57b716de706e5787e88d4178b --- /dev/null +++ b/third_party/segment-anything/demo/src/index.tsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32ef6d97f2e12b9f60669c036367e9c9b214ce262a5ff6c12e7ffd1120004985 +size 529 diff --git a/third_party/segment-anything/demo/tailwind.config.js b/third_party/segment-anything/demo/tailwind.config.js new file mode 100644 index 0000000000000000000000000000000000000000..1e81ce8887f0828391e7ffb308034e39fc9a4b8c --- /dev/null +++ b/third_party/segment-anything/demo/tailwind.config.js @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:996d1ac894296cf3137afa8b2cf66432e31fb3db31d6e9980a4873d257721ca7 +size 337 diff --git a/third_party/segment-anything/demo/tsconfig.json b/third_party/segment-anything/demo/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..4f1b23bfefc0fc22f48085785774ce0bbc97d909 --- /dev/null +++ b/third_party/segment-anything/demo/tsconfig.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa7fabbae4db7cfd6a63e1b60a50c64b8c0ed81ea7527c9bd4d2e2824e6f68d5 +size 644 diff --git a/third_party/segment-anything/linter.sh b/third_party/segment-anything/linter.sh new file mode 100644 index 0000000000000000000000000000000000000000..e330d0f736b94623a8d7fcd72174e7176e279a10 --- /dev/null +++ b/third_party/segment-anything/linter.sh @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de55131fe5f32874b314502a3f940036691f7e1fa166d17941eccb869a139d92 +size 564 diff --git a/third_party/segment-anything/notebooks/automatic_mask_generator_example.ipynb b/third_party/segment-anything/notebooks/automatic_mask_generator_example.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..3ae97e1b1b38548bcbc17d651395b3e120810b73 --- /dev/null +++ b/third_party/segment-anything/notebooks/automatic_mask_generator_example.ipynb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10908fffaa0c06b5f2ced2f32723bb6b54c373fd1e6ebb58f72e892339c3df19 +size 4381012 diff --git a/third_party/segment-anything/notebooks/images/dog.jpg b/third_party/segment-anything/notebooks/images/dog.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b1c2adf5f95b8bfea396cceb5d7ec0e1943405bc --- /dev/null +++ b/third_party/segment-anything/notebooks/images/dog.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf76876b90e3ebd521f9882b9177ba8f33e80cb7ec09c630f179b122edd125e1 +size 99846 diff --git a/third_party/segment-anything/notebooks/images/groceries.jpg b/third_party/segment-anything/notebooks/images/groceries.jpg new file mode 100644 index 0000000000000000000000000000000000000000..755e1896c5518a58c0327189f3a895d5216d9753 --- /dev/null +++ b/third_party/segment-anything/notebooks/images/groceries.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7073dfecb5a3ecafb6152124113163a0ea1c1c70f92999ec892b519eca63e3d3 +size 168066 diff --git a/third_party/segment-anything/notebooks/images/truck.jpg b/third_party/segment-anything/notebooks/images/truck.jpg new file mode 100644 index 0000000000000000000000000000000000000000..88b0a07cdca374ea006351c86bad82d61ddb98c5 --- /dev/null +++ b/third_party/segment-anything/notebooks/images/truck.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:941715e721c8864324a1425b445ea4dde0498b995c45ddce0141a58971c6ff99 +size 271475 diff --git a/third_party/segment-anything/notebooks/onnx_model_example.ipynb b/third_party/segment-anything/notebooks/onnx_model_example.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..9fe7a93f5a355c6d79c69da89117e004723167bc --- /dev/null +++ b/third_party/segment-anything/notebooks/onnx_model_example.ipynb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0468449922eab9aaefe788a5e9da01b7756fb15795eaef71af71e0b590afb816 +size 22502 diff --git a/third_party/segment-anything/notebooks/predictor_example.ipynb b/third_party/segment-anything/notebooks/predictor_example.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..528b1040b066f3490de3cc431c0a1c0552c1c767 --- /dev/null +++ b/third_party/segment-anything/notebooks/predictor_example.ipynb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd02280bcd3aab53ecb8fec3c808fc6b8976d094e6dba93d8e53b1a5f62a5752 +size 8380947 diff --git a/third_party/segment-anything/scripts/amg.py b/third_party/segment-anything/scripts/amg.py new file mode 100644 index 0000000000000000000000000000000000000000..e1e4bea25926111aeef1e98af92499dea047ae1c --- /dev/null +++ b/third_party/segment-anything/scripts/amg.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24b3edd3f3880e75b64d2b8d67e1b7d9519f46f6479d1137c9ac3309e9d43105 +size 7043 diff --git a/third_party/segment-anything/scripts/export_onnx_model.py b/third_party/segment-anything/scripts/export_onnx_model.py new file mode 100644 index 0000000000000000000000000000000000000000..90f5cbe1774f156741e3f7bbe7864bbe55556c04 --- /dev/null +++ b/third_party/segment-anything/scripts/export_onnx_model.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0270d82d96cfb3348471f349b6cb5b224833a0ea101bd8091dc5c364695b3b2 +size 6250 diff --git a/third_party/segment-anything/segment_anything/__init__.py b/third_party/segment-anything/segment_anything/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..06c92f74d1f6a9883fc6f55524e9af3214f61d27 --- /dev/null +++ b/third_party/segment-anything/segment_anything/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8d8eb649610b2d51f138481a89617a3dcb61106465121dcb1c2f23affc84c30 +size 427 diff --git a/third_party/segment-anything/segment_anything/automatic_mask_generator.py b/third_party/segment-anything/segment_anything/automatic_mask_generator.py new file mode 100644 index 0000000000000000000000000000000000000000..0a8a102df5175f8eb33eefe37374ad567efcb4ac --- /dev/null +++ b/third_party/segment-anything/segment_anything/automatic_mask_generator.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71c698d2b6cbf5a62eafa5f12106fdf3bff676102adf1aed2287df3b3990b4e0 +size 15148 diff --git a/third_party/segment-anything/segment_anything/build_sam.py b/third_party/segment-anything/segment_anything/build_sam.py new file mode 100644 index 0000000000000000000000000000000000000000..051fd407762e84ce175f620c8cc7a4d1bfad3672 --- /dev/null +++ b/third_party/segment-anything/segment_anything/build_sam.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77bc4faf728118625ddd184dc4e6375bd1b5c636fc66fb429f9fc5276f331cc5 +size 2941 diff --git a/third_party/segment-anything/segment_anything/modeling/__init__.py b/third_party/segment-anything/segment_anything/modeling/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f95197587ba72df00442a3469cc580d4d6bc8d03 --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47f6363b86c0bfaa7a6abf723975136d17fae4a5f002d2814a5cce8834d18980 +size 385 diff --git a/third_party/segment-anything/segment_anything/modeling/common.py b/third_party/segment-anything/segment_anything/modeling/common.py new file mode 100644 index 0000000000000000000000000000000000000000..3a98c58d4895a6e93b27571c833510ed6e8b70e8 --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/common.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59a53bfa5d0a4d446df7f2bb57d2e95808b130601592b934600fb663d256ce17 +size 1479 diff --git a/third_party/segment-anything/segment_anything/modeling/image_encoder.py b/third_party/segment-anything/segment_anything/modeling/image_encoder.py new file mode 100644 index 0000000000000000000000000000000000000000..31a3875e69d6ff981e91f93607c2cd7cfe238e9a --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/image_encoder.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1665ada2902722c9a8cd566c840e324d623ef2b12f7d9ae9f38b24aed0e39886 +size 14420 diff --git a/third_party/segment-anything/segment_anything/modeling/mask_decoder.py b/third_party/segment-anything/segment_anything/modeling/mask_decoder.py new file mode 100644 index 0000000000000000000000000000000000000000..858543eceee5bf2887c30944ed1bd0a573f073fe --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/mask_decoder.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a2455e990515c67a061187c92c236b879b189f21ef6ebfce1627cae9a6b2f93 +size 6615 diff --git a/third_party/segment-anything/segment_anything/modeling/prompt_encoder.py b/third_party/segment-anything/segment_anything/modeling/prompt_encoder.py new file mode 100644 index 0000000000000000000000000000000000000000..d31db368ccb0b79a3364b68d4aa8b2d5fc6e18b2 --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/prompt_encoder.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd8f2f5903f0647f55c21c608bcbb334eec2901ebe76aa41061b1c513df4a06f +size 8594 diff --git a/third_party/segment-anything/segment_anything/modeling/sam.py b/third_party/segment-anything/segment_anything/modeling/sam.py new file mode 100644 index 0000000000000000000000000000000000000000..d151d0e8dab1929969edaddfedac65f3c4537270 --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/sam.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d501173b7345f6829f745a2ade240c98026f6b3237bf6cf8e9473405e86c54e +size 7226 diff --git a/third_party/segment-anything/segment_anything/modeling/transformer.py b/third_party/segment-anything/segment_anything/modeling/transformer.py new file mode 100644 index 0000000000000000000000000000000000000000..858882ca56a861d00dc8f83d88cb678182c27c38 --- /dev/null +++ b/third_party/segment-anything/segment_anything/modeling/transformer.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:566a8f6db8b608398de939548bd0f485b21752fda2bdda36900e6444ef938d11 +size 8397 diff --git a/third_party/segment-anything/segment_anything/predictor.py b/third_party/segment-anything/segment_anything/predictor.py new file mode 100644 index 0000000000000000000000000000000000000000..cb4658ea2ef6c7f37d9ed7e2bed8545541b17c9b --- /dev/null +++ b/third_party/segment-anything/segment_anything/predictor.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab66c29ac0b5b204d23997ef49d8a2476f71b596ce97e35efbf116cfc2118fce +size 11649 diff --git a/third_party/segment-anything/segment_anything/utils/__init__.py b/third_party/segment-anything/segment_anything/utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..89deec191617d36ee80ad686ee04ea7de8b3806a --- /dev/null +++ b/third_party/segment-anything/segment_anything/utils/__init__.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34bd8069c54764e7b8d73a78905dbe6467140a2f73170875128f6ca4d8cdd0aa +size 197 diff --git a/third_party/segment-anything/segment_anything/utils/amg.py b/third_party/segment-anything/segment_anything/utils/amg.py new file mode 100644 index 0000000000000000000000000000000000000000..183d06103020d005230089dc11712f4cbeac344e --- /dev/null +++ b/third_party/segment-anything/segment_anything/utils/amg.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c10f8dd63facb642ff090f61426b35b3c6c3a07e72839595cb04d74828b1d39 +size 12712 diff --git a/third_party/segment-anything/segment_anything/utils/onnx.py b/third_party/segment-anything/segment_anything/utils/onnx.py new file mode 100644 index 0000000000000000000000000000000000000000..53baf686f590766bdd4f5d18c22c048749d0fbd4 --- /dev/null +++ b/third_party/segment-anything/segment_anything/utils/onnx.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4410ac1dc9a7bb3a09827520fa08454f9b397608775e2fe4ebfb7c8dbb02666 +size 5812 diff --git a/third_party/segment-anything/segment_anything/utils/transforms.py b/third_party/segment-anything/segment_anything/utils/transforms.py new file mode 100644 index 0000000000000000000000000000000000000000..00b1248cf07de5fbe3895bc6bc03c23fd2287e5a --- /dev/null +++ b/third_party/segment-anything/segment_anything/utils/transforms.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26a649f2bca8a4a24b4d56617487a9a54c4279e559b2b813c9de38f58a60107c +size 3972 diff --git a/third_party/segment-anything/setup.cfg b/third_party/segment-anything/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..255eca118550e7d9d8e6c0d95755874282bf9031 --- /dev/null +++ b/third_party/segment-anything/setup.cfg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca25a496fbec2b44f7747d9bc64c206a0cd6a447a1452611f756a56658cc2395 +size 371 diff --git a/third_party/segment-anything/setup.py b/third_party/segment-anything/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..b63d6c390b480ea0f1e7c5413a53ba8101527bca --- /dev/null +++ b/third_party/segment-anything/setup.py @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be8672c2c99f3295d25721faa4524b314c8c08965d853e55fc42183b809d3842 +size 541 diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..90f60fdd89ad8575faafe45188bd1d968852fc67 --- /dev/null +++ b/utils/__init__.py @@ -0,0 +1 @@ +from .utils import * \ No newline at end of file diff --git a/utils/crop_for_replacing.py b/utils/crop_for_replacing.py new file mode 100644 index 0000000000000000000000000000000000000000..635b8650282bb082b9e29a1b4dee3e7063eb63fb --- /dev/null +++ b/utils/crop_for_replacing.py @@ -0,0 +1,101 @@ +import cv2 +import numpy as np +from typing import Tuple + +def resize_and_pad(image: np.ndarray, mask: np.ndarray, target_size: int = 512) -> Tuple[np.ndarray, np.ndarray]: + """ + Resizes an image and its corresponding mask to have the longer side equal to `target_size` and pads them to make them + both have the same size. The resulting image and mask have dimensions (target_size, target_size). + + Args: + image: A numpy array representing the image to resize and pad. + mask: A numpy array representing the mask to resize and pad. + target_size: An integer specifying the desired size of the longer side after resizing. + + Returns: + A tuple containing two numpy arrays - the resized and padded image and the resized and padded mask. + """ + height, width, _ = image.shape + max_dim = max(height, width) + scale = target_size / max_dim + new_height = int(height * scale) + new_width = int(width * scale) + image_resized = cv2.resize(image, (new_width, new_height), interpolation=cv2.INTER_LINEAR) + mask_resized = cv2.resize(mask, (new_width, new_height), interpolation=cv2.INTER_LINEAR) + pad_height = target_size - new_height + pad_width = target_size - new_width + top_pad = pad_height // 2 + bottom_pad = pad_height - top_pad + left_pad = pad_width // 2 + right_pad = pad_width - left_pad + image_padded = np.pad(image_resized, ((top_pad, bottom_pad), (left_pad, right_pad), (0, 0)), mode='constant') + mask_padded = np.pad(mask_resized, ((top_pad, bottom_pad), (left_pad, right_pad)), mode='constant') + return image_padded, mask_padded, (top_pad, bottom_pad, left_pad, right_pad) + +def recover_size(image_padded: np.ndarray, mask_padded: np.ndarray, orig_size: Tuple[int, int], + padding_factors: Tuple[int, int, int, int]) -> Tuple[np.ndarray, np.ndarray]: + """ + Resizes a padded and resized image and mask to the original size. + + Args: + image_padded: A numpy array representing the padded and resized image. + mask_padded: A numpy array representing the padded and resized mask. + orig_size: A tuple containing two integers - the original height and width of the image before resizing and padding. + + Returns: + A tuple containing two numpy arrays - the recovered image and the recovered mask with dimensions `orig_size`. + """ + h,w,c = image_padded.shape + top_pad, bottom_pad, left_pad, right_pad = padding_factors + image = image_padded[top_pad:h-bottom_pad, left_pad:w-right_pad, :] + mask = mask_padded[top_pad:h-bottom_pad, left_pad:w-right_pad] + image_resized = cv2.resize(image, orig_size[::-1], interpolation=cv2.INTER_LINEAR) + mask_resized = cv2.resize(mask, orig_size[::-1], interpolation=cv2.INTER_LINEAR) + return image_resized, mask_resized + + + + +if __name__ == '__main__': + + # image = cv2.imread('example/boat.jpg') + # mask = cv2.imread('example/boat_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/groceries.jpg') + # mask = cv2.imread('example/groceries_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/bridge.jpg') + # mask = cv2.imread('example/bridge_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/person_umbrella.jpg') + # mask = cv2.imread('example/person_umbrella_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/hippopotamus.jpg') + # mask = cv2.imread('example/hippopotamus_mask_1.png', cv2.IMREAD_GRAYSCALE) + image = cv2.imread('/data1/yutao/projects/IAM/Inpaint-Anything/example/fill-anything/sample5.jpeg') + mask = cv2.imread('/data1/yutao/projects/IAM/Inpaint-Anything/example/fill-anything/sample5/mask.png', cv2.IMREAD_GRAYSCALE) + print(image.shape) + print(mask.shape) + cv2.imwrite('original_image.jpg', image) + cv2.imwrite('original_mask.jpg', mask) + image_padded, mask_padded, padding_factors = resize_and_pad(image, mask) + cv2.imwrite('padded_image.png', image_padded) + cv2.imwrite('padded_mask.png', mask_padded) + print(image_padded.shape, mask_padded.shape, padding_factors) + + # ^ ------------------------------------------------------------------------------------ + # ^ Please conduct inpainting or filling here on the cropped image with the cropped mask + # ^ ------------------------------------------------------------------------------------ + + # resize and pad the image and mask + + # perform some operation on the 512x512 image and mask + # ... + + # recover the image and mask to the original size + height, width, _ = image.shape + image_resized, mask_resized = recover_size(image_padded, mask_padded, (height, width), padding_factors) + + # save the resized and recovered image and mask + cv2.imwrite('resized_and_padded_image.png', image_padded) + cv2.imwrite('resized_and_padded_mask.png', mask_padded) + cv2.imwrite('recovered_image.png', image_resized) + cv2.imwrite('recovered_mask.png', mask_resized) + + \ No newline at end of file diff --git a/utils/get_point_coor.py b/utils/get_point_coor.py new file mode 100644 index 0000000000000000000000000000000000000000..1f3c3f248f7973a46c3329fe6db9a3f8e92446c6 --- /dev/null +++ b/utils/get_point_coor.py @@ -0,0 +1,12 @@ +import cv2 + +def click_event(event, x, y, flags, param): + if event == cv2.EVENT_LBUTTONDOWN: + print("Point coordinates ({}, {})".format(x, y)) +img = cv2.imread("./example/remove-anything/dog.jpg") + +cv2.imshow("Image", img) +cv2.setMouseCallback("Image", click_event) +cv2.waitKey(0) + +cv2.destroyAllWindows() diff --git a/utils/mask_processing.py b/utils/mask_processing.py new file mode 100644 index 0000000000000000000000000000000000000000..4bab72869fd585d8a2ec805fb699ed6eb55f629b --- /dev/null +++ b/utils/mask_processing.py @@ -0,0 +1,160 @@ +import cv2 +from matplotlib import pyplot as plt +import PIL.Image as Image +import numpy as np + + +def crop_for_filling_pre(image: np.array, mask: np.array, crop_size: int = 512): + # Calculate the aspect ratio of the image + height, width = image.shape[:2] + aspect_ratio = float(width) / float(height) + + # If the shorter side is less than 512, resize the image proportionally + if min(height, width) < crop_size: + if height < width: + new_height = crop_size + new_width = int(new_height * aspect_ratio) + else: + new_width = crop_size + new_height = int(new_width / aspect_ratio) + + image = cv2.resize(image, (new_width, new_height)) + mask = cv2.resize(mask, (new_width, new_height)) + + # Find the bounding box of the mask + x, y, w, h = cv2.boundingRect(mask) + + # Update the height and width of the resized image + height, width = image.shape[:2] + + # # If the 512x512 square cannot cover the entire mask, resize the image accordingly + if w > crop_size or h > crop_size: + # padding to square at first + if height < width: + padding = width - height + image = np.pad(image, ((padding // 2, padding - padding // 2), (0, 0), (0, 0)), 'constant') + mask = np.pad(mask, ((padding // 2, padding - padding // 2), (0, 0)), 'constant') + else: + padding = height - width + image = np.pad(image, ((0, 0), (padding // 2, padding - padding // 2), (0, 0)), 'constant') + mask = np.pad(mask, ((0, 0), (padding // 2, padding - padding // 2)), 'constant') + + resize_factor = crop_size / max(w, h) + image = cv2.resize(image, (0, 0), fx=resize_factor, fy=resize_factor) + mask = cv2.resize(mask, (0, 0), fx=resize_factor, fy=resize_factor) + x, y, w, h = cv2.boundingRect(mask) + + # Calculate the crop coordinates + crop_x = min(max(x + w // 2 - crop_size // 2, 0), width - crop_size) + crop_y = min(max(y + h // 2 - crop_size // 2, 0), height - crop_size) + + # Crop the image + cropped_image = image[crop_y:crop_y + crop_size, crop_x:crop_x + crop_size] + cropped_mask = mask[crop_y:crop_y + crop_size, crop_x:crop_x + crop_size] + + return cropped_image, cropped_mask + + +def crop_for_filling_post( + image: np.array, + mask: np.array, + filled_image: np.array, + crop_size: int = 512, + ): + image_copy = image.copy() + mask_copy = mask.copy() + # Calculate the aspect ratio of the image + height, width = image.shape[:2] + height_ori, width_ori = height, width + aspect_ratio = float(width) / float(height) + + # If the shorter side is less than 512, resize the image proportionally + if min(height, width) < crop_size: + if height < width: + new_height = crop_size + new_width = int(new_height * aspect_ratio) + else: + new_width = crop_size + new_height = int(new_width / aspect_ratio) + + image = cv2.resize(image, (new_width, new_height)) + mask = cv2.resize(mask, (new_width, new_height)) + + # Find the bounding box of the mask + x, y, w, h = cv2.boundingRect(mask) + + # Update the height and width of the resized image + height, width = image.shape[:2] + + # # If the 512x512 square cannot cover the entire mask, resize the image accordingly + if w > crop_size or h > crop_size: + flag_padding = True + # padding to square at first + if height < width: + padding = width - height + image = np.pad(image, ((padding // 2, padding - padding // 2), (0, 0), (0, 0)), 'constant') + mask = np.pad(mask, ((padding // 2, padding - padding // 2), (0, 0)), 'constant') + padding_side = 'h' + else: + padding = height - width + image = np.pad(image, ((0, 0), (padding // 2, padding - padding // 2), (0, 0)), 'constant') + mask = np.pad(mask, ((0, 0), (padding // 2, padding - padding // 2)), 'constant') + padding_side = 'w' + + resize_factor = crop_size / max(w, h) + image = cv2.resize(image, (0, 0), fx=resize_factor, fy=resize_factor) + mask = cv2.resize(mask, (0, 0), fx=resize_factor, fy=resize_factor) + x, y, w, h = cv2.boundingRect(mask) + else: + flag_padding = False + + # Calculate the crop coordinates + crop_x = min(max(x + w // 2 - crop_size // 2, 0), width - crop_size) + crop_y = min(max(y + h // 2 - crop_size // 2, 0), height - crop_size) + + # Fill the image + image[crop_y:crop_y + crop_size, crop_x:crop_x + crop_size] = filled_image + if flag_padding: + image = cv2.resize(image, (0, 0), fx=1/resize_factor, fy=1/resize_factor) + if padding_side == 'h': + image = image[padding // 2:padding // 2 + height_ori, :] + else: + image = image[:, padding // 2:padding // 2 + width_ori] + + image = cv2.resize(image, (width_ori, height_ori)) + + image_copy[mask_copy==255] = image[mask_copy==255] + return image_copy + + +if __name__ == '__main__': + + # image = cv2.imread('example/boat.jpg') + # mask = cv2.imread('example/boat_mask_2.png', cv2.IMREAD_GRAYSCALE) + image = cv2.imread('./example/groceries.jpg') + mask = cv2.imread('example/groceries_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/bridge.jpg') + # mask = cv2.imread('example/bridge_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/person_umbrella.jpg') + # mask = cv2.imread('example/person_umbrella_mask_2.png', cv2.IMREAD_GRAYSCALE) + # image = cv2.imread('example/hippopotamus.jpg') + # mask = cv2.imread('example/hippopotamus_mask_1.png', cv2.IMREAD_GRAYSCALE) + + cropped_image, cropped_mask = crop_for_filling_pre(image, mask) + # ^ ------------------------------------------------------------------------------------ + # ^ Please conduct inpainting or filling here on the cropped image with the cropped mask + # ^ ------------------------------------------------------------------------------------ + + # e.g. + # cropped_image[cropped_mask==255] = 0 + cv2.imwrite('cropped_image.jpg', cropped_image) + cv2.imwrite('cropped_mask.jpg', cropped_mask) + print(cropped_image.shape) + print(cropped_mask.shape) + + image = crop_for_filling_post(image, mask, cropped_image) + cv2.imwrite('filled_image.jpg', image) + print(image.shape) + + + \ No newline at end of file diff --git a/utils/paste_object.py b/utils/paste_object.py new file mode 100644 index 0000000000000000000000000000000000000000..c4a4a040cfe5b7a9a76c40e4d0ca4a63cee51227 --- /dev/null +++ b/utils/paste_object.py @@ -0,0 +1,50 @@ +import cv2 +import numpy as np + +def paste_object(source, source_mask, target, target_coords, resize_scale=1): + assert target_coords[0] < target.shape[1] and target_coords[1] < target.shape[0] + # Find the bounding box of the source_mask + x, y, w, h = cv2.boundingRect(source_mask) + assert h < source.shape[0] and w < source.shape[1] + obj = source[y:y+h, x:x+w] + obj_msk = source_mask[y:y+h, x:x+w] + if resize_scale != 1: + obj = cv2.resize(obj, (0,0), fx=resize_scale, fy=resize_scale) + obj_msk = cv2.resize(obj_msk, (0,0), fx=resize_scale, fy=resize_scale) + _, _, w, h = cv2.boundingRect(obj_msk) + + xt = max(0, target_coords[0]-w//2) + yt = max(0, target_coords[1]-h//2) + if target_coords[0]-w//2 < 0: + obj = obj[:, w//2-target_coords[0]:] + obj_msk = obj_msk[:, w//2-target_coords[0]:] + if target_coords[0]+w//2 > target.shape[1]: + obj = obj[:, :target.shape[1]-target_coords[0]+w//2] + obj_msk = obj_msk[:, :target.shape[1]-target_coords[0]+w//2] + if target_coords[1]-h//2 < 0: + obj = obj[h//2-target_coords[1]:, :] + obj_msk = obj_msk[h//2-target_coords[1]:, :] + if target_coords[1]+h//2 > target.shape[0]: + obj = obj[:target.shape[0]-target_coords[1]+h//2, :] + obj_msk = obj_msk[:target.shape[0]-target_coords[1]+h//2, :] + _, _, w, h = cv2.boundingRect(obj_msk) + + target[yt:yt+h, xt:xt+w][obj_msk==255] = obj[obj_msk==255] + target_mask = np.zeros_like(target) + target_mask = cv2.cvtColor(target_mask, cv2.COLOR_BGR2GRAY) + target_mask[yt:yt+h, xt:xt+w][obj_msk==255] = 255 + + return target, target_mask + +if __name__ == '__main__': + source = cv2.imread('example/boat.jpg') + source_mask = cv2.imread('example/boat_mask_1.png', 0) + target = cv2.imread('example/hippopotamus.jpg') + print(source.shape, source_mask.shape, target.shape) + + target_coords = (700, 400) # (x, y) + resize_scale = 1 + target, target_mask = paste_object(source, source_mask, target, target_coords, resize_scale) + cv2.imwrite('target_pasted.png', target) + cv2.imwrite('target_mask.png', target_mask) + print(target.shape, target_mask.shape) \ No newline at end of file diff --git a/utils/utils.py b/utils/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..c93b952c0ee8d106fb6fa62050725d6bd9fb1f59 --- /dev/null +++ b/utils/utils.py @@ -0,0 +1,53 @@ +import cv2 +import numpy as np +from PIL import Image +from typing import Any, Dict, List + + +def load_img_to_array(img_p): + return np.array(Image.open(img_p)) + + +def save_array_to_img(img_arr, img_p): + Image.fromarray(img_arr.astype(np.uint8)).save(img_p) + + +def dilate_mask(mask, dilate_factor=15): + mask = mask.astype(np.uint8) + mask = cv2.dilate( + mask, + np.ones((dilate_factor, dilate_factor), np.uint8), + iterations=1 + ) + return mask + +def erode_mask(mask, dilate_factor=15): + mask = mask.astype(np.uint8) + mask = cv2.erode( + mask, + np.ones((dilate_factor, dilate_factor), np.uint8), + iterations=1 + ) + return mask + +def show_mask(ax, mask: np.ndarray, random_color=False): + mask = mask.astype(np.uint8) + if np.max(mask) == 255: + mask = mask / 255 + if random_color: + color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0) + else: + color = np.array([30 / 255, 144 / 255, 255 / 255, 0.6]) + h, w = mask.shape[-2:] + mask_img = mask.reshape(h, w, 1) * color.reshape(1, 1, -1) + ax.imshow(mask_img) + + +def show_points(ax, coords: List[List[float]], labels: List[int], size=375): + coords = np.array(coords) + labels = np.array(labels) + color_table = {0: 'red', 1: 'green'} + for label_value, color in color_table.items(): + points = coords[labels == label_value] + ax.scatter(points[:, 0], points[:, 1], color=color, marker='*', + s=size, edgecolor='white', linewidth=1.25) \ No newline at end of file diff --git a/utils/visual_mask_on_img.py b/utils/visual_mask_on_img.py new file mode 100644 index 0000000000000000000000000000000000000000..2897ee90d588d66bcf8382bcbe74b191eda91b6d --- /dev/null +++ b/utils/visual_mask_on_img.py @@ -0,0 +1,62 @@ +import cv2 +import sys +import argparse +import numpy as np +from PIL import Image +from pathlib import Path +from matplotlib import pyplot as plt +from typing import Any, Dict, List +import glob + +from utils import load_img_to_array, show_mask + + +def setup_args(parser): + parser.add_argument( + "--input_img", type=str, required=True, + help="Path to a single input img", + ) + parser.add_argument( + "--input_mask_glob", type=str, required=True, + help="Glob to input masks", + ) + parser.add_argument( + "--output_dir", type=str, required=True, + help="Output path to the directory with results.", + ) + +if __name__ == "__main__": + """Example usage: + python visual_mask_on_img.py \ + --input_img FA_demo/FA1_dog.png \ + --input_mask_glob "results/FA1_dog/mask*.png" \ + --output_dir results + """ + parser = argparse.ArgumentParser() + setup_args(parser) + args = parser.parse_args(sys.argv[1:]) + + img = load_img_to_array(args.input_img) + img_stem = Path(args.input_img).stem + + mask_ps = sorted(glob.glob(args.input_mask_glob)) + + out_dir = Path(args.output_dir) / img_stem + out_dir.mkdir(parents=True, exist_ok=True) + + for mask_p in mask_ps: + mask = load_img_to_array(mask_p) + mask = mask.astype(np.uint8) + + # path to the results + img_mask_p = out_dir / f"with_{Path(mask_p).name}" + + # save the masked image + dpi = plt.rcParams['figure.dpi'] + height, width = img.shape[:2] + plt.figure(figsize=(width/dpi/0.77, height/dpi/0.77)) + plt.imshow(img) + plt.axis('off') + show_mask(plt.gca(), mask, random_color=False) + plt.savefig(img_mask_p, bbox_inches='tight', pad_inches=0) + plt.close()