(self, ram_path, current_rgb_path="current_view.jpg", view_record_path="cache_files/view_cache.json")
| 120 | |
| 121 | class Vision_Perception_Experts: |
| 122 | def __init__(self, ram_path, current_rgb_path="current_view.jpg", view_record_path="cache_files/view_cache.json"): |
| 123 | self.current_rgb_path = current_rgb_path |
| 124 | self.view_record_path = view_record_path |
| 125 | if os.path.exists(self.view_record_path): |
| 126 | with open(self.view_record_path, "r", encoding="utf-8") as file: |
| 127 | self.view_record = json.load(file) |
| 128 | else: |
| 129 | self.view_record = {} |
| 130 | |
| 131 | while True: |
| 132 | try: |
| 133 | self.instructblip_model, self.instructblip_vis_processors, _ = load_model_and_preprocess(name="blip2_t5_instruct", model_type="flant5xl", is_eval=True, device=device) |
| 134 | self.ram_transform = get_transform(image_size=384) |
| 135 | self.ram_model = ram(pretrained=ram_path, image_size=384, vit='swin_l').eval().to(device) |
| 136 | break |
| 137 | except: |
| 138 | continue |
| 139 | |
| 140 | def ram_img_tagging(self, image): |
| 141 | ram_img = self.ram_transform(image).unsqueeze(0).to(device) |
nothing calls this directly
no outgoing calls
no test coverage detected