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

Error at around stage 40 #6

Open
enzyme69 opened this issue Jun 10, 2020 · 2 comments
Open

Error at around stage 40 #6

enzyme69 opened this issue Jun 10, 2020 · 2 comments

Comments

@enzyme69
Copy link

I tested this using my own image but keep on failing:
corgi

Not sure why...

Stage  45 . Generation  1 / 20
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-d878b63d593f> in <module>
      1 #load the example image and set the generator for 100 stages with 20 generations each
      2 gen = GeneticDrawing('corgi.jpg', seed=time.time())
----> 3 out = gen.generate(100, 20)

~/genetic-drawing-master/genetic_drawing.py in generate(self, stages, generations, brushstrokesCount, show_progress_imgs)
     40                 if show_progress_imgs is True:
     41                     #plt.imshow(sampling_mask, cmap='gray')
---> 42                     plt.imshow(self.myDNA.get_cached_image(), cmap='gray')
     43                     plt.show()
     44             self.imgBuffer.append(self.myDNA.get_cached_image())

/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, data, **kwargs)
   2699         filternorm=filternorm, filterrad=filterrad, imlim=imlim,
   2700         resample=resample, url=url, **({"data": data} if data is not
-> 2701         None else {}), **kwargs)
   2702     sci(__ret)
   2703     return __ret

/usr/local/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1803                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1804                         RuntimeWarning, stacklevel=2)
-> 1805             return func(ax, *args, **kwargs)
   1806 
   1807         inner.__doc__ = _add_data_doc(inner.__doc__,

/usr/local/lib/python3.7/site-packages/matplotlib/axes/_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
   5481                               resample=resample, **kwargs)
   5482 
-> 5483         im.set_data(X)
   5484         im.set_alpha(alpha)
   5485         if im.get_clip_path() is None:

/usr/local/lib/python3.7/site-packages/matplotlib/image.py in set_data(self, A)
    640         if (self._A.dtype != np.uint8 and
    641                 not np.can_cast(self._A.dtype, float, "same_kind")):
--> 642             raise TypeError("Image data cannot be converted to float")
    643 
    644         if not (self._A.ndim == 2

TypeError: Image data cannot be converted to float
@enzyme69
Copy link
Author

If I keep lower value and further proceed with smaller brush...

Screen Shot 2020-06-10 at 12 29 09 pm

@sgmoratilla
Copy link

@enzyme69 I've been playing a lot with the code and I didn't get that error. Can you trying converting the original imagen to black and white and feeding it to the algorithm instead of the coloured one?

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

2 participants