<jupyter_start><jupyter_text>Installation<jupyter_code>!git clone https://github.com/NVlabs/UMR
%cd UMR
!pip install -r requirements.txt
!pip install Pillow==6.1 --upgrade
!bash install.sh<jupyter_output><empty_output><jupyter_text>Download Pre-trained Model<jupyter_code>import requests

def download(file_id, dst_path):
    URL = "https://docs.google.com/uc?export=download"
    session = requests.Session()
    response = session.get(URL, params = { 'id' : file_id }, stream = True)
    for key, value in response.cookies.items():
        if key.startswith('download_warning'):
            params = { 'id' : file_id, 'confirm' : value }
            response = session.get(URL, params = params, stream = True)
            break
    with open(dst_path, "wb") as f:
        for chunk in response.iter_content(32768):
            if chunk:
                f.write(chunk)

download('1lwZu6Rl8iL9KZBLvK4dIneB_dKMtC9uY', 'cachedir.tar.gz')
!tar xzf cachedir.tar.gz && rm cachedir.tar.gz<jupyter_output><empty_output><jupyter_text>Inference<jupyter_code>%cd /content
from IPython.display import Image
!python -m UMR.experiments.demo --model_path UMR/cachedir/snapshots/cub_net/pred_net_latest.pth --img_path UMR/demo_imgs/img1.jpg --out_path outputs
Image("outputs/pred_tex.png")<jupyter_output>[1m[32mLoaded model from UMR/cachedir/snapshots/cub_net/pred_net_latest.pth.[0m
[1m[32mRead image from UMR/demo_imgs/img1.jpg.[0m
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=383 error=11 : invalid argument
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:2539: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  "See the documentation of nn.Upsample for details.".format(mode))
[1m[32mResults saved at outputs.[0m
{'fraction_non_alphanumeric': 0.12141740489838458, 'fraction_numerical': 0.02136529442417926, 'mean_word_length': 4.485714285714286, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '460432', 'license': 'MIT', 'n_tokens_mistral': 709, 'n_tokens_neox': 678, 'n_words': 139, 'path': 'Single-view 3D Reconstruction (UMR).ipynb', 'repo_name': 'apoorvkh/notebooks', 'size': '1919'}