Skip to content

Commit

Permalink
added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcclinton committed Oct 17, 2024
1 parent 81a0859 commit 8efea46
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 7 deletions.
Binary file modified image_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions predicators/perception/spot_perceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import time
from pathlib import Path
from typing import Dict, List, Optional, Set, Collection
import json

import imageio.v2 as iio
import numpy as np
from bosdyn.client import math_helpers
from matplotlib import pyplot as plt
import PIL.Image

from predicators import utils
from predicators.envs import BaseEnv, get_or_create_env
Expand Down Expand Up @@ -569,8 +571,7 @@ def _create_goal(self, state: State,
GroundAtom(Inside, [cup, plastic_bin]),
}
object_name_to_object = {}
self._parse_vlm_goal_from_state(state, goal_description, object_name_to_object)
import ipdb; ipdb.set_trace()
return self._parse_vlm_goal_from_state(state, goal_description, object_name_to_object)
if goal_description == "know container as empty":
cup = Object("cup", _container_type)
ContainingFoodKnown = pred_name_to_pred["ContainingFoodKnown"]
Expand Down Expand Up @@ -722,9 +723,8 @@ def _parse_vlm_goal_from_state(
object_names = set(id_to_obj)
prompt_prefix = self._get_language_goal_prompt_prefix(object_names)
prompt = prompt_prefix + f"\n# {language_goal}"
import ipdb; ipdb.set_trace()
image_list = [
PIL.Image.fromarray(v.rotated_rgb) for _, v in rgbds.items()
PIL.Image.fromarray(v.rotated_rgb) for _, v in state.camera_images.items()
]
responses = vlm.sample_completions(
prompt=prompt,
Expand All @@ -734,10 +734,13 @@ def _parse_vlm_goal_from_state(
num_completions=1,
)
response = responses[0]
import ipdb; ipdb.set_trace()
# Currently assumes that the LLM is perfect. In the future, will need
# to handle various errors and perhaps query the LLM for multiple
# responses until we find one that can be parsed.
goal_spec = json.loads(response)
try:
goal_spec = json.loads(response)
except json.JSONDecodeError as e:
goal_spec = json.loads(response.replace('`', '').replace('json', ''))

return self._curr_env._parse_goal_from_json(goal_spec, id_to_obj)

1 change: 0 additions & 1 deletion predicators/spot_utils/perception/object_perception.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def query_vlm(full_prompt, image_list):
votes = [result[i] for result in results]
final_results.append(votes.count(True) > votes.count(False))

import ipdb; ipdb.set_trace()
return final_results


Expand Down

0 comments on commit 8efea46

Please sign in to comment.