Skip to content

Commit 0d805e3

Browse files
committed
fix tensor conversion
1 parent b7cbd34 commit 0d805e3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- improve handling of long filenames and filenames during batch processing
4343
- do not set preview samples when using via api
4444
- avoid unnecessary resizes in img2img and inpaint
45+
- updated `cli/simple-txt2img.py` and `cli/simple-img2img.py` scripts
4546
- update built-in log monitor in ui, thanks @midcoastal
4647

4748
## Update for 2023-12-04

modules/processing.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,13 @@ def validate_sample(tensor):
757757
return tensor
758758
if tensor.dtype == torch.bfloat16: # numpy does not support bf16
759759
tensor = tensor.to(torch.float16)
760-
sample = tensor.detach().cpu().numpy() if isinstance(tensor, torch.Tensor) and hasattr(tensor, 'detach') else tensor.cpu().numpy()
760+
print('HERE', isinstance(tensor, np.ndarray), isinstance(tensor, torch.Tensor))
761+
if isinstance(tensor, torch.Tensor) and hasattr(tensor, 'detach'):
762+
sample = tensor.detach().cpu().numpy()
763+
elif isinstance(tensor, np.ndarray):
764+
sample = tensor
765+
else:
766+
shared.log.warning(f'Unknown sample type: {type(tensor)}')
761767
sample = 255.0 * np.moveaxis(sample, 0, 2) if shared.backend == shared.Backend.ORIGINAL else 255.0 * sample
762768
with warnings.catch_warnings(record=True) as w:
763769
cast = sample.astype(np.uint8)

0 commit comments

Comments
 (0)