Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
GoAI
attention_ocr.pytorch
提交
3baa25ed
A
attention_ocr.pytorch
项目概览
GoAI
/
attention_ocr.pytorch
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
attention_ocr.pytorch
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3baa25ed
编写于
10月 14, 2017
作者:
X
xiaohang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
works for mnt data
上级
c70bc0f6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
64 deletion
+35
-64
README.md
README.md
+6
-0
data/create_mnt_list.py
data/create_mnt_list.py
+28
-0
dataset.py
dataset.py
+0
-53
run.sh
run.sh
+1
-11
未找到文件。
README.md
浏览文件 @
3baa25ed
...
...
@@ -36,3 +36,9 @@ Train a new model
Stable commits
--------------
dbe73da0dd7efb8bd76dbd7f0ac3856e742b98d4: support image list with label and alphabet
Train for VGG text data
--------------
1.
create a link to mnt folder
2.
python data/create_mnt_list.py
3.
python main.py --trainlist data/train_list.txt --vallist data/test_list.txt --cuda --adam --lr=0.001
data/create_mnt_list.py
0 → 100644
浏览文件 @
3baa25ed
with
open
(
'data/mnt/ramdisk/max/90kDICT32px/annotation_train.txt'
)
as
fp
:
lines
=
fp
.
readlines
()
train_fp
=
open
(
'data/train_list.txt'
,
'w'
)
for
line
in
lines
:
imgpath
=
line
.
strip
().
split
(
' '
)[
0
]
label
=
imgpath
.
split
(
'/'
)[
-
1
].
split
(
'_'
)[
1
].
lower
()
label
=
':'
.
join
(
label
)
imgpath
=
'data/mnt/ramdisk/max/90kDICT32px/%s'
%
imgpath
output
=
' '
.
join
([
imgpath
,
label
])
print
>>
train_fp
,
output
train_fp
.
close
()
with
open
(
'data/mnt/ramdisk/max/90kDICT32px/annotation_test.txt'
)
as
fp
:
lines
=
fp
.
readlines
()
test_fp
=
open
(
'data/test_list.txt'
,
'w'
)
for
line
in
lines
:
imgpath
=
line
.
strip
().
split
(
' '
)[
0
]
label
=
imgpath
.
split
(
'/'
)[
-
1
].
split
(
'_'
)[
1
].
lower
()
label
=
':'
.
join
(
label
)
imgpath
=
'data/mnt/ramdisk/max/90kDICT32px/%s'
%
imgpath
output
=
' '
.
join
([
imgpath
,
label
])
print
>>
test_fp
,
output
test_fp
.
close
()
dataset.py
浏览文件 @
3baa25ed
...
...
@@ -46,59 +46,6 @@ class listDataset(Dataset):
return
(
img
,
label
)
class
lmdbDataset
(
Dataset
):
def
__init__
(
self
,
root
=
None
,
transform
=
None
,
target_transform
=
None
):
self
.
env
=
lmdb
.
open
(
root
,
max_readers
=
1
,
readonly
=
True
,
lock
=
False
,
readahead
=
False
,
meminit
=
False
)
if
not
self
.
env
:
print
(
'cannot creat lmdb from %s'
%
(
root
))
sys
.
exit
(
0
)
with
self
.
env
.
begin
(
write
=
False
)
as
txn
:
nSamples
=
int
(
txn
.
get
(
'num-samples'
))
self
.
nSamples
=
nSamples
self
.
transform
=
transform
self
.
target_transform
=
target_transform
def
__len__
(
self
):
return
self
.
nSamples
def
__getitem__
(
self
,
index
):
assert
index
<=
len
(
self
),
'index range error'
index
+=
1
with
self
.
env
.
begin
(
write
=
False
)
as
txn
:
img_key
=
'image-%09d'
%
index
imgbuf
=
txn
.
get
(
img_key
)
buf
=
six
.
BytesIO
()
buf
.
write
(
imgbuf
)
buf
.
seek
(
0
)
try
:
img
=
Image
.
open
(
buf
).
convert
(
'L'
)
except
IOError
:
print
(
'Corrupted image for %d'
%
index
)
return
self
[
index
+
1
]
if
self
.
transform
is
not
None
:
img
=
self
.
transform
(
img
)
label_key
=
'label-%09d'
%
index
label
=
str
(
txn
.
get
(
label_key
))
if
self
.
target_transform
is
not
None
:
label
=
self
.
target_transform
(
label
)
return
(
img
,
label
)
class
resizeNormalize
(
object
):
def
__init__
(
self
,
size
,
interpolation
=
Image
.
BILINEAR
):
...
...
run.sh
浏览文件 @
3baa25ed
...
...
@@ -2,14 +2,4 @@
# imagepath label
# /ab/cd/image.jpg a:b:c:d
#python main.py --trainlist train_list2.txt --vallist test_list2.txt --cuda --adam --lr=0.001
#python main_for_music.py --trainlist data/train_list2.txt --vallist data/test_list2.txt --cuda --adam --lr=0.001
# loss ~ 2
nohup
python main_for_music.py
--trainlist
data/train_list3.txt
--vallist
data/test_list3.txt
--cuda
--adam
--lr
=
0.001
>
log3.txt &
# loss ~ 2
python main.py
--trainlist
data/train_list.txt
--vallist
data/test_list.txt
--cuda
--adam
--lr
=
0.001
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录