zkytony / cos-pomdp

Code for "Towards Optimal Correlational Object Search" | ICRA 2022
Apache License 2.0
12 stars 5 forks source link

Problems with tests #10

Open mKabouri opened 3 months ago

mKabouri commented 3 months ago

Hello, I tried to run tests for thor, but I had some errors:

For _test_optimal_search_agent, I have the following error (the same with _test_mjolnir_agent):

Traceback (most recent call last):
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/run_all.py", line 52, in <module>
    main()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/run_all.py", line 16, in main
    _test_optimal_search_agent({"FloorPlan1": ["Vase", "Book"]})
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_optimal_object_search_agent.py", line 83, in _test_optimal_search_agent
    _test_many(targets)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_optimal_object_search_agent.py", line 71, in _test_many
    all_results.append(collect(_test_singe(floorplan, target)))
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_optimal_object_search_agent.py", line 94, in _test_singe
    return trial.run(logging=True)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/trial.py", line 136, in run
    components = self.setup()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/trial.py", line 91, in setup
    agent = agent_class(controller,
TypeError: ThorObjectSearchOptimalAgent.__init__() got an unexpected keyword argument 'approx_belief'

For _test_basic_search, I have the following (the same with _test_basic_informed_search and _test_analyze_cosagent_basic_search_tree):

Traceback (most recent call last):
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/run_all.py", line 52, in <module>
    main()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/run_all.py", line 39, in main
    _test_analyze_cosagent_basic_search_tree(
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_analyze_search_tree.py", line 86, in _test_analyze_cosagent_basic_search_tree
    _test_basic_search(target, other, prior='informed',
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_cosagent_basic_search.py", line 82, in _test_basic_search
    trial.run(step_act_cb=step_act_cb,
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/trial.py", line 136, in run
    components = self.setup()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/trial.py", line 97, in setup
    agent = agent_class(self.config["task_config"],
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/agent/cospomdp_basic.py", line 282, in __init__
    super().__init__(task_config,
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/agent/cospomdp_basic.py", line 69, in __init__
    super().__init__(task_config)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/common.py", line 140, in __init__
    self._detector = ThorAgent.load_detector(task_config)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/common.py", line 190, in load_detector
    detector = YOLODetector(model_path, data_config,
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/detector.py", line 200, in __init__
    raise ValueError("Not all detectable objects are handled"
ValueError: Not all detectable objects are handledby the YOLO detector; Classes that can't be detected: {'Book'}.
YOLO can detect: ['Microwave', 'Mug', 'Spatula', 'Sink', 'Apple', 'SoapBottle', 'Cup', 'DishSponge', 'StoveBurner', 'Fork', 'SaltShaker', 'ButterKnife', 'CounterTop', 'Fridge', 'Pan', 'StoveKnob', 'Cabinet', 'SinkBasin', 'Knife', 'Floor', 'Lettuce', 'Egg', 'Spoon', 'GarbageCan', 'Faucet', 'CoffeeMachine', 'Potato', 'Bowl', 'Toaster', 'Plate', 'Tomato', 'Pot', 'Bread', 'LightSwitch', 'PepperShaker']
zkytony commented 3 months ago

Did test_vision_detector_search.py in the README work for you?

mKabouri commented 3 months ago

It doesn't work. I had the following error:

Traceback (most recent call last):
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_vision_detector_search.py", line 41, in <module>
    _test_method(Methods.V_HIERARCHICAL_CORR_CRT, "bedroom", "AlarmClock", scene="FloorPlan321")
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/tests/thor/test_vision_detector_search.py", line 37, in _test_method
    trial.run()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/trial.py", line 159, in run
    action = agent.act()
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp_apps/thor/agent/cospomdp_complete.py", line 357, in act
    goal = self.solver.plan(self.cos_agent)
  File "pomdp_py/algorithms/po_uct.pyx", line 225, in pomdp_py.algorithms.po_uct.POUCT.plan
  File "pomdp_py/algorithms/po_uct.pyx", line 233, in pomdp_py.algorithms.po_uct.POUCT.plan
  File "pomdp_py/algorithms/po_uct.pyx", line 313, in pomdp_py.algorithms.po_uct.POUCT._search
  File "pomdp_py/algorithms/po_uct.pyx", line 361, in pomdp_py.algorithms.po_uct.POUCT._simulate
  File "pomdp_py/framework/basics.pyx", line 640, in pomdp_py.framework.basics.sample_generative_model
  File "pomdp_py/framework/basics.pyx", line 693, in pomdp_py.framework.basics.sample_explict_models
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp/models/observation_model.py", line 573, in sample
    objobzs = {objid : self.zi_models[objid].sample(next_state)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp/models/observation_model.py", line 573, in <dictcomp>
    objobzs = {objid : self.zi_models[objid].sample(next_state)
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp/models/observation_model.py", line 107, in sample
    si = dist_si.sample()[self.corr_object_id]
  File "/home/mykabouri/Reinforcement_Learning/ai2thor-yolo/cos-pomdp/cospomdp/probability/tabular_dist.py", line 227, in sample
    return self.random(rnd=rnd)
  File "pomdp_py/representations/distribution/histogram.pyx", line 76, in pomdp_py.representations.distribution.histogram.Histogram.random
  File "/usr/lib/python3.10/random.py", line 535, in choices
    raise ValueError('Total of weights must be greater than zero')
ValueError: Total of weights must be greater than zero
zkytony commented 3 months ago

It's been quite a while since I last run this, so I am no longer familiar with the traceback :( Could you provide more details about your system and your steps?

According to https://github.com/zkytony/cos-pomdp/issues/5 and https://github.com/zkytony/cos-pomdp/issues/7, people have been able to get the example working. Perhaps @RajeshDM has some insight?

Also, please investigate if necessary.

RajeshDM commented 3 months ago

It's been quite a while since I last run this, so I am no longer familiar with the traceback :( Could you provide more details about your system and your steps?

According to #5 and #7, people have been able to get the example working. Perhaps @RajeshDM has some insight?

Also, please investigate if necessary.

Hi,

This is the error that occurs when using python 3.9 and above - https://github.com/zkytony/cos-pomdp/issues/8

What is happening is, in the files, there are some correlations that are all 0 and the newer version of python's random function needs something to be non-zero. So one can either use a lower version of python (anything lower than 3.9 will work) or update the random function in histogram (in pomdp-py)

mKabouri commented 3 months ago

Thank you