Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image = rgb.numpy()[0].transpose((1, 2, 0))报错 #8

Open
CaoJupeng opened this issue Apr 24, 2022 · 16 comments
Open

image = rgb.numpy()[0].transpose((1, 2, 0))报错 #8

CaoJupeng opened this issue Apr 24, 2022 · 16 comments

Comments

@CaoJupeng
Copy link

RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.numpy)).

Types of your inputs are:
self = Var,
args = (),

The function declarations are:
ArrayArgs fetch_sync()
请问这是什么意思

@Jittor
Copy link
Owner

Jittor commented Apr 24, 2022 via email

@CaoJupeng
Copy link
Author

CaoJupeng commented Apr 24, 2022 via email

@CaoJupeng
Copy link
Author

这是在做jrender中demo中都会运行处的错误

@Jittor
Copy link
Owner

Jittor commented Apr 24, 2022 via email

@CaoJupeng
Copy link
Author

CaoJupeng commented Apr 24, 2022 via email

@CaoJupeng
Copy link
Author

CaoJupeng commented Apr 24, 2022

 0%|          | 0/90 [00:00<?, ?it/s]
Drawing rotation:   0%|          | 0/90 [00:00<?, ?it/s]
Traceback (most recent call last):

  File "D:\semester\insemester_plan\4sophomore\学习资料\B样条神经网络生成曲面\可微渲染\基础教程jittor\jrender-main\demo1-render.py", line 115, in <module>
    main()

  File "D:\semester\insemester_plan\4sophomore\学习资料\B样条神经网络生成曲面\可微渲染\基础教程jittor\jrender-main\demo1-render.py", line 65, in main
    image = rgb.numpy()[0].transpose((1, 2, 0))

RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.numpy)).

Types of your inputs are:
 self	= Var,
 args	= (),

The function declarations are:
 ArrayArgs fetch_sync()

Failed reason:[f 0424 15:45:55.716000 76 op.cc:151] Check failed: flags.get(NodeFlags::_cpu)  Something wrong... Could you please report this issue?
 Op code doesn't have cpu version
--------------
# 思路:
# 从目录data中的obj读取得到mesh--
# 通过renderer将mesh渲染得到纹理obj
# 保存几个文件-做关闭
import jittor as jt
import jrender as jr
jt.flags.use_cuda = 0
# jt.flags.use_cuda((int)1)
# jittor_core.flags.use_cuda(1)
import os
import tqdm
import numpy as np
import imageio
import argparse

current_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(current_dir, 'data')#相当于设定了data—_dird的相对地址

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-i', '--filename-input', type=str, 
        default=os.path.join(data_dir, 'obj/spot/spot_triangulated.obj'))
    parser.add_argument('-o', '--output-dir', type=str, 
        default=os.path.join(data_dir, 'results/output_render'))#
    args = parser.parse_args()

    # other settings
    camera_distance = 2.732
    elevation = 30
    azimuth = 0

    # load from Wavefront .obj file
    mesh = jr.Mesh.from_obj(args.filename_input, load_texture=True, texture_res=5, texture_type='surface', dr_type='softras')#SoftRas 是目前主流三角网格可微渲染器之一。
    # print("mesh:")
    # print(mesh)
    # print("batchsize:")
    # print(mesh.batch_size)
    
    # create renderer with SoftRas
    renderer = jr.Renderer(dr_type='softras')
    # print(renderer)
    os.makedirs(args.output_dir, exist_ok=True)
    # print("output_dir")
    # print(args.output_dir)
    # print("data_dir")
    # print(data_dir)
    
    
    
    
    
    # draw object from different view


    loop = tqdm.tqdm(list(range(0, 360, 4)))
    writer = imageio.get_writer(os.path.join(args.output_dir, 'rotation.gif'), mode='I')
    imgs = []
    from PIL import Image
    for num, azimuth in enumerate(loop):
   # rest mesh to initial state
       mesh.reset_()
       loop.set_description('Drawing rotation')
       renderer.transform.set_eyes_from_angles(camera_distance, elevation, azimuth)
       rgb = renderer.render_mesh(mesh, mode='rgb')
       image = rgb.numpy()[0].transpose((1, 2, 0))
       # image = rgb.numpy()[0]
       # writer.append_data((255*image).astype(np.uint8))
    writer.close()
    
    
    # # draw object from different view
    # loop = tqdm.tqdm(list(range(0, 360, 4)))
    # writer = imageio.get_writer(os.path.join(args.output_dir, 'rotation.gif'), mode='I')#输出等价于写操作#这种文件输出的使用留点印象
    # imgs = []
    # # from PIL import Image
    # for num, azimuth in enumerate(loop):
    #     # rest mesh to initial state
    #     mesh.reset_()
    #     loop.set_description('Drawing rotation')
    #     renderer.transform.set_eyes_from_angles(camera_distance, elevation, azimuth)
    #     rgb = renderer.render_mesh(mesh, mode='rgb')
    #     # print("datatype:")
    #     print(rgb.dtype)
    #     # print(rgb,rgb.shape)
    #     # rgb.numpy()[0].transpose(1,2,0)
    #     # print(rgb)
    #     # rgb = renderer.render_mesh(mesh, mode='silhouettes') # or mode = 'rgb'
    #     # print(rgb)
    #     # image = rgb.numpy()[0].transpose((1, 2, 0))
    #     # writer.append_data((255*image).astype(np.uint8))
    # writer.close()

    # draw object from different sigma and gamma
    loop = tqdm.tqdm(list(np.arange(-4, -2, 0.2)))
    renderer.transform.set_eyes_from_angles(camera_distance, elevation, 45)
    writer = imageio.get_writer(os.path.join(args.output_dir, 'bluring.gif'), mode='I')
    for num, gamma_pow in enumerate(loop):
        # rest mesh to initial state
        mesh.reset_()
        renderer.set_gamma(10**gamma_pow)
        renderer.set_sigma(10**(gamma_pow - 1))
        loop.set_description('Drawing blurring')
        images = renderer.render_mesh(mesh, mode='rgb')
        # print(images)
        # print(images.numpy().size)
        # image = images.numpy()[0].transpose((1, 2, 0))  # [image_size, image_size, RGB]
        # writer.append_data((255*image).astype(np.uint8))
    writer.close()

    # # save to textured obj
    # mesh.reset_()
    # mesh.save_obj(os.path.join(args.output_dir, 'saved_spot.obj'))

if __name__ == '__main__':
    main()

@CaoJupeng
Copy link
Author

windowspip直接下载的,现在照论坛更新 为jittor1.3.3.10,测试通过了安装教程里的数据,但是运行渲染的demo,出现了更多问题,显示缺少模块?

File "D:\可微渲染\基础教程jittor\jrender-main\demo1-render.py", line 115, in
main()

File "D:\可微渲染\基础教程jittor\jrender-main\demo1-render.py", line 64, in main
rgb = renderer.render_mesh(mesh, mode='rgb')

File "D:\可微渲染\基础教程jittor\jrender-main\jrender\renderer\renderer.py", line 64, in render_mesh
mesh = self.lighting(mesh, self.transform.eyes)

File "D:\anaconda\lib\site-packages\jittor_init_.py", line 864, in call
return self.execute(*args, **kw)

File "D:\可微渲染\基础教程jittor\jrender-main\jrender\renderer\lighting\lighting.py", line 108, in execute
[diffuseLight, specularLight] = directional(diffuseLight, specularLight, mesh.surface_normals, (jt.sum(mesh.face_vertices, dim=2) / 3.0), eyes, mesh.with_specular, mesh.metallic_textures, mesh.roughness_textures)

File "D:\anaconda\lib\site-packages\jittor_init_.py", line 864, in call
return self.execute(*args, **kw)

File "D:\可微渲染\基础教程jittor\jrender-main\jrender\renderer\lighting\lighting.py", line 75, in execute
return directional_lighting(diffuseLight, specularLight, normals,

File "D:\可微渲染\基础教程jittor\jrender-main\jrender\renderer\lighting\directional_lighting.py", line 48, in directional_lighting
cosine = nn.relu(jt.sum(normals * light_direction, dim=2))

File "D:\anaconda\lib\site-packages\jittor\nn.py", line 177, in relu
return jt.ternary_out_hint(cond, x, 0.0)

AttributeError: module 'jittor' has no attribute 'ternary_out_hint'

@CaoJupeng
Copy link
Author

运行demo1.render目前的报错是这样的
拜托找找问题

image = rgb.numpy()[0].transpose((1, 2, 0))

RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.numpy)).

Types of your inputs are:
self = Var,
args = (),

The function declarations are:
ArrayArgs fetch_sync()

Failed reason:[f 0425 23:57:01.686000 20 op.cc:165] Check failed: flags.get(NodeFlags::_cpu) Something wrong... Could you please report this issue?
Op code doesn't have cpu version

@Jittor
Copy link
Owner

Jittor commented Apr 26, 2022

收到,谢谢您的反馈,您试试删除cache:rm -rf ~/.cache/jittor,然后更新一下jittor: python3.x -m pip install jittor -U.
另外,demo1 需要有gpu的环境才可以运行,否则会报错Op code doesn't have cpu version

@CaoJupeng
Copy link
Author

CaoJupeng commented Apr 26, 2022 via email

@Jittor
Copy link
Owner

Jittor commented Apr 26, 2022

demo1 目前是需要N卡环境的,其他设备我们正在适配当中

@CaoJupeng
Copy link
Author

CaoJupeng commented Apr 26, 2022 via email

@CaoJupeng
Copy link
Author

D:\python\jrender_main\jrender-main\data\obj/spot/spot_triangulated.obj

0%| | 0/90 [00:00<?, ?it/s]
Drawing rotation: 0%| | 0/90 [00:00<?, ?it/s]
Drawing rotation: 0%| | 0/90 [00:39<?, ?it/s]
Traceback (most recent call last):
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python310\lib\idlelib\run.py", line 578, in runcode
exec(code, self.locals)
File "D:\python\jrender_main\jrender-main\demo1-render.py", line 69, in
main()
File "D:\python\jrender_main\jrender-main\demo1-render.py", line 45, in main
image = rgb.numpy()[0].transpose((1, 2, 0))
RuntimeError: Wrong inputs arguments, Please refer to examples(help(jt.numpy)).

Types of your inputs are:
self = Var,
args = (),

The function declarations are:
ArrayArgs fetch_sync()

Failed reason:[f 0426 22:30:28.582000 08 parallel_compiler.cc:329] Error happend during compilation:
[Error] source file location:C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default\cu11.2.67\jit_opkey0_array_T_float32__o_0___opkey1_array_T_float32__o_0___opkey2_array_T_float32__o_3f8___hash_371610aa57c86386_op.cc
Compile fused operator(42/54)failed:[Op(0000029D6D82BC20:0:0:1:i0:o1:s0,array->0000029D7E93ED10),Op(0000029D6D82CC70:0:1:1:i0:o1:s0,array->0000029D7E940110),Op(0000029D6D82D840:0:1:1:i0:o1:s0,array->0000029D7E93E630),Op(0000029D6D82C7F0:0:0:1:i0:o1:s0,array->0000029D7E93FE90),Op(0000029D7E93E9F0:0:0:1:i1:o1:s0,broadcast_to->0000029D7E93F710),Op(0000029D7E93F7B0:0:1:1:i1:o1:s0,broadcast_to->0000029D7E93F030),Op(0000029D7E93DB90:0:1:1:i1:o1:s0,broadcast_to->0000029D7E93E1D0),Op(0000029D7E93E270:0:0:1:i1:o1:s0,broadcast_to->0000029D7E93EBD0),Op(0000029D6F39E150:1:0:1:i2:o1:s0,binary.greater->0000029D7E93FCB0),Op(0000029D6D82CB50:1:1:2:i3:o1:s0,ternary->0000029D7E93F2B0),Op(0000029D6F39FB50:1:1:2:i2:o1:s0,binary.subtract->0000029D7E9402F0),Op(0000029D6F39EFD0:1:1:2:i2:o1:s0,binary.pow->0000029D7E93F210),]

Reason: [f 0426 22:30:28.572000 08 log.cc:608] Check failed ret(255) == 0(0) Run cmd failed: "C:\Users\lenovo.cache\jittor\jtcuda\cuda11.2_cudnn8_win\bin\nvcc.exe" "C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default\cu11.2.67\jit_opkey0_array_T_float32__o_0___opkey1_array_T_float32__o_0___opkey2_array_T_float32__o_3f8___hash_371610aa57c86386_op.cc" -shared -L"c:\users\lenovo\appdata\local\programs\python\python310\libs" -lpython310 -Xcompiler -EHa -Xcompiler -MD -Xcompiler -utf-8 -I"C:\Users\lenovo.cache\jittor\msvc\VC\include" -I"C:\Users\lenovo.cache\jittor\msvc\win10_kits\include\ucrt" -I"C:\Users\lenovo.cache\jittor\msvc\win10_kits\include\shared" -I"C:\Users\lenovo.cache\jittor\msvc\win10_kits\include\um" -DNOMINMAX -L"C:\Users\lenovo.cache\jittor\msvc\VC\lib" -L"C:\Users\lenovo.cache\jittor\msvc\win10_kits\lib\um\x64" -L"C:\Users\lenovo.cache\jittor\msvc\win10_kits\lib\ucrt\x64" -I"c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages\jittor\src" -I"c:\users\lenovo\appdata\local\programs\python\python310\include" -DHAS_CUDA -DIS_CUDA -I"C:\Users\lenovo.cache\jittor\jtcuda\cuda11.2_cudnn8_win\include" -I"c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages\jittor\extern\cuda\inc" -lcudart -L"C:\Users\lenovo.cache\jittor\jtcuda\cuda11.2_cudnn8_win\lib\x64" -L"C:\Users\lenovo.cache\jittor\jtcuda\cuda11.2_cudnn8_win\bin" -I"C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default\cu11.2.67" -L"C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default\cu11.2.67" -L"C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default" -l"jit_utils_core.cp310-win_amd64" -l"jittor_core.cp310-win_amd64" -x cu --cudart=shared -ccbin="C:\Users\lenovo.cache\jittor\msvc\VC_____\bin\cl.exe" --use_fast_math -w -I"c:\users\lenovo\appdata\local\programs\python\python310\lib\site-packages\jittor\extern/cuda/inc" -arch=compute_61 -code=sm_61 -o "C:\Users\lenovo.cache\jittor\jt1.3.2\cl\py3.10.4\Windows-10-10.x3b\11thGenIntelRCx42\default\cu11.2.67\jit_opkey0_array_T_float32__o_0___opkey1_array_T_float32__o_0___opkey2_array_T_float32__o_3f8___hash_371610aa57c86386_op.dll" -Xlinker -EXPORT:"?jit_run@FusedOp@jittor@@QEAAXXZ"

换n卡之后的结果
Y6OE}2T`~WBHQHSEOEXUVOC

@CaoJupeng
Copy link
Author

是没有设置c++编译器的原因吗,我用pip在windows上装的

@Jittor
Copy link
Owner

Jittor commented Apr 26, 2022 via email

@CaoJupeng
Copy link
Author

CaoJupeng commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants