Ikomia-dev / IkomiaApi

Deploy Computer Vision solutions with a few lines of code.
https://ikomia-dev.github.io/python-api-documentation/
Apache License 2.0
224 stars 13 forks source link

import ik error #28

Open lafnac opened 6 months ago

lafnac commented 6 months ago

hi

i successfully installed ikomia using pip in a virtual env (pycharm + python 3.9). i tried to run the above code and i get many errors. First the line "from ikomia.utils import ik" prodce the following error "Cannot find reference 'ik' in 'init.py'. Other errors are listed bellow the code

from ikomia.dataprocess.workflow import Workflow from ikomia.utils import ik

wf = Workflow()

resnet = wf.add_task(ik.train_torchvision_resnet( model_name="resnet34", batch_size="16", epochs="5" ), auto_connect=True )

dataset_folder = "/home/train/"

wf.run_on(folder=dataset_folder)

/home/resnet/resnet-ikomia.py Traceback (most recent call last): File "/home/shared-env/lib/python3.9/site-packages/ikomia/core/init.py", line 19, in from ikomia.core.pycore import * ImportError: libusb-1.0.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/resnet/resnet-ikomia.py", line 1, in from ikomia.dataprocess.workflow import Workflow File "/home/shared-env/lib/python3.9/site-packages/ikomia/init.py", line 17, in from ikomia import utils File "/home/shared-env/lib/python3.9/site-packages/ikomia/utils/init.py", line 15, in from ikomia.utils import iklogger File "/home/shared-env/lib/python3.9/site-packages/ikomia/utils/iklogger.py", line 25, in from ikomia.core import config File "/home/shared-env/lib/python3.9/site-packages/ikomia/core/init.py", line 22, in from ikomia.lib.pycore import * ModuleNotFoundError: No module named 'ikomia.lib.pycore'

Process finished with exit code 1

================================================================================================

same errors with this code too

from ikomia.dataprocess.workflow import Workflow from ikomia.utils.displayIO import display

wf = Workflow()

canny = wf.add_task(name="ocv_canny", auto_connect=True)

wf.run_on(url="https://raw.githubusercontent.com/Ikomia-dev/notebooks/main/examples/img/img_work.jpg")

display(canny.get_input(0).get_image()) display(canny.get_output(0).get_image())

Environment:

any suggestion please? many thanks.

LudoBar commented 6 months ago

Hi @lafnac,

It seems that libusb-1.0.so is missing from your OS. This library is required because it's a dependency inherited from OpenCV. We try to include as many dependencies as possible, but some may be missing on some Linux distributions.

So as a first step to your issue, install the libusb-1.0: sudo apt-get install libusb-1.0-0-dev

As it could be the root cause, let me know if you still have errors then.

netpoe commented 1 month ago

Hi @lafnac,

It seems that libusb-1.0.so is missing from your OS. This library is required because it's a dependency inherited from OpenCV. We try to include as many dependencies as possible, but some may be missing on some Linux distributions.

So as a first step to your issue, install the libusb-1.0: sudo apt-get install libusb-1.0-0-dev

As it could be the root cause, let me know if you still have errors then.

On my end, Ubuntu 20+, Python 3.10, I needed to install several more libraries to run this code:

from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

# Init your workflow
wf = Workflow()

# Add the Canny Edge Detector
canny = wf.add_task(name="ocv_canny", auto_connect=True)

# Run on your image
# wf.run_on(path="path/to/your/image.png")
wf.run_on(
    url="https://raw.githubusercontent.com/Ikomia-dev/notebooks/main/examples/img/img_work.jpg"
)

# Inspect your results
display(canny.get_input(0).get_image())
display(canny.get_output(0).get_image())

These libraries were needed:

apt install libsm6
apt install libthai0
apt install libegl1-mesa-dev
apt install libharfbuzz0b
apt install libglu1-mesa-dev

Then the example ran successfully.