目录
sam2转coco json格式
import os
import json
import shutil
import cv2
import numpy as np
import random
import time
class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.integer):
return int(obj)
elif isinstance(obj, np.floating):
return float(obj)
elif isinstance(obj, np.ndarray):
return obj.tolist()
else:
return super(MyEncoder, self).default(obj)
if __name__ == '__main__':
debug_show=1
to_json=1
base_dir=r'E:\project\Grounded-SAM-2-main\dao_video_11\dao_video'
save_dir=r'E:\project\Grounded-SAM-