|
| 1 | +import os |
| 2 | +import rerun as rr |
| 3 | +import airgen |
| 4 | +from airgen.utils.sensor import ImageType, imagetype2request, responses2images |
| 5 | + |
| 6 | +# Enable logging visual data inside GRID's models |
| 7 | +os.environ["TURN_ON_RERUN"] = "1" |
| 8 | + |
| 9 | +from grid import GRIDConfig |
| 10 | +# Replace this with the main directory of GRID that contains `external` |
| 11 | +GRIDConfig.set_main_dir("/workspaces/GRID") |
| 12 | + |
| 13 | +from grid.model.perception.vqa.gllava import GLLaVA |
| 14 | +from grid.model.perception.segmentation.gsam import GroundedSAM |
| 15 | + |
| 16 | +llava = GLLaVA() |
| 17 | +gsam = GroundedSAM() |
| 18 | + |
| 19 | +# Initialize the AirGen client |
| 20 | +c = airgen.MultirotorClient() |
| 21 | +c.confirmConnection() |
| 22 | +c.enableApiControl(True) |
| 23 | +c.armDisarm(True) |
| 24 | +c.takeoffAsync().join() |
| 25 | + |
| 26 | +responses = c.simGetImages([imagetype2request("front_center", ImageType.Scene)]) |
| 27 | +image = responses2images(responses)[0][0] |
| 28 | +obj = llava.run(image, "Describe the scene, and pick a single object of interest") |
| 29 | +print(obj) |
| 30 | + |
| 31 | +# Example output: The scene is a large, open field with a road running through it. |
| 32 | +# In the distance, there are several wind turbines, which are the main focus |
| 33 | +# of the image. These wind turbines are situated in the middle of the field, |
| 34 | +# and they are spinning, indicating that they are generating electricity from |
| 35 | +# the wind. The presence of these turbines suggests that the area is likely |
| 36 | +# a wind farm, which harnesses the power of the wind to produce clean and |
| 37 | +# renewable energy |
| 38 | + |
| 39 | +seg = gsam.segment_object(image, "wind turbines") |
0 commit comments