eg4000 / SKU110K_CVPR19

773 stars 183 forks source link

How to use the provided model? #67

Closed RafayAK closed 4 years ago

RafayAK commented 4 years ago

Hi Eran, I tried to test out the pre-trained model that you graciously provided in #9, but I can't seem to figure out why it does not work? Following is the way I'm trying to make it work:

# import keras_retinanet
from object_detector_retinanet.keras_retinanet import models
from object_detector_retinanet.keras_retinanet.utils.image import read_image_bgr, preprocess_image, resize_image
from object_detector_retinanet.keras_retinanet.utils.visualization import draw_box, draw_caption
from object_detector_retinanet.keras_retinanet.utils.colors import label_color

# import for EM Merger and viz
from object_detector_retinanet.keras_retinanet.utils import EmMerger
from object_detector_retinanet.utils import create_folder, root_dir

# import miscellaneous modules
import matplotlib.pyplot as plt
import cv2
import os
import numpy as np
import time
# set tf backend to allow memory to grow, instead of claiming everything
import tensorflow as tf

model_path = 'iou_resnet50_csv_06.h5'
model = models.load_model(model_path, backbone_name='resnet50')

image = read_image_bgr("test.jpg")

# for filtering predictions based on score (objectness/confidence)
threshold = 0.3

# copy to draw on
draw = image.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)

# preprocess image for network
image = preprocess_image(image)
image, scale = resize_image(image)

# Run inference
boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0))
...
...

... this is where the inference fails:

boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0))
ValueError: not enough values to unpack (expected 4, got 3)

I've been looking at previously closed issues in solving this #21, #51, and #30, sadly to no avail. Any help will be much appreciated

PS: Following are my dependencies setup:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_tflow_select             2.3.0                       mkl    anaconda
absl-py                   0.9.0                    py36_0    anaconda
astor                     0.8.0                    py36_0    anaconda
attrs                     19.3.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl  
bleach                    3.1.4              pyh9f0ad1d_0    conda-forge
bzip2                     1.0.8                h7b6447c_0  
c-ares                    1.15.0            h7b6447c_1001    anaconda
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
cairo                     1.14.12              h8948797_3  
certifi                   2020.4.5.1       py36h9f0ad1d_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             py36h9f0ad1d_1001    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
ffmpeg                    4.0                  hcdf2ecd_0  
fontconfig                2.13.0               h9420a91_0  
freeglut                  3.0.0                hf484d3e_5  
freetype                  2.9.1                h8a8886c_1  
gast                      0.2.2                    py36_0    anaconda
glib                      2.63.1               h5a9c865_0  
google-pasta              0.2.0                      py_0    anaconda
graphite2                 1.3.13               h23475e2_0  
grpcio                    1.14.1           py36h9ba97e2_0    anaconda
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
h5py                      2.8.0            py36h989c5e5_3    anaconda
harfbuzz                  1.8.8                hffaf4a1_0  
hdf5                      1.10.2               hba1933b_1  
icu                       58.2                 h9c2bf20_1  
importlib-metadata        1.6.0            py36h9f0ad1d_0    conda-forge
importlib_metadata        1.6.0                         0    conda-forge
intel-openmp              2020.0                      166  
ipykernel                 5.2.1            py36h95af2a2_0    conda-forge
ipython                   7.13.0           py36h9f0ad1d_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jasper                    2.0.14               h07fcdf6_1  
jedi                      0.17.0           py36h9f0ad1d_0    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
jpeg                      9b                   h024ee3a_2  
json5                     0.9.0                      py_0    conda-forge
jsonschema                3.2.0            py36h9f0ad1d_1    conda-forge
jupyter_client            6.1.3                      py_0    conda-forge
jupyter_core              4.6.3            py36h9f0ad1d_1    conda-forge
jupyterlab                2.1.0                      py_0    conda-forge
jupyterlab_server         1.1.1                      py_0    conda-forge
keras                     2.2.4                    py36_1    conda-forge
keras-applications        1.0.8                      py_0    anaconda
keras-preprocessing       1.1.0                      py_1    anaconda
keras-resnet              0.2.0                    pypi_0    pypi
kiwisolver                1.2.0            py36hdb11119_0    conda-forge
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libglu                    9.0.0                hf484d3e_1  
libgpuarray               0.7.6             h14c3975_1003    conda-forge
liblapack                 3.8.0                    15_mkl    conda-forge
libopencv                 3.4.2                hb342d67_1  
libopus                   1.3.1                h7b6447c_0  
libpng                    1.6.37               hbc83047_0  
libprotobuf               3.11.4               hd408876_0    anaconda
libsodium                 1.0.17               h516909a_0    conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.1.0                h2733197_0  
libuuid                   1.0.3                h1bed415_2  
libvpx                    1.7.0                h439df22_0  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.9                hea5a465_1  
mako                      1.1.0                      py_0    conda-forge
markdown                  3.1.1                    py36_0    anaconda
markupsafe                1.1.1            py36h8c4c3a4_1    conda-forge
matplotlib                3.1.3                    py36_0  
matplotlib-base           3.1.3            py36hef1b27d_0  
mistune                   0.8.4           py36h8c4c3a4_1001    conda-forge
mkl                       2020.0                      166  
mkl-service               2.3.0            py36he904b0f_0  
mkl_fft                   1.0.15           py36ha843d7b_0  
mkl_random                1.1.0            py36hd6b4f25_0  
nbconvert                 5.6.1            py36h9f0ad1d_1    conda-forge
nbformat                  5.0.6                      py_0    conda-forge
ncurses                   6.2                  he6710b0_0  
notebook                  6.0.3                    py36_0    conda-forge
numpy                     1.18.1           py36h4f9e942_0  
numpy-base                1.18.1           py36hde5b4d6_1  
olefile                   0.46                       py_0    conda-forge
opencv                    3.4.2            py36h6fd60c2_1  
openssl                   1.0.2u               h516909a_0    conda-forge
opt_einsum                3.1.0                      py_0    anaconda
pandas                    1.0.3            py36h830a2c2_1    conda-forge
pandoc                    2.9.2.1                       0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.7.0              pyh9f0ad1d_0    conda-forge
pcre                      8.43                 he6710b0_0  
pexpect                   4.8.0            py36h9f0ad1d_1    conda-forge
pickleshare               0.7.5           py36h9f0ad1d_1001    conda-forge
pillow                    7.0.0            py36hb39fc2d_0  
pip                       20.0.2                   py36_1  
pixman                    0.38.0               h7b6447c_0  
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.5                      py_0    conda-forge
protobuf                  3.11.4           py36he6710b0_0    anaconda
ptyprocess                0.6.0                   py_1001    conda-forge
py-opencv                 3.4.2            py36hb342d67_1  
pygments                  2.6.1                      py_0    conda-forge
pygpu                     0.7.6           py36hc1659b7_1000    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.6.0           py36h13b7fb3_1008    conda-forge
pyrsistent                0.16.0           py36h8c4c3a4_0    conda-forge
python                    3.6.5                hc3d631a_2  
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.6                     1_cp36m    conda-forge
pytz                      2019.3                     py_0    conda-forge
pyyaml                    5.3.1            py36h8c4c3a4_0    conda-forge
pyzmq                     19.0.0           py36h9947dbf_1    conda-forge
qt                        5.6.3                h8bf5577_3  
readline                  7.0                  h7b6447c_5  
requests                  2.12.5                   py36_0    conda-forge
scipy                     1.4.1            py36h2d22cac_3    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                46.1.3                   py36_0  
sip                       4.18.1          py36hf484d3e_1000    conda-forge
six                       1.14.0                   py36_0  
sqlite                    3.31.1               h62c20be_1  
tensorboard               1.15.0             pyhb230dea_0    anaconda
tensorflow                1.15.0          mkl_py36h4920b83_0    anaconda
tensorflow-base           1.15.0          mkl_py36he1670d9_0    anaconda
tensorflow-estimator      1.15.1             pyh2649769_0    anaconda
termcolor                 1.1.0                    py36_1    anaconda
terminado                 0.8.3            py36h9f0ad1d_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
theano                    1.0.3            py36hfc679d8_1    conda-forge
tk                        8.6.8                hbc83047_0  
toolchain                 2.4.0                         0  
toolchain_c_linux-64      2.4.0                         0  
toolchain_cxx_linux-64    2.4.0                         0  
tornado                   6.0.4            py36h8c4c3a4_1    conda-forge
tqdm                      4.45.0             pyh9f0ad1d_0    conda-forge
traitlets                 4.3.3            py36h9f0ad1d_1    conda-forge
wcwidth                   0.1.9              pyh9f0ad1d_0    conda-forge
webencodings              0.5.1                    py36_1    anaconda
werkzeug                  0.16.1                     py_0    anaconda
wheel                     0.34.2                   py36_0  
wrapt                     1.12.1           py36h7b6447c_1    anaconda
xz                        5.2.5                h7b6447c_0  
yaml                      0.2.4                h516909a_0    conda-forge
zeromq                    4.3.2                he1b5a44_2    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0  
eg4000 commented 4 years ago

For test mode add "convert=True" (see file predict.py) model = models.load_model(model_path, backbone_name='resnet50',convert=True)

RafayAK commented 4 years ago

LOL! That was it!

RafayAK commented 4 years ago

...+ pands 1.0.xx and above don't work since .ix has been consistently used in EmMerger.py. Fixed that by downgrading to 0.25.xx

Thanks a lot, Eran! I'll see If I can convert this model to PyTorch for some experiments.

CodeJjang commented 4 years ago

@RafayAK Didn't you receive the following error while using the pretrained model?

cv2.error: OpenCV(4.1.0) /io/opencv/modules/imgproc/src/shapedescr.cpp:743: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'pointSetBoundingRect'

I saw the fix in #30 but it was related to the remove_redundant function and here it occurs in find_new_candidates, on the following line:

contour_bounding_rect = cv2.boundingRect(contour)
eg4000 commented 4 years ago

Hi @CodeJjang. Did you try the following change for opencv4?

   for contour_i, contour in enumerate(contours[0]):
         contour_bounding_rect = cv2.boundingRect(contour)

https://github.com/eg4000/SKU110K_code/pull/1/commits/8ceefcf0e51ab981c6c06df780bae3cd5459384f#diff-e423f29cb3fad81e3b987d4c03d26f1d

CodeJjang commented 4 years ago

@eg4000 I applied that now, the cnts.append(contours[0][0]) fix and another small fix for an old python 2 iteration.
However the EM doesn't seem to converge, I get this output:

EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
agglomerative_init Timeout - using fallback
1612 78  k<=Params.min_k or EM failed
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
EM did not converge- using fallback
...

Using your pretrained weights.

eg4000 commented 4 years ago

It might use fallback in rare cases.

RafayAK commented 4 years ago

@CodeJjang Sorry for the late reply, unfortunately, I didn't face the same problems as you. I'll see If I can attach a sample code showing the way I tested the author's model. I'll also attach my environment setup perhaps that may come in handy.

RafayAK commented 4 years ago

@CodeJjang

Setup of my Anaconda Environment

substitute ENVIRONMNET_NAME with the name you want to give to this virtual environment

conda create -n ENVIRONMNET_NAME python=3.6.5 opencv=3.4

conda activate ENVIRONMNET_NAME conda install -c anaconda tensorflow=1.15 conda install -c conda-forge keras=2.2.4 conda install -c conda-forge scipy=1.41 conda install -c conda-forge pandas=0.25.1 conda install -c conda-forge pillow conda install -c conda-forge tqdm conda install -c conda-forge matplotlib pip install keras-resnet conda install -c conda-forge jupyterlab (optional)

RafayAK commented 4 years ago

@CodeJjang https://gist.github.com/RafayAK/98988d3bbb2d1160b11a0b1d5e719da5 example of inference

gmt710 commented 4 years ago

Hi Eran, I tried to test out the pre-trained model that you graciously provided in #9, but I can't seem to figure out why it does not work? Following is the way I'm trying to make it work:

# import keras_retinanet
from object_detector_retinanet.keras_retinanet import models
from object_detector_retinanet.keras_retinanet.utils.image import read_image_bgr, preprocess_image, resize_image
from object_detector_retinanet.keras_retinanet.utils.visualization import draw_box, draw_caption
from object_detector_retinanet.keras_retinanet.utils.colors import label_color

# import for EM Merger and viz
from object_detector_retinanet.keras_retinanet.utils import EmMerger
from object_detector_retinanet.utils import create_folder, root_dir

# import miscellaneous modules
import matplotlib.pyplot as plt
import cv2
import os
import numpy as np
import time
# set tf backend to allow memory to grow, instead of claiming everything
import tensorflow as tf

model_path = 'iou_resnet50_csv_06.h5'
model = models.load_model(model_path, backbone_name='resnet50')

image = read_image_bgr("test.jpg")

# for filtering predictions based on score (objectness/confidence)
threshold = 0.3

# copy to draw on
draw = image.copy()
draw = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)

# preprocess image for network
image = preprocess_image(image)
image, scale = resize_image(image)

# Run inference
boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0))
...
...

... this is where the inference fails:

boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0))
ValueError: not enough values to unpack (expected 4, got 3)

I've been looking at previously closed issues in solving this #21, #51, and #30, sadly to no avail. Any help will be much appreciated

PS: Following are my dependencies setup:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_tflow_select             2.3.0                       mkl    anaconda
absl-py                   0.9.0                    py36_0    anaconda
astor                     0.8.0                    py36_0    anaconda
attrs                     19.3.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl  
bleach                    3.1.4              pyh9f0ad1d_0    conda-forge
bzip2                     1.0.8                h7b6447c_0  
c-ares                    1.15.0            h7b6447c_1001    anaconda
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
cairo                     1.14.12              h8948797_3  
certifi                   2020.4.5.1       py36h9f0ad1d_0    conda-forge
cycler                    0.10.0                     py_2    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             py36h9f0ad1d_1001    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
ffmpeg                    4.0                  hcdf2ecd_0  
fontconfig                2.13.0               h9420a91_0  
freeglut                  3.0.0                hf484d3e_5  
freetype                  2.9.1                h8a8886c_1  
gast                      0.2.2                    py36_0    anaconda
glib                      2.63.1               h5a9c865_0  
google-pasta              0.2.0                      py_0    anaconda
graphite2                 1.3.13               h23475e2_0  
grpcio                    1.14.1           py36h9ba97e2_0    anaconda
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
h5py                      2.8.0            py36h989c5e5_3    anaconda
harfbuzz                  1.8.8                hffaf4a1_0  
hdf5                      1.10.2               hba1933b_1  
icu                       58.2                 h9c2bf20_1  
importlib-metadata        1.6.0            py36h9f0ad1d_0    conda-forge
importlib_metadata        1.6.0                         0    conda-forge
intel-openmp              2020.0                      166  
ipykernel                 5.2.1            py36h95af2a2_0    conda-forge
ipython                   7.13.0           py36h9f0ad1d_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jasper                    2.0.14               h07fcdf6_1  
jedi                      0.17.0           py36h9f0ad1d_0    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
jpeg                      9b                   h024ee3a_2  
json5                     0.9.0                      py_0    conda-forge
jsonschema                3.2.0            py36h9f0ad1d_1    conda-forge
jupyter_client            6.1.3                      py_0    conda-forge
jupyter_core              4.6.3            py36h9f0ad1d_1    conda-forge
jupyterlab                2.1.0                      py_0    conda-forge
jupyterlab_server         1.1.1                      py_0    conda-forge
keras                     2.2.4                    py36_1    conda-forge
keras-applications        1.0.8                      py_0    anaconda
keras-preprocessing       1.1.0                      py_1    anaconda
keras-resnet              0.2.0                    pypi_0    pypi
kiwisolver                1.2.0            py36hdb11119_0    conda-forge
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libglu                    9.0.0                hf484d3e_1  
libgpuarray               0.7.6             h14c3975_1003    conda-forge
liblapack                 3.8.0                    15_mkl    conda-forge
libopencv                 3.4.2                hb342d67_1  
libopus                   1.3.1                h7b6447c_0  
libpng                    1.6.37               hbc83047_0  
libprotobuf               3.11.4               hd408876_0    anaconda
libsodium                 1.0.17               h516909a_0    conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.1.0                h2733197_0  
libuuid                   1.0.3                h1bed415_2  
libvpx                    1.7.0                h439df22_0  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.9                hea5a465_1  
mako                      1.1.0                      py_0    conda-forge
markdown                  3.1.1                    py36_0    anaconda
markupsafe                1.1.1            py36h8c4c3a4_1    conda-forge
matplotlib                3.1.3                    py36_0  
matplotlib-base           3.1.3            py36hef1b27d_0  
mistune                   0.8.4           py36h8c4c3a4_1001    conda-forge
mkl                       2020.0                      166  
mkl-service               2.3.0            py36he904b0f_0  
mkl_fft                   1.0.15           py36ha843d7b_0  
mkl_random                1.1.0            py36hd6b4f25_0  
nbconvert                 5.6.1            py36h9f0ad1d_1    conda-forge
nbformat                  5.0.6                      py_0    conda-forge
ncurses                   6.2                  he6710b0_0  
notebook                  6.0.3                    py36_0    conda-forge
numpy                     1.18.1           py36h4f9e942_0  
numpy-base                1.18.1           py36hde5b4d6_1  
olefile                   0.46                       py_0    conda-forge
opencv                    3.4.2            py36h6fd60c2_1  
openssl                   1.0.2u               h516909a_0    conda-forge
opt_einsum                3.1.0                      py_0    anaconda
pandas                    1.0.3            py36h830a2c2_1    conda-forge
pandoc                    2.9.2.1                       0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.7.0              pyh9f0ad1d_0    conda-forge
pcre                      8.43                 he6710b0_0  
pexpect                   4.8.0            py36h9f0ad1d_1    conda-forge
pickleshare               0.7.5           py36h9f0ad1d_1001    conda-forge
pillow                    7.0.0            py36hb39fc2d_0  
pip                       20.0.2                   py36_1  
pixman                    0.38.0               h7b6447c_0  
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.5                      py_0    conda-forge
protobuf                  3.11.4           py36he6710b0_0    anaconda
ptyprocess                0.6.0                   py_1001    conda-forge
py-opencv                 3.4.2            py36hb342d67_1  
pygments                  2.6.1                      py_0    conda-forge
pygpu                     0.7.6           py36hc1659b7_1000    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.6.0           py36h13b7fb3_1008    conda-forge
pyrsistent                0.16.0           py36h8c4c3a4_0    conda-forge
python                    3.6.5                hc3d631a_2  
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.6                     1_cp36m    conda-forge
pytz                      2019.3                     py_0    conda-forge
pyyaml                    5.3.1            py36h8c4c3a4_0    conda-forge
pyzmq                     19.0.0           py36h9947dbf_1    conda-forge
qt                        5.6.3                h8bf5577_3  
readline                  7.0                  h7b6447c_5  
requests                  2.12.5                   py36_0    conda-forge
scipy                     1.4.1            py36h2d22cac_3    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                46.1.3                   py36_0  
sip                       4.18.1          py36hf484d3e_1000    conda-forge
six                       1.14.0                   py36_0  
sqlite                    3.31.1               h62c20be_1  
tensorboard               1.15.0             pyhb230dea_0    anaconda
tensorflow                1.15.0          mkl_py36h4920b83_0    anaconda
tensorflow-base           1.15.0          mkl_py36he1670d9_0    anaconda
tensorflow-estimator      1.15.1             pyh2649769_0    anaconda
termcolor                 1.1.0                    py36_1    anaconda
terminado                 0.8.3            py36h9f0ad1d_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
theano                    1.0.3            py36hfc679d8_1    conda-forge
tk                        8.6.8                hbc83047_0  
toolchain                 2.4.0                         0  
toolchain_c_linux-64      2.4.0                         0  
toolchain_cxx_linux-64    2.4.0                         0  
tornado                   6.0.4            py36h8c4c3a4_1    conda-forge
tqdm                      4.45.0             pyh9f0ad1d_0    conda-forge
traitlets                 4.3.3            py36h9f0ad1d_1    conda-forge
wcwidth                   0.1.9              pyh9f0ad1d_0    conda-forge
webencodings              0.5.1                    py36_1    anaconda
werkzeug                  0.16.1                     py_0    anaconda
wheel                     0.34.2                   py36_0  
wrapt                     1.12.1           py36h7b6447c_1    anaconda
xz                        5.2.5                h7b6447c_0  
yaml                      0.2.4                h516909a_0    conda-forge
zeromq                    4.3.2                he1b5a44_2    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0  

May you need the 2nd train(train_iou.py).

RafayAK commented 4 years ago

@gmt710 this issue was not related to train_iou.py. Already solved using the author's suggestion.

gmt710 commented 4 years ago
boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0))
ValueError: not enough values to unpack (expected 4, got 3)

@RafayAK ,I met this problem too.Because I do not train the 2nd step by train_iou.py and only eval the 1st step model(train.py).

eg4000 commented 4 years ago

model = models.load_model(model_path, backbone_name='resnet50',convert=True)

malik-anhar commented 3 years ago

Hi @RafayAK thanks for opening this issue, I met the same problem when I run the model with boxes, hard_scores, labels, soft_scores = model.predict_on_batch(np.expand_dims(image, axis=0)) an error occurred ValueError: not enough values to unpack (expected 4, got 3) but it's already solved by adding convert=True while loading the model.

Then I'm trying to retrain the model with my own dataset. The training running well, but when I run prediction with my retrained model and enabling the convert by adding convert=True, but the error still happen ValueError: not enough values to unpack (expected 4, got 3)

Is there something wrong with the training?

*the retrained model can be found here