jkulhanek / viewformer

ViewFormer: NeRF-free Neural Rendering from Few Images Using Transformers
MIT License
233 stars 15 forks source link

Evaluation script #10

Closed snshen closed 1 year ago

snshen commented 1 year ago

Hello! Thanks for the awesome work in this repo. I am have successfully downloaded a pertained model to run forward pass; however, when I try to use the evaluation script I run into the following error.

WARNING:absl:`0` is not a valid tf.function parameter name. Sanitizing to arg_0.
WARNING:absl:`1` is not a valid tf.function parameter name. Sanitizing to arg_1.
Traceback (most recent call last):
  File "/opt/conda/envs/vlp/bin/viewformer-cli", line 33, in <module>
    sys.exit(load_entry_point('viewformer', 'console_scripts', 'viewformer-cli')())
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 1130, in _call_
    return self.main(*args, **kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/aparse/click.py", line 104, in invoke
    return super().invoke(ctx)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/evaluate/evaluate_transformer.py", line 218, in main
    codebook_model = load_model(codebook_model)
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/utils/tensorflow.py", line 50, in load_model
    model = AutoModel.from_config(th_model.config)
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/models/__init__.py", line 35, in from_config
    return cls(config, **kwargs)
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/models/vqgan.py", line 270, in _init_
    self.perceptual_loss = lpips(net='vgg')
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/models/utils.py", line 298, in lpips
    model = load_lpips_model(net=net)
  File "/home/ec2-user/novel-cross-view-generation/viewformer/viewformer/models/utils.py", line 293, in load_lpips_model
    onnx_tf.backend.prepare(model).export_graph(f'{path}.pb')
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/onnx_tf/backend_rep.py", line 115, in export_graph
    signatures=self.tf_module.__call__.get_concrete_function(
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 1258, in get_concrete_function
    concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 1238, in _get_concrete_function_garbage_collected
    self._initialize(args, kwargs, add_initializers_to=initializers)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 763, in _initialize
    self._variable_creation_fn    # pylint: disable=protected-access
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py", line 171, in _get_concrete_function_internal_garbage_collected
    concrete_function, _ = self._maybe_define_concrete_function(args, kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py", line 166, in _maybe_define_concrete_function
    return self._maybe_define_function(args, kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py", line 396, in _maybe_define_function
    concrete_function = self._create_concrete_function(
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py", line 300, in _create_concrete_function
    func_graph_module.func_graph_from_py_func(
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 1214, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 667, in wrapped_fn
    out = weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py", line 484, in bound_method_wrapper
    return wrapped_fn(*args, **kwargs)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 1200, in autograph_handler
    raise e.ag_error_metadata.to_exception(e)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 1189, in autograph_handler
    return autograph.converted_call(
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 439, in converted_call
    result = converted_f(*effective_args, **kwargs)
  File "/tmp/__autograph_generated_filenb6tpkki.py", line 30, in tf____call__
    ag__.for_stmt(ag__.ld(self).graph_def.node, None, loop_body, get_state, set_state, (), {'iterate_names': 'node'})
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 451, in for_stmt
    for_fn(iter_, extra_test, body, get_state, set_state, symbol_names, opts)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 502, in _py_for_stmt
    body(target)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 468, in protected_body
    original_body(protected_iter)
  File "/tmp/__autograph_generated_filenb6tpkki.py", line 23, in loop_body
    output_ops = ag__.converted_call(ag__.ld(self).backend._onnx_node_to_tensorflow_op, (ag__.ld(onnx_node), ag__.ld(tensor_dict), ag__.ld(self).handlers), dict(opset=ag__.ld(self).opset, strict=ag__.ld(self).strict), fscope)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 439, in converted_call
    result = converted_f(*effective_args, **kwargs)
  File "/tmp/__autograph_generated_filerq2x04bj.py", line 50, in tf___onnx_node_to_tensorflow_op
    ag__.if_stmt(ag__.ld(handlers), if_body_1, else_body_1, get_state_1, set_state_1, ('do_return', 'retval_'), 2)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1266, in if_stmt
    _py_if_stmt(cond, body, orelse)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1319, in _py_if_stmt
    return body() if cond else orelse()
  File "/tmp/__autograph_generated_filerq2x04bj.py", line 44, in if_body_1
    ag__.if_stmt(ag__.ld(handler), if_body, else_body, get_state, set_state, ('do_return', 'retval_'), 2)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1266, in if_stmt
    _py_if_stmt(cond, body, orelse)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1319, in _py_if_stmt
    return body() if cond else orelse()
  File "/tmp/__autograph_generated_filerq2x04bj.py", line 36, in if_body
    retval_ = ag__.converted_call(ag__.ld(handler).handle, (ag__.ld(node),), dict(tensor_dict=ag__.ld(tensor_dict), strict=ag__.ld(strict)), fscope)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 439, in converted_call
    result = converted_f(*effective_args, **kwargs)
  File "/tmp/__autograph_generated_filesv6ir83a.py", line 34, in tf__handle
    ag__.if_stmt(ag__.ld(ver_handle), if_body, else_body, get_state, set_state, ('do_return', 'retval_'), 2)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1266, in if_stmt
    _py_if_stmt(cond, body, orelse)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/operators/control_flow.py", line 1319, in _py_if_stmt
    return body() if cond else orelse()
  File "/tmp/__autograph_generated_filesv6ir83a.py", line 23, in if_body
    ag__.converted_call(ag__.ld(cls).args_check, (ag__.ld(node),), dict(**ag__.ld(kwargs)), fscope)
  File "/opt/conda/envs/vlp/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 439, in converted_call
    result = converted_f(*effective_args, **kwargs)
  File "/tmp/__autograph_generated_file7c2tsg8q.py", line 8, in tf__args_check
    dtype = ag__.ld(kwargs)['tensor_dict'][ag__.ld(node).inputs[0]].dtype
tensorflow.python.autograph.pyct.error_utils.KeyError: in user code:

    File "/opt/conda/envs/vlp/lib/python3.8/site-packages/onnx_tf/backend_tf_module.py", line 98, in _call_  *
        output_ops = self.backend._onnx_node_to_tensorflow_op(onnx_node,
    File "/opt/conda/envs/vlp/lib/python3.8/site-packages/onnx_tf/backend.py", line 289, in _onnx_node_to_tensorflow_op  *
        return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
    File "/opt/conda/envs/vlp/lib/python3.8/site-packages/onnx_tf/handlers/handler.py", line 58, in handle  *
        cls.args_check(node, **kwargs)
    File "/opt/conda/envs/vlp/lib/python3.8/site-packages/onnx_tf/handlers/backend/sub.py", line 24, in args_check  *
        dtype = kwargs["tensor_dict"][node.inputs[0]].dtype

    KeyError: '0'

This issue seems similar to the one addressed in issue #6, but when I try the same hack it does not seem to patch the issue. I was wondering if you had any ideas on how to address the issue?

jkulhanek commented 1 year ago

Hi, can you please post the specific versions of python, onnx, onnx_tf, and pytorch you have installed?

jkulhanek commented 1 year ago

Can you try installing “ onnx_tf==1.7.0” and “ onnx==1.7.0”?

rachelzh9 commented 1 year ago
rachelzh9 commented 1 year ago

Update: It works if I call main() in evaluate_transformer directly, but not with the cli.

jkulhanek commented 1 year ago

Wasn’t viewformer installed to a wrong environment? Can you check by locating the cli (whereis…). I will replace the LPIPS pytorch implementation to prevent these bugs in future.

jkulhanek commented 1 year ago

Closing this now.

XinyangHan commented 12 months ago

same problem lol