anopara / genetic-drawing Goto Github PK
View Code? Open in Web Editor NEWA genetic algorithm toy project for drawing
License: MIT License
A genetic algorithm toy project for drawing
License: MIT License
flake8 testing of https://github.com/anopara/genetic-drawing on Python 3.8.3
$ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
./genetic_drawing.py:51:9: F821 undefined name 'self'
self.brushesRange = ranges
^
./genetic_drawing.py:54:9: F821 undefined name 'self'
self.sampling_mask = cv2.cvtColor(cv2.imread(img_path),cv2.COLOR_BGR2GRAY)
^
./genetic_drawing.py:275:33: F821 undefined name 'rangeY'
print(" Y range: ", rangeY, 'X range: ', rangeX)
^
./genetic_drawing.py:275:54: F821 undefined name 'rangeX'
print(" Y range: ", rangeY, 'X range: ', rangeX)
^
./genetic_drawing.py:276:44: F821 undefined name 'rangeY'
print('bg coord: ', posY, posY+rangeY, posX, posX+rangeX)
^
./genetic_drawing.py:276:63: F821 undefined name 'rangeX'
print('bg coord: ', posY, posY+rangeY, posX, posX+rangeX)
^
6 F821 undefined name 'self'
6
https://flake8.pycqa.org/en/latest/user/error-codes.html
On the flake8 test selection, this PR does not focus on "style violations" (the majority of flake8 error codes that psf/black can autocorrect). Instead these tests are focus on runtime safety and correctness:
Hi, I try to change a few parameters from the provided example but it doesn't change getting exactly 140 images at the end, where is this parameter fixed? any way to change this, increase or reduce it?
thanks!
David
Any chance of adding color?
Hi, I can't run genetic drawing. The following prerequisites are installed:
opencv 4.4.0-1
python2-numpy 1.16.6-1, python-numpy 1.19.1-1
python-matplotlib 3.3.1-1
Jupyter Notebook 6.1.1-1
glib2 2.64.5-1
shortened terminal output of $ ./GeneticDrawing.ipynb
In file included from ../../../../../../../../../usr/include/glib-2.0/glib/galloca.h:32:
../../../../../../../../../usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: 'glibconfig.h' file not found
#include <glibconfig.h>
^~~~~~~~~~~~~~
...
1 error generated.
make: *** [makefile:14: nfd_gtk.o] Error 1
make: *** Waiting for unfinished jobs....
...
43 warnings generated.
Build time: 0m 4s
Compilation failed.
==> ERROR: A failure occurred in build().
Aborting...
Please help.
flake8 testing of https://github.com/anopara/genetic-drawing on Python 3.8.3
$ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
./genetic_drawing.py:275:33: F821 undefined name 'rangeY'
print(" Y range: ", rangeY, 'X range: ', rangeX)
^
./genetic_drawing.py:275:54: F821 undefined name 'rangeX'
print(" Y range: ", rangeY, 'X range: ', rangeX)
^
./genetic_drawing.py:276:44: F821 undefined name 'rangeY'
print('bg coord: ', posY, posY+rangeY, posX, posX+rangeX)
^
./genetic_drawing.py:276:63: F821 undefined name 'rangeX'
print('bg coord: ', posY, posY+rangeY, posX, posX+rangeX)
^
4 F821 undefined name 'rangeY'
4
https://flake8.pycqa.org/en/latest/user/error-codes.html
On the flake8 test selection, this PR does not focus on "style violations" (the majority of flake8 error codes that psf/black can autocorrect). Instead these tests are focus on runtime safety and correctness:
I tested this using my own image but keep on failing:
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
Hi @anopara
The program takes too long at line
out = gen.generate(100, 20)
Is there a way to reduce the processing time apart from reducing the number of iterations ?
When I try to run the code appear this error:
Any idea?
dyld: Library not loaded: /usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/Python Referenced from: /usr/local/opt/[email protected]/bin/python3.9 Reason: image not found
Hi @anopara. Thank you for sharing this awesome toy exercise. I was wondering if you or someone else could explain how the algorithm works? Despite repeated review of the code, my python fu is limited.
really love it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.