MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / inference

Function inference

app.py:522–755  ·  view source on GitHub ↗
(inference_canvas, visual_canvas, text_prompt, traj_lists, main_reference_img, 
                resized_height, resized_width, top_left_height, top_left_width, bottom_right_height, bottom_right_width)

Source from the content-addressed store, hash-verified

520
521
522def inference(inference_canvas, visual_canvas, text_prompt, traj_lists, main_reference_img,
523 resized_height, resized_width, top_left_height, top_left_width, bottom_right_height, bottom_right_width):
524
525 # TODO: enhance the text prompt by Qwen3-VL-32B?
526
527
528 # Convert
529 resized_height = int(resized_height)
530 resized_width = int(resized_width)
531 top_left_height = int(top_left_height)
532 top_left_width = int(top_left_width)
533 bottom_right_height = int(bottom_right_height)
534 bottom_right_width = int(bottom_right_width)
535 traj_lists = ast.literal_eval(traj_lists)
536
537
538
539 # Init Some Fixed Setting
540 if model_code_name == "Wan":
541 config_path = "config/train_wan_motion_FrameINO.yaml"
542 dot_radius = 7
543 num_frames = 81
544 elif model_code_name == "CogVideoX":
545 config_path = "config/train_cogvideox_i2v_motion_FrameINO.yaml"
546 dot_radius = 6
547 num_frames = 49
548 config = OmegaConf.load(config_path)
549
550
551 # Prepare tmp folders
552 print()
553 store_folder_path = "tmp_app_example_" + str(int(time.time()))
554 if os.path.exists(store_folder_path):
555 shutil.rmtree(store_folder_path)
556 os.makedirs(store_folder_path)
557
558
559 # Write the visual canvas
560 visual_canvas_store_path = os.path.join(store_folder_path, "visual_canvas.png")
561 cv2.imwrite( visual_canvas_store_path, cv2.cvtColor(visual_canvas, cv2.COLOR_BGR2RGB) )
562
563
564
565 # Resize the map
566 canvas_width = resized_width + top_left_width + bottom_right_width
567 canvas_height = resized_height + top_left_height + bottom_right_height
568 # inference_canvas = cv2.resize(visual_canvas, (canvas_width, canvas_height), interpolation = cv2.INTER_AREA)
569 print("Canvas Shape is", str(canvas_height) + "x" + str(canvas_width) )
570
571
572 # TODO: 还要去enhance这个text prompt要跟QWen的保持一致的complexity的感觉。。。
573
574 # Save the text prompt
575 print("Text Prompt is", text_prompt)
576 with open(os.path.join(store_folder_path, 'text_prompt.txt'), 'w') as file:
577 file.write(text_prompt)
578
579

Callers

nothing calls this directly

Calls 6

sample_traj_by_lengthFunction · 0.85
timeMethod · 0.80
writeMethod · 0.80
closeMethod · 0.80
updateMethod · 0.80
prepare_traj_tensorMethod · 0.45

Tested by

no test coverage detected