Skip to content

Commit

Permalink
[GUI] [bug] Fix "gui.set_image" not accept multi-channel scalar tenso…
Browse files Browse the repository at this point in the history
…rs (#1264)

* [GUI] [bug] Fix "gui.set_image" not accept multi-channel scalar tensors

* rev

* [skip ci] fix doc link
  • Loading branch information
archibate authored Jun 17, 2020
1 parent 762aca5 commit 2641a20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The Taichi Programming Language
:caption: Miscellaneous
:maxdepth: 3

external_libraries
extension_libraries
gui
export_results
cli_utilities
Expand Down
6 changes: 4 additions & 2 deletions python/taichi/misc/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ def set_image(self, img):
import taichi as ti

if isinstance(img, ti.Expr):
if ti.core.is_integral(img.data_type()):
# image of uint is not optimized by xxx_to_image
if ti.core.is_integral(img.data_type()) or len(img.shape()) != 2:
# Images of uint is not optimized by xxx_to_image
self.img = self.cook_image(img.to_numpy())
else:
# Type matched! We can use an optimized copy kernel.
assert img.shape(
) == self.res, "Image resolution does not match GUI resolution"
from taichi.lang.meta import tensor_to_image
Expand All @@ -94,6 +95,7 @@ def set_image(self, img):
if ti.core.is_integral(img.data_type()):
self.img = self.cook_image(img.to_numpy())
else:
# Type matched! We can use an optimized copy kernel.
assert img.shape(
) == self.res, "Image resolution does not match GUI resolution"
assert img.n in [
Expand Down

0 comments on commit 2641a20

Please sign in to comment.