23 lines
710 B
Python
23 lines
710 B
Python
import os
|
|
import json
|
|
|
|
def generate_label_studio_json(image_path, image_type=None, result=None):
|
|
|
|
pre_root = image_path.split('/')[-1]
|
|
|
|
json_list = list()
|
|
|
|
image_names = os.listdir(image_path)
|
|
for i in range(len(image_names)):
|
|
t_d = dict()
|
|
t_d['data'] = {"image": f"/data/local-files/?d={pre_root}/{image_names[i]}"}
|
|
json_list.append(t_d)
|
|
|
|
|
|
with open(f"result.json", "w", encoding='utf-8') as f:
|
|
json.dump(json_list, f, indent=4,ensure_ascii=False)
|
|
|
|
if __name__ == '__main__':
|
|
image_path = "/home/admin-root/haotian/康达瑞贝斯机器狗/data_image/002目标检测图片"
|
|
generate_label_studio_json(image_path)
|
|
|