Bladeren bron

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

WangChao 4 maanden geleden
bovenliggende
commit
622b7b6b38
1 gewijzigde bestanden met toevoegingen van 31 en 0 verwijderingen
  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()