import os
import argparse
import json
def gen_rec_label(input_path, out_label):
with open(out_label, ‘w’) as out_file:
with open(input_path, ‘r’) as f:
for line in f.readlines():
tmp = line.strip(‘\n’).replace(" ", “”).split(‘,’)
img_path, label = tmp[0], tmp[1]
label = label.replace(“”", “”)
out_file.write(img_path + ‘\t’ + label + ‘\n’)
def gen_det_label(root_path, input_dir, out_label):
with open(out_label, ‘w’,encoding=‘utf-8’) as out_file:
for label_file in os.listdir(input_dir):
img_path = root_path + label_file[3:-4] + “.jpg”
label = []
print(label_file)
with open(os.path.join(input_dir, label_file), “r”,encoding=‘UTF-8-sig’) as f:
for line in f.readlines():
print(line)
#tmp = str(line).replace(“\xef\xbb\xbf”, “”).split(‘,’)
#tmp = str(line).strip(“\r\n”).replace(“\xef\xbb\xbf”, “”).split(‘,’)
tmp=str(line).strip(“\n\r”).split(‘,’)
print(tmp)
points = tmp[:8]
print(len(points))
s = []
for i in range(0, len(points), 2):
b = points[i:i + 2]
print(b)
b = [int(float(t)) for t in b]
s.append(b)
result = {“transcription”: tmp[8], “points”: s}
label.append(result)
out_file.write(img_path + ‘\t’ + json.dumps(
label, ensure_ascii=False) + ‘\n’)
if name == “main”:
parser = argparse.ArgumentParser()
parser.add_argument(
‘–mode’,
type=str,
default=“rec”,
help=‘Generate rec_label or det_label, can be set rec or det’)
parser.add_argument(
‘–root_path’,
type=str,
default=“text_localization/ch4_test_images/”,
help='The root directory of images.Only takes effect when mode=det ')
parser.add_argument(
‘–input_path’,
type=str,
default=“icdar2015/text_localization/Challenge4_Test_Task1_GT”,
help=‘Input_label or input path to be converted’)
parser.add_argument(
感谢每一个认真阅读我文章的人,看着粉丝一路的上涨和关注,礼尚往来总是要有的:
① 2000多本Python电子书(主流和经典的书籍应该都有了)
② Python标准库资料(最全中文版)
③ 项目源码(四五十个有趣且经典的练手项目及源码)
④ Python基础入门、爬虫、web开发、大数据分析方面的视频(适合小白学习)
⑤ Python学习路线图(告别不入流的学习)
小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Python爬虫全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:python)
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:python)
[外链图片转存中…(img-3uP93f8t-1711059265839)]