Skip to content

Commit

Permalink
Script: Created empty text file with the same name as the image name
Browse files Browse the repository at this point in the history
  • Loading branch information
emes3ye committed Jan 20, 2020
1 parent 09f2c65 commit 0107e88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Annotations_yolo/
Annotations_yolo/
images/
labels/
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.pythonPath": "/home/shovon/anaconda3/bin/python"
"python.pythonPath": "/usr/bin/python3"
}
25 changes: 25 additions & 0 deletions creates_empty_txt_file_with_jpg_image_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#image are in the images folder
#created .txt file will be in the labels folder
import os

def main():
dir_path = 'images'
extensions = ['.jpg']
dir_list = [file for file in os.listdir(dir_path)
if any(file.endswith(ext) for ext in extensions)]
#print(dir_list)
output_dir = 'labels'
if not os.path.exists(output_dir):
os.mkdir(output_dir)

for image_name in dir_list:
file_name = image_name.split('.')[0]
#print(file_name)
text_file_path = output_dir + "/" + file_name + ".txt"
if not os.path.exists(text_file_path):
f = open(text_file_path, 'w')
f.close()


if __name__ == "__main__":
main()

0 comments on commit 0107e88

Please sign in to comment.