Compare commits
2 Commits
76b0919e91
...
a772fdad77
| Author | SHA1 | Date | |
|---|---|---|---|
| a772fdad77 | |||
| e2047bbf5a |
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/
|
||||||
|
|||||||
44
scripts/dataset_validation.py
Normal file
44
scripts/dataset_validation.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
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):
|
||||||
|
for filename in os.listdir(dir_path):
|
||||||
|
name, extension = filename.split(".")
|
||||||
|
if len(name) != 17:
|
||||||
|
print(filename)
|
||||||
|
|
||||||
|
def check_symbols(dir_path: str):
|
||||||
|
with open(os.path.join(dir_path, "dict.txt"), "r") as dict_file:
|
||||||
|
dict_content = dict_file.readlines()
|
||||||
|
dict_chars = set(char.strip() for char in dict_content)
|
||||||
|
for filename in os.listdir(os.path.join(dir_path, "images")):
|
||||||
|
label, extension = filename.split(".")
|
||||||
|
if any([char not in dict_chars for char in label]):
|
||||||
|
print(filename)
|
||||||
|
|
||||||
|
# rename_files("train_data/images/")
|
||||||
|
# check_images("train_data/images/")
|
||||||
|
# check_labels("train_data/images/")
|
||||||
|
check_symbols("train_data/")
|
||||||
|
|
||||||
Reference in New Issue
Block a user