zkytony / cos-pomdp

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

Experiments reproduction #19

Open mKabouri opened 1 month ago

mKabouri commented 1 month ago

Hi,

I am trying to reproduce the results from the cos-pomdp experiments, specifically tables 1 and 2 from the paper. Here's the process I followed:

  1. I went to experiments/thor.

  2. I ran python collect_correlation_info.py followed by python experiment_thor.py. This generated the ExperimentThor-... folder in results folder.

  3. I trained yolov5 using the provided data.

  4. I returned to the ExperimentThor-... directory and executed the script ./run_kitchen-FloorPlan21_0.sh (I assume I need to run all the scripts and then use python gather_results.py to reproduce the tables ?).

However, when running the script, I encountered the following error, which seems to originate from pomdp_py:

Traceback (most recent call last):
  File "/home/mykabouri/Desktop/cos-pomdp/results/ExperimentThor-017_20240812233900674/trial_runner.py", line 53, in <module>
    main()
  File "/home/mykabouri/Desktop/cos-pomdp/results/ExperimentThor-017_20240812233900674/trial_runner.py", line 28, in main
    results = trial.run(logging=args.logging)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/trial.py", line 138, in run
    action = agent.act()
  File "/home/mykabouri/Desktop/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 249, in pomdp_py.algorithms.po_uct.POUCT.plan
  File "pomdp_py/algorithms/po_uct.pyx", line 261, in pomdp_py.algorithms.po_uct.POUCT.plan
  File "pomdp_py/algorithms/po_uct.pyx", line 327, in pomdp_py.algorithms.po_uct.POUCT._search
  File "pomdp_py/algorithms/po_uct.pyx", line 342, in pomdp_py.algorithms.po_uct.POUCT._perform_simulation
  File "pomdp_py/algorithms/po_uct.pyx", line 376, in pomdp_py.algorithms.po_uct.POUCT._simulate
  File "pomdp_py/algorithms/po_uct.pyx", line 409, in pomdp_py.algorithms.po_uct.POUCT._rollout
  File "pomdp_py/framework/basics.pyx", line 666, in pomdp_py.framework.basics.sample_generative_model
  File "pomdp_py/framework/basics.pyx", line 719, in pomdp_py.framework.basics.sample_explict_models
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp/models/observation_model.py", line 572, in sample
    objobzs = {objid : self.zi_models[objid].sample(next_state)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp/models/observation_model.py", line 572, in <dictcomp>
    objobzs = {objid : self.zi_models[objid].sample(next_state)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp/models/observation_model.py", line 106, in sample
    si = dist_si.sample()[self.corr_object_id]
  File "/home/mykabouri/Desktop/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

Thank you!

RajeshDM commented 1 month ago

Hi,

I encountered the same issue. This issue occurs if you use Python 3.9 or above. It will not happen if you change your version to Python 3.8 or below.

mKabouri commented 1 week ago

Hi,

After switching to Python 3.8, the initial problem was resolved, but I encountered a new issue. When I ran ./run_kitchen-FloorPlan21_0.sh, I received the error below.

When investigating, I found that the bounding box output has an area of 0, meaning the (x1, y1) and (x2, y2) coordinates of the bounding box have the same values. As a result, in thortils.vision.projection.thor_project_bbox(...), the length of positions is 0. Have you encountered this issue before ?

Traceback (most recent call last):
  File "trial_runner.py", line 54, in <module>
    main()
  File "trial_runner.py", line 29, in main
    results = trial.run(logging=args.logging)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/trial.py", line 159, in run
    observation, reward = task_env.execute(agent, action)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/common.py", line 83, in execute
    observation = self.get_observation(event, action, detector=agent.detector)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/object_search.py", line 211, in get_observation
    detections = detector.detect_project(img, event.depth_frame,
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/detector.py", line 264, in detect_project
    thor_points = pj.thor_project_bbox(
  File "/home/mykabouri/Desktop/cos-pomdp/venv/cosp/lib/python3.8/site-packages/thortils/vision/projection.py", line 302, in thor_project_bbox
    sampled_positions = positions[np.random.choice(len(positions), num_points)]
  File "mtrand.pyx", line 928, in numpy.random.mtrand.RandomState.choice
ValueError: a must be greater than 0 unless no samples are taken
RajeshDM commented 1 week ago

Hi,

After switching to Python 3.8, the initial problem was resolved, but I encountered a new issue. When I ran ./run_kitchen-FloorPlan21_0.sh, I received the error below.

When investigating, I found that the bounding box output has an area of 0, meaning the (x1, y1) and (x2, y2) coordinates of the bounding box have the same values. As a result, in thortils.vision.projection.thor_project_bbox(...), the length of positions is 0. Have you encountered this issue before ?

Traceback (most recent call last):
  File "trial_runner.py", line 54, in <module>
    main()
  File "trial_runner.py", line 29, in main
    results = trial.run(logging=args.logging)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/trial.py", line 159, in run
    observation, reward = task_env.execute(agent, action)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/common.py", line 83, in execute
    observation = self.get_observation(event, action, detector=agent.detector)
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/object_search.py", line 211, in get_observation
    detections = detector.detect_project(img, event.depth_frame,
  File "/home/mykabouri/Desktop/cos-pomdp/cospomdp_apps/thor/detector.py", line 264, in detect_project
    thor_points = pj.thor_project_bbox(
  File "/home/mykabouri/Desktop/cos-pomdp/venv/cosp/lib/python3.8/site-packages/thortils/vision/projection.py", line 302, in thor_project_bbox
    sampled_positions = positions[np.random.choice(len(positions), num_points)]
  File "mtrand.pyx", line 928, in numpy.random.mtrand.RandomState.choice
ValueError: a must be greater than 0 unless no samples are taken

You might want to try a lower version of Numpy as well - either 1.20 or 1.24

mKabouri commented 1 week ago

Thank you for your response. I do not think this is an issue with numpy (I am using version 1.24). The positions array is empty due to an unusual bounding box prediction, where the bounding box predicts a single point (x1 == x2 and y1 == y2).

RajeshDM commented 1 week ago

Thank you for your response. I do not think this is an issue with numpy (I am using version 1.24). The positions array is empty due to an unusual bounding box prediction, where the bounding box predicts a single point (x1 == x2 and y1 == y2).

Oh ok makes sense. I guess in that case you might just ignore that case since the object prediction has 0 width or 0 height.