Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError when executing vision deployed-models infer #38

Closed
nogayama opened this issue Apr 7, 2021 · 3 comments
Closed

ModuleNotFoundError when executing vision deployed-models infer #38

nogayama opened this issue Apr 7, 2021 · 3 comments

Comments

@nogayama
Copy link
Contributor

nogayama commented Apr 7, 2021

Symptom

import cv2 as cv fails when executing vision deployed-models infer.

Reproduce

$ pip list 
Package    Version
---------- -------
pip        21.0.1
setuptools 54.2.0
wheel      0.36.2

$ pip install requests
Collecting requests
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting chardet<5,>=3.0.2
  Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
Installing collected packages: urllib3, idna, chardet, certifi, requests
Successfully installed certifi-2020.12.5 chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.4
mbp2019:vision-tools_nogayama nogayama1$ cd ..
mbp2019:workspace nogayama1$ cd -
/Users/nogayama1/Data/project/vag/workspace/vision-tools_nogayama


$ pip install .
Obtaining file:///Users/nogayama1/Data/project/vag/workspace/vision-tools_nogayama
Requirement already satisfied: requests in /Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/lib/python3.9/site-packages (from Vision-Tools==0.2.0) (2.25.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/lib/python3.9/site-packages (from requests->Vision-Tools==0.2.0) (1.26.4)
Requirement already satisfied: idna<3,>=2.5 in /Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/lib/python3.9/site-packages (from requests->Vision-Tools==0.2.0) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/lib/python3.9/site-packages (from requests->Vision-Tools==0.2.0) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in /Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/lib/python3.9/site-packages (from requests->Vision-Tools==0.2.0) (4.0.0)
Installing collected packages: Vision-Tools
  Running setup.py develop for Vision-Tools
Successfully installed Vision-Tools


$ vision deployed-models infer /tmp/hoge.JPG 
ERROR: Unknown resource -- deployed-models

Usage:  vision [--httpdetail] [--jsonoutput] [--host=<host> | --uri=<serverUri>] [--token=<token>] [--log=<level>] [-?] <resource> [<args>...]

Where:
   --httpdetail   Causes HTTP message details to be printed to STDERR
                  This information can be useful for debugging purposes or
                  to get the syntax for use with CURL.
   --jsonoutput   Intended to ease use by scripts, all output to STDOUT is in
                  JSON format. By default output to STDOUT is more human
                  friendly
   --host         Identifies the targeted MVI server. If not
                  specified here, the VAPI_HOST environment variable is used.
                  This parameter has been deprecated. It is maintained for 
                  backward compatibility, but will be removed in a future 
                  release of the tools. 
   --uri          Identifies the base URI for the MVI server -- including the
                  '/api' "directory". If not specified, VAPI_BASE_URI
                  environment variable will be used.
   --token        The API Key token. If not specified here, the
                  VAPI_TOKEN environment variable is used.
   --log          Requests logging at the indicated level. Supported levels are
                  'error', 'warn', 'info', and 'debug'
   -?  displays this help message.

   <resource> is required and must be one of:
      categories     -- work with categories within a dataset
      datasets       -- work with datasets
      files          -- work with dataset files (images and/or videos)
      fkeys          -- work with user file metadata keys
      fmetadata      -- work with user file metadata key/value pairs
      object-tags    -- work with object detection tags 
      object-labels  -- work with object detection labels (aka annotations)
      dltasks        -- work with DL training tasks
      trained-models -- work with trained models
      deployed-models -- work with deployed models
      projects       -- work with projects
      users          -- work with users

'vision' provides access to Maximo Visual Inspection resources via the ReST API.
Use 'vision <resource> --help' for more information about operating on a given resource
Traceback (most recent call last):
  File "/Users/nogayama1/.pyenv/versions/3.9.1_vision_tool2/bin/vision", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/Users/nogayama1/Data/project/vag/workspace/vision-tools_nogayama/cli/vision", line 108, in <module>
    raise err
  File "/Users/nogayama1/Data/project/vag/workspace/vision-tools_nogayama/cli/vision", line 103, in <module>
    pkg = importlib.import_module(f"vapi_cli.{resource}", package=None)
  File "/Users/nogayama1/.pyenv/versions/3.9.1/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/nogayama1/Data/project/vag/workspace/vision-tools_nogayama/lib/vapi_cli/deployed-models.py", line 23, in <module>
    import cv2 as cv
ModuleNotFoundError: No module named 'cv2'


@nogayama
Copy link
Contributor Author

nogayama commented Apr 7, 2021

pip install opencv-python fixes this problem.

$ pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-4.5.1.48-cp39-cp39-macosx_10_13_x86_64.whl (40.3 MB)
Collecting numpy>=1.19.3
  Downloading numpy-1.20.2-cp39-cp39-macosx_10_9_x86_64.whl (16.1 MB)
     |████████████████████████████████| 16.1 MB 2.7 MB/s 
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.20.2 opencv-python-4.5.1.48


mbp2019:vision-tools_nogayama nogayama1$ vision deployed-models infer /tmp/hoge.JPG  --modelid=e1a90034-7fa0-469a-b81e-9e7b6f6fc082
{
  "webAPIId": "e1a90034-7fa0-469a-b81e-9e7b6f6fc082",
  "imageUrl": "http://vision-ny-service:9080/vision-ny-api/uploads/temp/e1a90034-7fa0-469a-b81e-9e7b6f6fc082/cdee6576-fcc7-4b19-b4ef-17cc212081df.JPG",
  "imageMd5": "69afa2d1c283a303413d8a43fe945665",
  "classified": [
    {
      "confidence": 0.9999998807907104,
      "ymax": 2993,
      "label": "human",
      "xmax": 1494,
      "xmin": 634,
      "ymin": 472
    },
    {
      "confidence": 0.9999139308929443,
      "ymax": 1394,
      "label": "neck_strap",
      "xmax": 1127,
      "xmin": 898,
      "ymin": 901
    },
    {
      "confidence": 0.9999920129776001,
      "ymax": 1579,
      "label": "ID_card",
      "xmax": 1047,
      "xmin": 948,
      "ymin": 1390
    }
  ],
  "result": "success"
}

nogayama added a commit to nogayama/vision-tools that referenced this issue Apr 7, 2021
Signed-off-by: nogayama <NOGAYAMA@jp.ibm.com>
@nogayama
Copy link
Contributor Author

nogayama commented Apr 7, 2021

I have fixed this on a pull request #39

bcarld pushed a commit that referenced this issue Apr 13, 2021
Signed-off-by: nogayama <NOGAYAMA@jp.ibm.com>
@nogayama
Copy link
Contributor Author

@bcarld Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant