Скрипт для валидации датасета.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -33,3 +33,4 @@ paddleocr.egg-info/
|
|||||||
/deploy/android_demo/app/cache/
|
/deploy/android_demo/app/cache/
|
||||||
test_tipc/web/models/
|
test_tipc/web/models/
|
||||||
test_tipc/web/node_modules/
|
test_tipc/web/node_modules/
|
||||||
|
paddle/
|
||||||
|
|||||||
35
scripts/dataset_validation.py
Normal file
35
scripts/dataset_validation.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
def rename_files(directory_path: str):
|
||||||
|
extensions = set()
|
||||||
|
|
||||||
|
for file in os.listdir(directory_path):
|
||||||
|
filename, extension = file.split(".")
|
||||||
|
extensions.add(extension)
|
||||||
|
old_filename = os.path.join(directory_path, file)
|
||||||
|
new_filename = os.path.join(directory_path, f"{filename}.jpg")
|
||||||
|
if old_filename != new_filename:
|
||||||
|
print(f"{old_filename} -> {new_filename}")
|
||||||
|
os.rename(old_filename, new_filename)
|
||||||
|
|
||||||
|
def check_images(directory_path: str):
|
||||||
|
for file in os.listdir(directory_path):
|
||||||
|
try:
|
||||||
|
img = cv2.imread(os.path.join(directory_path, file))
|
||||||
|
if img is None:
|
||||||
|
print(file)
|
||||||
|
except Exception:
|
||||||
|
print(file)
|
||||||
|
|
||||||
|
def check_labels(dir_path: str) -> int:
|
||||||
|
for filename in os.listdir(dir_path):
|
||||||
|
name, extension = filename.split(".")
|
||||||
|
if len(name) != 17:
|
||||||
|
print(filename)
|
||||||
|
|
||||||
|
|
||||||
|
# rename_files("train_data/images/")
|
||||||
|
# check_images("train_data/images/")
|
||||||
|
check_labels("train_data/images/")
|
||||||
|
|
||||||
Reference in New Issue
Block a user