dave-epstein / blobgan

Official PyTorch implementation of BlobGAN: Spatially Disentangled Scene Representations
BSD 2-Clause "Simplified" License
172 stars 12 forks source link

Colab Interactively edit scenes error (indices should be either on cpu or on the same device as the indexed tensor (cpu)) #12

Open kevinzhao81 opened 1 year ago

kevinzhao81 commented 1 year ago

Hi Dr. Epstein,

Thank you for this great work and published codes.

I tried to manipulate blobs using your BlobGAN Playground Colab (Last cell: Interactively edit scenes). I also ran the code on the server.

They both gave the same error message

RuntimeError Traceback (most recent call last)

in () 35 layout, orig_img = model.gen(z=z, truncate=truncate, layout=layout, **render_kwargs) 36 orig_blobs = for_canvas(layout['feature_img'].mul(255)) ---> 37 labeled_blobs, labeled_blobs_img = draw_labels(orig_blobs, layout, size_threshold, COLORS) 38 39 blobs = DraggableBlobMap(locals()) /content/blobgan/./src/utils/colab.py in draw_labels(img, layout, T, colors, layout_i) 88 # draw = ImageDraw.Draw(img) 89 # mask = layout['sizes'][layout_i, 1:] > T ---> 90 # idmap = torch.arange(len(mask))[mask] 91 # blob = {k: layout[k][layout_i][mask].mul(255).tolist() for k in ('xs', 'ys')} 92 # for i, (x, y) in enumerate(zip(blob['xs'], blob['ys'])): RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu) I searched online and no solutions work for me. Could you please tell me how to solve this for manipulating blobs and generating the corresponding images? I appreciate any help from you.
limeng-1234 commented 1 year ago

I have encountered the same issue. Do you have a solution for it?