deepdreamer icon indicating copy to clipboard operation
deepdreamer copied to clipboard

Numpy update might have broken the gif making command

Open kboruff opened this issue 7 years ago • 3 comments

Using the gif argument now returns "Error: only integer scalar arrays can be converted to a scalar index"

This might be something to do with how Numpy is handling np.float32 now.

kboruff avatar Apr 23 '17 23:04 kboruff

The error is on this line. Has anyone found any workarounds for this? I tried adding [0] to each of the slices, but that created a .gif that was not viewable for me.

nickbclifford avatar Nov 03 '17 02:11 nickbclifford

@kboruff @nickbclifford @kesara A fix for that lifted from https://github.com/lucyking/images2gif-Pillow/blob/master/images2gif/images2gif.py

@@ -340,17 +338,17 @@ class GifWriter:
             Y = np.argwhere(diff.sum(1))
             # Get rect coordinates
             if X.size and Y.size:
-                x0, x1 = X[0], X[-1] + 1
-                y0, y1 = Y[0], Y[-1] + 1
+                x0, x1 = int(X[0]), int(X[-1] + 1)
+                y0, y1 = int(Y[0]), int(Y[-1] + 1)
             else:  # No change ... make it minimal
                 x0, x1 = 0, 2
                 y0, y1 = 0, 2

This deals with the scalar integer error, but then I got a new error.

Creating gif...
Error: a bytes-like object is required, not 'str'

Don't know what causes that one.

Benitoite avatar Mar 02 '18 00:03 Benitoite

For anyone else who finds this while troubleshooting: my quick-and-dirty solution was just to do away with images2gif entirely, and use Pillow to make the gifs. Large filesizes, but it works. You can check out my fork for details (and other improvements like progress bars).

uajqq avatar Nov 28 '20 23:11 uajqq