1 Star 0 Fork 1

vipul/Vehicle-Car-detection-and-multilabel-classification

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
utils.py 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
CaptainEven 提交于 2018-09-04 11:43 . Add files via upload
# coding: utf-8
import os
import shutil
def merge_violet2blue(train_root):
"""
to simplify data labeling and training, we merge violet into blue
"""
sub_dirs = [train_root + '/' + x for x in os.listdir(train_root)]
violets = [x for x in sub_dirs if os.path.isdir(x) and 'Violet' in x]
print('=> violets:\n', violets)
# merge violet files into blue
for x in violets:
dst_dir = x.replace('Violet', 'Blue')
if os.path.exists(dst_dir):
for y in os.listdir(x):
src_path = x + '/' + y
if os.path.exists(src_path):
dst_path = dst_dir + '/' + y
if not os.path.exists(dst_path):
shutil.copy(src_path, dst_dir)
# delete empty sub-dirs which contains violet
for x in violets:
if os.path.exists(x):
shutil.rmtree(x)
def viz_err(err_path, root='f:/'):
"""
visualize the detailed err info.
"""
err_dict = pickle.load(open(err_path, 'rb'))
# print(err_dict)
fig = plt.figure() #
for k, v in err_dict.items():
img_path = root + k
if os.path.isfile(img_path):
img = Image.open(img_path)
plt.gcf().set_size_inches(8, 8)
plt.imshow(img)
plt.title(img_path + '\n' + v)
plt.gca().set_xticks([])
plt.gca().set_yticks([])
plt.show()
if __name__ == '__main__':
# merge_violet2blue('f:/vehicle_test')
pass
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vipul/Vehicle-Car-detection-and-multilabel-classification.git
git@gitee.com:vipul/Vehicle-Car-detection-and-multilabel-classification.git
vipul
Vehicle-Car-detection-and-multilabel-classification
Vehicle-Car-detection-and-multilabel-classification
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385