stevewongv / SSIS

Instance Shadow Detection with A Single-Stage Detector [SSIS & SSISv2] (CVPR 2021 Oral & TPAMI 2022)
Other
95 stars 14 forks source link

Demo not working #13

Closed ddogfoodd closed 1 year ago

ddogfoodd commented 1 year ago

Hey there, the demo is not working locally nor in colab.

Following the notebook in colab the following error message is returned:

/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py:125: UserWarning: Decorating classes is deprecated and will be disabled in future versions. You should only decorate functions or methods. To preserve the current behavior of class decoration, you can directly decorate the `__init__` method and nothing else.
  warnings.warn("Decorating classes is deprecated and will be disabled in "
[08/07 11:11:49 detectron2]: Arguments: Namespace(config_file='../configs/SSIS/MS_R_101_BiFPN_SSISv2_demo.yaml', webcam=False, video_input=None, input='./samples', output='./res/', confidence_threshold=0.1, opts=[])
WARNING [08/07 11:11:49 d2.config.compat]: Config '../configs/SSIS/MS_R_101_BiFPN_SSISv2_demo.yaml' has no VERSION. Assuming it to be compatible with latest v2.
[08/07 11:11:50 d2.checkpoint.detection_checkpoint]: [DetectionCheckpointer] Loading from ../tools/output/SSISv2_MS_R_101_bifpn_with_offset_class_maskiouv2_da_bl/model_ssisv2_final.pth ...
  0% 0/4 [00:00<?, ?it/s]/usr/local/lib/python3.10/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
double free or corruption (!prev)
/usr/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

Similarly I tried to run the demo locally following the instructions in the README (using CUDA 11.3 and torch 1.11.0 both of which should be supported according to the README) and it returns a similar error:

alemann@n02-01:~/SSIS/demo$ python3 demo.py --input ./samples/

[07/31 13:47:09 detectron2]: Arguments: Namespace(confidence_threshold=0.1, config_file='../configs/SSIS/MS_R_101_BiFPN_SSISv2_demo.yaml', input='./samples/', opts=[], output='./res/', video_input=None, webcam=False)

WARNING [07/31 13:47:09 d2.config.compat]: Config '../configs/SSIS/MS_R_101_BiFPN_SSISv2_demo.yaml' has no VERSION. Assuming it to be compatible with latest v2.

[07/31 13:47:21 d2.checkpoint.detection_checkpoint]: [DetectionCheckpointer] Loading from ../tools/output/SSISv2_MS_R_101_bifpn_with_offset_class_maskiouv2_da_bl/model_ssisv2_final.pth ...

  0%|                                                                   | 0/4 [00:00<?, ?it/s]/scratch/alemann/python/lib/python3.8/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2228.)

  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

double free or corruption (!prev)

/usr/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown

  warnings.warn('resource_tracker: There appear to be %d '

Aborted
stevewongv commented 1 year ago

It's related to a known issue in pysobatools in python 3.10. You can try this workaround: https://github.com/stevewongv/InstanceShadowDetection/issues/24#issuecomment-1668927882

ddogfoodd commented 1 year ago

The workaround did solve the error. Thank you! However I had to remove the whole SSIS dir and install and build everything again or else the build of pysobatools would fail, just a FYI if anyone stumbles across the same thing.

yudi-xiao commented 1 year ago

Hi I was try to apply this workaround on the demo Colab

I modify this code block before excuting any blocks, and the pysobatools fails on build.

!pip install git+https://github.com/facebookresearch/detectron2.git -q
!pip install scikit-image numpy kornia opencv-python-headless -q
# !pip install git+https://github.com/stevewongv/InstanceShadowDetection.git#subdirectory=PythonAPI
!pip install git+https://github.com/stevewongv/InstanceShadowDetection.git@50764eb336f3194db382054fe537956dd8449c01#subdirectory=PythonAPI
  Preparing metadata (setup.py) ... done
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.2/50.2 kB 2.1 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.5/79.5 kB 6.6 MB/s eta 0:00:00
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 154.5/154.5 kB 9.0 MB/s eta 0:00:00
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 16.7 MB/s eta 0:00:00
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.0/117.0 kB 11.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
  Building wheel for detectron2 (setup.py) ... done
  Building wheel for fvcore (setup.py) ... done
  Building wheel for antlr4-python3-runtime (setup.py) ... done
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 705.7/705.7 kB 8.0 MB/s eta 0:00:00
Collecting git+https://github.com/stevewongv/InstanceShadowDetection.git@50764eb336f3194db382054fe537956dd8449c01#subdirectory=PythonAPI
  Cloning https://github.com/stevewongv/InstanceShadowDetection.git (to revision 50764eb336f3194db382054fe537956dd8449c01) to /tmp/pip-req-build-x5fb8eb_
  Running command git clone --filter=blob:none --quiet https://github.com/stevewongv/InstanceShadowDetection.git /tmp/pip-req-build-x5fb8eb_
  Running command git rev-parse -q --verify 'sha^50764eb336f3194db382054fe537956dd8449c01'
  Running command git fetch -q https://github.com/stevewongv/InstanceShadowDetection.git 50764eb336f3194db382054fe537956dd8449c01
  Running command git checkout -q 50764eb336f3194db382054fe537956dd8449c01
  Resolved https://github.com/stevewongv/InstanceShadowDetection.git to commit 50764eb336f3194db382054fe537956dd8449c01
  Preparing metadata (setup.py) ... done
Requirement already satisfied: setuptools>=18.0 in /usr/local/lib/python3.10/dist-packages (from pysobatools==2.0) (67.7.2)
Requirement already satisfied: cython>=0.27.3 in /usr/local/lib/python3.10/dist-packages (from pysobatools==2.0) (0.29.36)
Requirement already satisfied: matplotlib>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from pysobatools==2.0) (3.7.1)
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (1.1.0)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (4.42.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (1.4.4)
Requirement already satisfied: numpy>=1.20 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (1.23.5)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (23.1)
Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (9.4.0)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.1.0->pysobatools==2.0) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib>=2.1.0->pysobatools==2.0) (1.16.0)
Building wheels for collected packages: pysobatools
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for pysobatools (setup.py) ... error
  ERROR: Failed building wheel for pysobatools
  Running setup.py clean for pysobatools
Failed to build pysobatools
ERROR: Could not build wheels for pysobatools, which is required to install pyproject.toml-based projects
ddogfoodd commented 1 year ago

Oh right, I probably should mention that I only tried this workaround on my local setup where I edited the requirement.txt file.

On Colab I just tried something similar to @yudi-xiao and got the same error. Therefore I am reopening this issue.

aviadmx commented 1 year ago

The workaround did solve the error. Thank you! However I had to remove the whole SSIS dir and install and build everything again or else the build of pysobatools would fail, just a FYI if anyone stumbles across the same thing.

Could you please specifiy what exactly you did to install pysobatools successfully? Like, step by step? Thanks! I removed SSIS, installed it again, then tried installing pysobatools from the specified commit and it still fails

aviadmx commented 1 year ago

@stevewongv Also occurs in python 3.9

ddogfoodd commented 1 year ago

@aviadmx Sure, here is what I did step-by-step. Keep in mind that it worked on my setup not in Colab.

  1. Delete everything to start from scratch.
  2. Download repo (e.g. with wget https://github.com/stevewongv/SSIS/archive/refs/heads/main.zip)
  3. (Might be skippable) Unzip repo if it was downloaded as zip, also rename it to SSIS if it was named differently
  4. cd into the repo directory
  5. Create a virtual environment (e.g. with python3 -m venv venv) and activate it
  6. Installing those as it didn't work for me withoutpip install onnx protobuf
  7. Install an appropriate Torch version (e.g. pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113 for torch 1.11.0 and CUDA 11.3, look up what you need and find the command here)
  8. Apply the workaround mentioned here by editing the requirement.txt file and replacing git+https://github.com/stevewongv/InstanceShadowDetection.git#subdirectory=PythonAPI with git+https://github.com/stevewongv/InstanceShadowDetection.git@50764eb336f3194db382054fe537956dd8449c01#subdirectory=PythonAPI
  9. Install the requirements: pip install -r requirement.txt
  10. Run setup (something like this python3 setup.py build develop -d /path/depends/on/your/setup/python3.8/site-packages/, note to change the path according to your Python installation)
  11. pip install opencv-python

That's probably it. I came across some more pip errors at some point which I just fixed by uninstalling and installing everything it showed errors for.

stevewongv commented 1 year ago

I have just fixed the demo in Colab. It was a bit strange when building the pysobatools, but I managed to fix it by using a workaround.

ddogfoodd commented 1 year ago

@stevewongv Thanks again!