DmitryUlyanov / fast-neural-doodle

Faster neural doodle
MIT License
346 stars 51 forks source link

ValueError: Incorrect number of features. Got 4 features, expected 3 #8

Open ProGamerGov opened 6 years ago

ProGamerGov commented 6 years ago
ubuntu@ip-Address:~/fast-neural-doodle$ python get_mask_hdf5.py --n_colors=5 --style_image=Monet2.jpg --style_mask=Monet2_sem2_r.png --target_mask=MonetNew2_sem2.png
Traceback (most recent call last):
  File "get_mask_hdf5.py", line 45, in <module>
    labels_target = kmeans.predict(target_flatten.astype(float))
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py", line 889, in predict
    X = self._check_test_data(X)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py", line 800, in _check_test_data
    n_features, expected_n_features))
ValueError: Incorrect number of features. Got 4 features, expected 3
ubuntu@ip-Address:~/fast-neural-doodle$
ubuntu@ip-Address:~/fast-neural-doodle$ python get_mask_hdf5.py --n_colors=3 --style_image=Monet2.jpg --style_mask=Monet2_sem2_r.png --target_mask=MonetNew2_sem2.png
Traceback (most recent call last):
  File "get_mask_hdf5.py", line 45, in <module>
    labels_target = kmeans.predict(target_flatten.astype(float))
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py", line 889, in predict
    X = self._check_test_data(X)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/k_means_.py", line 800, in _check_test_data
    n_features, expected_n_features))
ValueError: Incorrect number of features. Got 4 features, expected 3
ubuntu@ip-Address:~/fast-neural-doodle$

There are 5 distinct color regions on my masks.

ProGamerGov commented 6 years ago

So it turns out that I needed a content image in addition to the content mask:

python get_mask_hdf5.py --n_colors=5 --style_image=data/Monet2/style.png --style_mask=data/Monet2/style_mask_fix.png --target_mask=data/Monet2/monetblank_mask.png

I added an image that was the same size as monetblank_mask.png to the Monet2 directory and named it monetblank.png. Then it worked.

ProGamerGov commented 6 years ago

That actually wasn't a fix. It's still broken.

ProGamerGov commented 6 years ago

My style and content masks have the exact same number of colors, and the exact same colors.

Here at the input images that I'm trying to use:

The Style Image:

Style Mask:

Content Mask:

ProGamerGov commented 6 years ago

@DmitryUlyanov Do you have any ideas on what is causing this odd issue, and how to resolve it?