MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / process_data

Function process_data

eval/run_predict_aguvis.py:452–504  ·  view source on GitHub ↗

Process the data to run predict. Args: episode (Dict): one single data. image_path (str): the image_path processed. args(argparse.Namespace): the args passed in from terminal. Returns: Dict: the param used to run predict function.

(episode:Dict,
                image_path: str,
                args:argparse.Namespace)

Source from the content-addressed store, hash-verified

450
451
452def process_data(episode:Dict,
453 image_path: str,
454 args:argparse.Namespace) -> Dict:
455 """
456 Process the data to run predict.
457
458 Args:
459 episode (Dict): one single data.
460 image_path (str): the image_path processed.
461 args(argparse.Namespace): the args passed in from terminal.
462
463 Returns:
464 Dict: the param used to run predict function.
465 """
466
467 def load_image(image_file: str) -> Image:
468 """
469 Origin code for loading the image.
470
471 Args:
472 image_file (str): the path or the url of the image.
473
474 Note we didn't do any resize action here.
475
476 Returns:
477 Image: the Image class.
478 """
479 if image_file.startswith(("http://", "https://")):
480 response = requests.get(image_file)
481 image = Image.open(BytesIO(response.content)).convert("RGB")
482 else:
483 image = Image.open(image_file).convert("RGB")
484 return image
485
486 image: Image = load_image(image_path)
487 instruction:str = episode['instruction']
488 low_instruction: Optional[str] = None
489
490 data_name:str = args.data_name
491
492 if data_name == 'android_control_low_test':
493 low_instruction:str = episode['low_instruction']
494
495 return {
496 "image": image,
497 "episode": episode,
498 "instruction": instruction,
499 "previous_actions": None,
500 "low_level_instruction": low_instruction,
501 "mode": args.mode,
502 "temperature": args.temperature,
503 "max_new_tokens": args.max_new_tokens
504 }
505
506
507def generate_response(

Callers

nothing calls this directly

Calls 1

load_imageFunction · 0.70

Tested by

no test coverage detected