ayoolaolafenwa / PixelLib

Visit PixelLib's official documentation https://pixellib.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to Inference with a custom model

JoeLan96 opened this issue · comments

Hi,
when I try to inference with a custom model using this code, error occur.

my code as follow:

`
import pixellib
from pixellib.instance import custom_segmentation

segment_image = custom_segmentation()
segment_image.inferConfig(num_classes=2, class_names=["BG", "butterfly", "squirrel"])
segment_image.load_model("./model/Nature_model_resnet101.h5")
segment_image.segmentImage("sample1.jpg", show_bboxes=True, output_image_name="sample_out.jpg")
`

error info:
Traceback (most recent call last):
File "D:/DownProjects/Pixellib/mytrain.py", line 38, in
test1()
File "D:/DownProjects/Pixellib/mytrain.py", line 35, in test1
segment_image.segmentImage("sample1.jpg", show_bboxes=True, output_image_name="sample_out.jpg")
File "D:\ProgramFiles\anaconda\envs\pixellib\lib\site-packages\pixellib\instance.py", line 565, in segmentImage
new_img = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-t9hleyt8\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Thank you!

@JoeLan96 the image you specify in the function does not exist. The error is an opencv error for an empty directory. Confirm the directory of your image.

Thank you for your reply

I'm very sorry I made such a low-level mistake.

Now, I am going to train a sample model that does not need good results to segment the QR code in the picture. I want to know how many pictures need to be labeled as a training set.

Thanks in advance