3d-photo-inpainting icon indicating copy to clipboard operation
3d-photo-inpainting copied to clipboard

A Windows version

Open feitgemel opened this issue 3 years ago • 20 comments

Hi, This isn't an open issue.

This is a very nice project

Just want to update that I did some changes in several files and now your repo can run on Windows 10 as well (not just Linux) I forked it for a new repo.

Eran

feitgemel avatar Oct 16 '21 18:10 feitgemel

This is the link : https://github.com/feitgemel/3d-photo-inpainting

feitgemel avatar Oct 16 '21 18:10 feitgemel

Thank you for that, I'm installing your version however there's some issue with you guide, you forget the command after "Next, please download the model weight using the following command:". Also I have to install PyQt5 with the following commands:

pip install "pyqtwebengine<5.13" pip install "PyQt5<5.13"

else there's conflicts

Entretoize avatar Oct 20 '21 07:10 Entretoize

Also wget should be replaced by curl in the download.sh

Entretoize avatar Oct 20 '21 08:10 Entretoize

But I still can't run it in Windows 10:

(3DP) H:\git\3d-photo-inpainting>python main.py --config argument.yml
running on device 0
  0%|                                                                                            | 0/1 [00:00<?, ?it/s]Current Source ==>  IMG_20211002_174918
Running depth extraction at 1634718298.483715
cp: ne peut créer le fichier régulier `BoostingMonocularDepth\\inputs\\IMG_20211002_174918.jpg': No such file or directory
python: can't open file 'run.py': [Errno 2] No such file or directory
  0%|                                                                                            | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "main.py", line 54, in <module>
    run_boostmonodepth(sample['ref_img_fi'], config['src_folder'], config['depth_folder'])
  File "H:\git\3d-photo-inpainting\boostmonodepth_utils.py", line 41, in run_boostmonodepth
    depth = imageio.imread(os.path.join(BOOST_BASE, BOOST_OUTPUTS, tgt_name))
  File "H:\Programmes\miniconda3\envs\3DP\lib\site-packages\imageio\core\functions.py", line 265, in imread
    reader = read(uri, format, "i", **kwargs)
  File "H:\Programmes\miniconda3\envs\3DP\lib\site-packages\imageio\core\functions.py", line 172, in get_reader
    request = Request(uri, "r" + mode, **kwargs)
  File "H:\Programmes\miniconda3\envs\3DP\lib\site-packages\imageio\core\request.py", line 124, in __init__
    self._parse_uri(uri)
  File "H:\Programmes\miniconda3\envs\3DP\lib\site-packages\imageio\core\request.py", line 260, in _parse_uri
    raise FileNotFoundError("No such file: '%s'" % fn)
FileNotFoundError: No such file: 'H:\git\3d-photo-inpainting\BoostingMonocularDepth\outputs\IMG_20211002_174918.png'

Entretoize avatar Oct 20 '21 08:10 Entretoize

Hi, Very strange . I think you have a problem with the "direction" of the slash / instead of \

I will make a tutorial video in the next weeks

Eran

feitgemel avatar Oct 21 '21 06:10 feitgemel

I think you have a problem with the "direction" of the slash / instead of \ Not sur, it doesn't create any folder I don't have a BoostingMonocularDepth folder. I tried to run cmd as administrator and chmo 777 the whole 3d-photo-inpainting folder with no success.

Entretoize avatar Oct 21 '21 15:10 Entretoize

Hi. Have you noticed that I made this fork for Windows ?

The original repo is for Lynux.

feitgemel avatar Oct 22 '21 05:10 feitgemel

I don't understand why you ask me, yes I noticed it is the purpose of my messages, but that doesn't create any folder anyway... It's because the function copy doesn't create folder in windows, if I create the folders manualy the files are copied but that still stop trying to open 'run.py' that doesn't exit.

Entretoize avatar Oct 22 '21 07:10 Entretoize

Just found that I had to use MiDaS, I don't know what is it, but is seems to work, I'm waiting for the job to finish, it doesn't seem to use the GPU looking at the resource monitor...

Entretoize avatar Oct 22 '21 07:10 Entretoize

same problem , I use wls2 on Win11

StarDustEins avatar Dec 19 '21 13:12 StarDustEins

that's because the use of linux command by os.system in boostmonodepth_utils.py. use this to replace then it'll be fine:

import os
import shutil
import cv2
import glob
import numpy as np
import imageio
from MiDaS.MiDaS_utils import write_depth

BOOST_BASE = 'BoostingMonocularDepth'

BOOST_INPUTS = 'inputs'
BOOST_OUTPUTS = 'outputs'

def run_boostmonodepth(img_names, src_folder, depth_folder):

    if not isinstance(img_names, list):
        img_names = [img_names]

    # remove irrelevant files first
    clean_folder(os.path.join(BOOST_BASE, BOOST_INPUTS))
    clean_folder(os.path.join(BOOST_BASE, BOOST_OUTPUTS))

    tgt_names = []
    for img_name in img_names:
        base_name = os.path.basename(img_name)
        tgt_name = os.path.join(BOOST_BASE, BOOST_INPUTS, base_name)
        shutil.copy(img_name, tgt_name)

        # keep only the file name here.
        # they save all depth as .png file
        tgt_names.append(os.path.basename(tgt_name).replace('.jpg', '.png'))

    os.system(f'cd {BOOST_BASE} && python run.py --Final --data_dir {BOOST_INPUTS}/  --output_dir {BOOST_OUTPUTS} --depthNet 0')

    for i, (img_name, tgt_name) in enumerate(zip(img_names, tgt_names)):
        img = imageio.imread(img_name)
        H, W = img.shape[:2]
        scale = 640. / max(H, W)

        # resize and save depth
        target_height, target_width = int(round(H * scale)), int(round(W * scale))
        depth = imageio.imread(os.path.join(BOOST_BASE, BOOST_OUTPUTS, tgt_name))
        depth = np.array(depth).astype(np.float32)
        depth = resize_depth(depth, target_width, target_height)
        np.save(os.path.join(depth_folder, tgt_name.replace('.png', '.npy')), depth / 32768. - 1.)
        write_depth(os.path.join(depth_folder, tgt_name.replace('.png', '')), depth)

def clean_folder(folder, img_exts=['.png', '.jpg', '.npy']):
    for img_ext in img_exts:
        for file in os.listdir(folder):
            if file.endswith(img_ext):
                os.remove(os.path.join(folder, file))

def resize_depth(depth, width, height):
    """Resize numpy (or image read by imageio) depth map

    Args:
        depth (numpy): depth
        width (int): image width
        height (int): image height

    Returns:
        array: processed depth
    """
    depth = cv2.blur(depth, (3, 3))
    return cv2.resize(depth, (width, height), interpolation=cv2.INTER_AREA)

Misaka17032 avatar Dec 30 '21 01:12 Misaka17032

None of the above did work for me. The installation seems to be ok but have exactly the same Filenotfound error. No solution sofar? What was that with using Midas?

Protonumerique avatar Jul 26 '22 12:07 Protonumerique

I also had several problems running this in a Windows environment.

The most effective methods are:

  1. Run the demo version once using colab.
  2. Download weights and other necessary items as they are downloaded.
  3. Install and run libraries (pip) on the local pc (windows).
  4. boostmonodepth_utils.Change py as suggested by @Misaka17032.
  5. python main.py --config argument.yml

I successfully executed it in a Windows environment using the above method.

ghzmwhdk777 avatar Jul 27 '22 05:07 ghzmwhdk777

wget doesn't work when downloading the models in the batch file.

Jonseed avatar Nov 05 '22 20:11 Jonseed

Looks like you also have to pip install matplotlib

Jonseed avatar Nov 05 '22 20:11 Jonseed

I get a trackback with vispy:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2575: character maps to <undefined>

Jonseed avatar Nov 05 '22 20:11 Jonseed

Upgrading vispy to 0.11 and I still get the same traceback. Not sure how to fix it...

Jonseed avatar Nov 05 '22 20:11 Jonseed

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2575: character maps to Upgrading vispy to 0.11 and I still get the same traceback. Not sure how to fix it...

Ever figure this out?

Straafe avatar Apr 10 '23 22:04 Straafe

Ever figure this out?

No.

Jonseed avatar Apr 11 '23 00:04 Jonseed

Looks like I have to give up

Lifeiyu620 avatar Jan 22 '24 06:01 Lifeiyu620