# Scale coordinates from original to resized dimensionsdef scale_coordinates(original_coords, original_size, resized_size): orig_x1, orig_y1, orig_x2, orig_y2 = original_coords orig_w, orig_h = original_size new_w, new_h = resized_size scaled_x1 = int(orig_x1 * new_w / orig_w) scaled_y1 = int(orig_y1 * new_h / orig_h) scaled_x2 = int(orig_x2 * new_w / orig_w) scaled_y2 = int(orig_y2 * new_h / orig_h) return f"({scaled_x1}, {scaled_y1}),({scaled_x2}, {scaled_y2})"Ā # Example usageoriginal_coords_str = "(600, 623),(907, 634)"# Parse original coordinatescoord_match = re.findall(r'\((\d+),\s*(\d+)\)', original_coords_str)original_coords = [int(coord_match[0][0]), int(coord_match[0][1]), int(coord_match[1][0]), int(coord_match[1][1])]scaled_coords_str = scale_coordinates(original_coords, (original_width, original_height), (resized_width, resized_height))Ā referring_messages = [ { "role": "user", "content": [ {"type": "image", "image": image_path}, {"type": "text", "text": f"Describe the region {scaled_coords_str}"} ] }]Ā referring_result = llm_inference(referring_messages)print("Referring Result:", referring_result)