MCPcopy Create free account
hub / github.com/SHAILAB-IPEC/OpenFly-Platform / main

Function main

train/eval.py:501–656  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

499 return [x, y, z, yaw]
500
501def main():
502 eval_info = "configs/eval_test.json"
503
504 f = open(eval_info, 'r')
505 all_eval_info = json.loads(f.read())
506 f.close()
507
508 # Load model
509 model_name_or_path="IPEC-COMMUNITY/openfly-agent-7b"
510 processor = AutoProcessor.from_pretrained(model_name_or_path)
511 policy = AutoModelForVision2Seq.from_pretrained(
512 model_name_or_path,
513 attn_implementation="flash_attention_2", # [Optional] Requires `flash_attn`
514 torch_dtype=torch.bfloat16,
515 low_cpu_mem_usage=True,
516 trust_remote_code=True,
517 ).to("cuda:0")
518
519 # Test metrics
520 acc = 0
521 stop = 0
522 data_num = 0
523 MAX_STEP = 100
524
525 # Group by environment type
526 env_groups = {}
527 for item in all_eval_info:
528 env_type = item["image_path"].split("/")[0] # Get environment type
529 if env_type not in env_groups:
530 env_groups[env_type] = []
531 env_groups[env_type].append(item)
532
533 # Process each environment type sequentially
534 for env_name, eval_info in env_groups.items():
535 print(f"Starting evaluation of environment: {env_name}, with {len(eval_info)} data entries")
536 time.sleep(5)
537
538 # Create appropriate environment bridge based on environment type
539 if "airsim" in env_name:
540 env_bridge = AirsimBridge(env_name)
541 pos_ratio = 1.0
542 elif "ue" in env_name:
543 env_bridge = UEBridge(ue_ip="127.0.0.1", ue_port="9000", env_name=env_name)
544 pos_ratio = 1.0
545 elif "gs" in env_name:
546 env_bridge = GSBridge(env_name)
547 pos_ratio = 5.15
548 else:
549 print(f"Unknown environment type: {env_name}, skipping")
550 continue
551
552 # Evaluate all data for current environment
553 for idx, item in enumerate(eval_info):
554 acts = [] # Reset action list
555 data_num += 1
556 pos_list = item['pos']
557 text = item['gpt_instruction']
558 start_postion = pos_list[0]

Callers 1

eval.pyFile · 0.70

Calls 14

set_camera_poseMethod · 0.95
print_infoMethod · 0.95
kill_env_processFunction · 0.85
readMethod · 0.80
appendMethod · 0.80
AirsimBridgeClass · 0.70
UEBridgeClass · 0.70
GSBridgeClass · 0.70
get_actionFunction · 0.70
getPoseAfterMakeActionFunction · 0.70
calculate_distanceFunction · 0.70
closeMethod · 0.45

Tested by

no test coverage detected