Skip to content

IMG2IMG -> ValueError: At least one stride in the given numpy array is negative #728

@WASasquatch

Description

@WASasquatch

Describe the bug

I am getting the following error with IMG2IMG

ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().)

The help topics online all seem to suggest the same fix with copying the array to fix the memory allocation for the array, I guess.

Full stack:

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

[<ipython-input-16-45b77f776f2b>](https://localhost:8080/#) in <module>
   1398                     raise SystemExit('\33[33mExecution interrupted by user.\33[0m')
   1399                 except Exception as e:
-> 1400                     raise e
   1401                 finally:
   1402                     clean_env()

5 frames

[<ipython-input-16-45b77f776f2b>](https://localhost:8080/#) in <module>
   1373                             iteration = iteration
   1374 
-> 1375                         do_gobig(path, opts())
   1376 
   1377                         NUM_ITERS = original_num_iters

[<ipython-input-1-fff68ce1e364>](https://localhost:8080/#) in do_gobig(gobig_init, opt)
   1027         original_init = init.copy()
   1028 
-> 1029         image, result = diffuse_run()
   1030         PROMPT = start_prompt #Fix for Style Prompts and NSP
   1031 

[<ipython-input-16-45b77f776f2b>](https://localhost:8080/#) in diffuse_run()
    524                     image = pipeout["sample"][0]
    525         except BaseException as e:
--> 526             raise e
    527         finally:
    528             if pipeout and pipeout['nsfw_content_detected'][0] and ENABLE_NSFW_FILTER:

[<ipython-input-16-45b77f776f2b>](https://localhost:8080/#) in diffuse_run()
    514                 else:
    515                     with autocast("cuda"):
--> 516                         pipeout = pipe(prompt=PROMPT, negative_prompt=NEG_PROMPT, num_inference_steps=STEPS, init_image=init, strength=INIT_SCALE, guidance_scale=SCALE, generator=gen_seed)
    517                         image = pipeout["sample"][0]
    518             else:

[/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py](https://localhost:8080/#) in decorate_context(*args, **kwargs)
     25         def decorate_context(*args, **kwargs):
     26             with self.clone():
---> 27                 return func(*args, **kwargs)
     28         return cast(F, decorate_context)
     29 

[/usr/local/lib/python3.7/dist-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py](https://localhost:8080/#) in __call__(self, prompt, init_image, strength, num_inference_steps, guidance_scale, negative_prompt, eta, generator, output_type, return_dict, callback, callback_steps, **kwargs)
    308         # Some schedulers like PNDM have timesteps as arrays
    309         # It's more optimzed to move all timesteps to correct device beforehand
--> 310         timesteps_tensor = torch.tensor(self.scheduler.timesteps[t_start:], device=self.device)
    311 
    312         for i, t in enumerate(self.progress_bar(timesteps_tensor)):

ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array  with array.copy().)

Reproduction

Img2img run with negative prompts with DDIM scheduler

Logs

No response

System Info

Google Colab Env | Python 3.7 | Latest pull as of this morning (since the new merge of negative prompts broke my patches for negative prompts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions