Просмотр исходного кода

[feat] label studio 文件目录生成工具

WangChao 4 месяцев назад
Родитель
Сommit
622b7b6b38
1 измененных файлов с 31 добавлено и 0 удалено
  1. 31 0
      Labelme_LabelStudio/label_studio_gen_files.py

+ 31 - 0
Labelme_LabelStudio/label_studio_gen_files.py

@@ -0,0 +1,31 @@
+import argparse
+import os
+
+
+def main():
+    parser = argparse.ArgumentParser("生成label studio 需要的文件目录\n")
+    parser.add_argument("input", help="")
+    parser.add_argument("--wildcard")
+    parser.add_argument("output", help="")
+
+    args = parser.parse_args()
+
+    try:
+        with open(args.output, 'w') as outfile:
+
+            # 遍历目录中的文件和文件夹
+            for root, dirs, files in os.walk(args.input):
+                # 只输出文件名,不包括文件夹
+                for file in files:
+                    if file.startswith("."):
+                        continue
+                    if args.wildcard and file.endswith(args.wildcard):
+                        file_path = os.path.join(root, file)
+                        outfile.write('http://192.168.10.18:10088/' + file_path + '\n')
+
+    except Exception as e:
+        print(e)
+
+
+if __name__ == '__main__':
+    main()