Git Product home page Git Product logo

genetic-drawing's People

Contributors

anopara avatar cclauss avatar nicolasap-dm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genetic-drawing's Issues

Six undefined names in genetic_drawing.py

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:

  • E9 tests are about Python syntax errors usually raised because flake8 can not build an Abstract Syntax Tree (AST). Often these issues are a sign of unused code or code that has not been ported to Python 3. These would be compile-time errors in a compiled language but in a dynamic language like Python they result in the script halting/crashing on the user.
  • F63 tests are usually about the confusion between identity and equality in Python. Use ==/!= to compare str, bytes, and int literals is the classic case. These are areas where a == b is True but a is b is False (or vice versa). Python >= 3.8 will raise SyntaxWarnings on these instances.
  • F7 tests logic errors and syntax errors in type hints
  • F82 tests are almost always undefined names which are usually a sign of a typo, missing imports, or code that has not been ported to Python 3. These also would be compile-time errors in a compiled language but in Python a NameError is raised which will halt/crash the script on the user.

Number of saved images

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

Color

Any chance of adding color?

Can't run: "GeneticDrawing.ipynb: line 78: syntax error: unexpected end of file"

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.

genetic_drawing.py: Undefined names: rangeX and rangeY

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:

  • E9 tests are about Python syntax errors usually raised because flake8 can not build an Abstract Syntax Tree (AST). Often these issues are a sign of unused code or code that has not been ported to Python 3. These would be compile-time errors in a compiled language but in a dynamic language like Python they result in the script halting/crashing on the user.
  • F63 tests are usually about the confusion between identity and equality in Python. Use ==/!= to compare str, bytes, and int literals is the classic case. These are areas where a == b is True but a is b is False (or vice versa). Python >= 3.8 will raise SyntaxWarnings on these instances.
  • F7 tests logic errors and syntax errors in type hints
  • F82 tests are almost always undefined names which are usually a sign of a typo, missing imports, or code that has not been ported to Python 3. These also would be compile-time errors in a compiled language but in Python a NameError is raised which will halt/crash the script on the user.

Error at around stage 40

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

reduce processing time

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 ?

Algorithm explanation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.