Repository: stable-diffusion-webui
Issue: [Bug]: Runtime error when using upscaling in an API request
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

When i try to use the `/sdapi/v1/txt2img` endpoint with `"enable_hr": True` SDW casts an exception at the end of generation

### Steps to reproduce the problem

Run:
```
payload = {
	"prompt": keywords,
	"negative_prompt": "lowres",
	"sampler_index": "DPM++ SDE Karras",
	"steps": 50,
	"cfg_scale": 7,
	"enable_hr": True,
	"hr_upscaler": "Latent",
	"hr_scale": 2,
	"hr_second_pass_steps": 30,
	"batch_size": 1,
	"restore_faces": True
}

response = requests.post(url=f"http://127.0.0.1:7860/sdapi/v1/txt2img", json=payload)
```

### What should have happened?

It should return the generated images in a json message

### Commit where the problem happens

Im running the latest commit 0cc0ee1

### What platforms do you use to access the UI ?

Linux

### What browsers do you use to access the UI ?

Mozilla Firefox

### Command Line Arguments

```Shell
python webui.py --xformers --listen --api
```


### List of extensions

deforum-for-automatic1111-webui
novelai-2-local-prompt
sd-civitai-browser
stable-diffusion-webui-inspiration
LDSR
Lora
ScuNET
SwinIR
prompt-bracket-checker

### Console logs

```Shell
Traceback (most recent call last):
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/streams/memory.py", line 94, in receive
    return self.receive_nowait()
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/streams/memory.py", line 89, in receive_nowait
    raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/base.py", line 77, in call_next
    message = await recv_stream.receive()
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/streams/memory.py", line 114, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/base.py", line 106, in __call__
    response = await self.dispatch_func(request, call_next)
  File "/mnt/c/stable-diffusion-webui/modules/api/api.py", line 96, in log_and_time
    res: Response = await call_next(req)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/base.py", line 80, in call_next
    raise app_exc
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/base.py", line 69, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in __call__
    await responder(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/routing.py", line 706, in __call__
    await route.handle(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/fastapi/routing.py", line 165, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/home/anon/anaconda3/envs/sdw/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/mnt/c/stable-diffusion-webui/modules/api/api.py", line 203, in text2imgapi
    processed = process_images(p)
  File "/mnt/c/stable-diffusion-webui/modules/processing.py", line 486, in process_images
    res = process_images_inner(p)
  File "/mnt/c/stable-diffusion-webui/modules/processing.py", line 632, in process_images_inner
    samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength, prompts=prompts)
  File "/mnt/c/stable-diffusion-webui/modules/processing.py", line 902, in sample
    samples = self.sampler.sample_img2img(self, samples, noise, conditioning, unconditional_conditioning, steps=self.hr_second_pass_steps or self.steps, image_conditioning=image_conditioning)
  File "/mnt/c/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 310, in sample_img2img
    noise_sampler = self.create_noise_sampler(x, sigmas, p)
  File "/mnt/c/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 282, in create_noise_sampler
    sigma_min, sigma_max = sigmas[sigmas > 0].min(), sigmas.max()
RuntimeError: min(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument.
```


### Additional information

I run this through WSL2 and have attempted to update libraries with `pip install -r requirements --upgrade` which didnt fix the problem