Download src/ui/examples.py from SahilCodevally/codevally-vision-language-action: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/SahilCodevally/codevally-vision-language-action/resolve/main/src/ui/examples.py
- Command line
-
hf download hf://spaces/SahilCodevally/codevally-vision-language-action/src/ui/examples.py
-
curl -L -o examples.py https://huggingface.co/spaces/SahilCodevally/codevally-vision-language-action/resolve/main/src/ui/examples.py
1.74 kB
| """ | |
| src/ui/examples.py — Demo image loader for the Gradio Examples component. | |
| Reads demo images from the configured assets directory and pairs each | |
| image with a contextually appropriate natural-language command. | |
| """ | |
| from pathlib import Path | |
| from src.utils.config import DEMO_IMAGES_DIR | |
| # Map each demo image filename to a curated command | |
| _IMAGE_COMMANDS: dict[str, str] = { | |
| "assembly_line.jpg": "Pick up the defective board and place it in the red bin", | |
| "construction_site.jpg": "Move the hard hat next to the gloves", | |
| "desk_scene.jpg": "Pick up the bottle and place it in the box", | |
| "garage_tools.jpg": "Place the wrench back into the toolbox", | |
| "grocery_shelf.jpg": "Move the water bottle into the shopping basket", | |
| "kitchen_counter.jpg": "Pick up the apple and place it in the bowl", | |
| "lab_equipment.jpg": "Move the bottle next to the microscope", | |
| "medical_tray.jpg": "Pick up the scissors and place them on the tray", | |
| "office_supplies.jpg": "Move the phone next to the laptop", | |
| "warehouse_boxes.jpg": "Move the closest box onto the hand truck", | |
| } | |
| def get_demo_examples() -> list[list]: | |
| """ | |
| Return a list of ``[image_path, command]`` pairs for Gradio Examples. | |
| Returns: | |
| Sorted list of ``[str, str]`` pairs, one per demo image found on disk. | |
| Returns an empty list if the demo images directory does not exist. | |
| """ | |
| demo_dir = Path(DEMO_IMAGES_DIR) | |
| if not demo_dir.exists(): | |
| return [] | |
| examples: list[list] = [] | |
| for img_path in sorted(demo_dir.glob("*.jpg")): | |
| cmd = _IMAGE_COMMANDS.get(img_path.name, "Inspect the closest object") | |
| examples.append([str(img_path), cmd]) | |
| return examples | |