SahilCodevally/codevally-vision-language-action
0
1"""2src/ui/examples.py — Demo image loader for the Gradio Examples component.3 4Reads demo images from the configured assets directory and pairs each5image with a contextually appropriate natural-language command.6"""7 8from pathlib import Path9 10from src.utils.config import DEMO_IMAGES_DIR11 12 13# Map each demo image filename to a curated command14_IMAGE_COMMANDS: dict[str, str] = {15 "assembly_line.jpg": "Pick up the defective board and place it in the red bin",16 "construction_site.jpg": "Move the hard hat next to the gloves",17 "desk_scene.jpg": "Pick up the bottle and place it in the box",18 "garage_tools.jpg": "Place the wrench back into the toolbox",19 "grocery_shelf.jpg": "Move the water bottle into the shopping basket",20 "kitchen_counter.jpg": "Pick up the apple and place it in the bowl",21 "lab_equipment.jpg": "Move the bottle next to the microscope",22 "medical_tray.jpg": "Pick up the scissors and place them on the tray",23 "office_supplies.jpg": "Move the phone next to the laptop",24 "warehouse_boxes.jpg": "Move the closest box onto the hand truck",25}26 27 28def get_demo_examples() -> list[list]:29 """30 Return a list of ``[image_path, command]`` pairs for Gradio Examples.31 32 Returns:33 Sorted list of ``[str, str]`` pairs, one per demo image found on disk.34 Returns an empty list if the demo images directory does not exist.35 """36 demo_dir = Path(DEMO_IMAGES_DIR)37 if not demo_dir.exists():38 return []39 40 examples: list[list] = []41 for img_path in sorted(demo_dir.glob("*.jpg")):42 cmd = _IMAGE_COMMANDS.get(img_path.name, "Inspect the closest object")43 examples.append([str(img_path), cmd])44 45 return examples46 