label_studio_gen_files.py 922 B

12345678910111213141516171819202122232425262728293031
  1. import argparse
  2. import os
  3. def main():
  4. parser = argparse.ArgumentParser("生成label studio 需要的文件目录\n")
  5. parser.add_argument("input", help="")
  6. parser.add_argument("--wildcard")
  7. parser.add_argument("output", help="")
  8. args = parser.parse_args()
  9. try:
  10. with open(args.output, 'w') as outfile:
  11. # 遍历目录中的文件和文件夹
  12. for root, dirs, files in os.walk(args.input):
  13. # 只输出文件名,不包括文件夹
  14. for file in files:
  15. if file.startswith("."):
  16. continue
  17. if args.wildcard and file.endswith(args.wildcard):
  18. file_path = os.path.join(root, file)
  19. outfile.write('http://192.168.10.18:10088/' + file_path + '\n')
  20. except Exception as e:
  21. print(e)
  22. if __name__ == '__main__':
  23. main()