Compare commits

..

327 Commits

Author SHA1 Message Date
dyning 2b16323080
Merge pull request #848 from tink2123/add_anno
6 years ago
tink2123 7f477619c0 fix typo
6 years ago
dyning 43874ba967
Merge pull request #847 from WenmuZhou/fix_cls_android_demo
6 years ago
littletomatodonkey d851f2c8d3
Merge pull request #858 from littletomatodonkey/fix_hub_serveing
6 years ago
littletomatodonkey ac1df3dbca fix hub serving draw
6 years ago
Daniel Yang e4b09948d1
Update FAQ.md
6 years ago
dyning 280cff56dc
Update README_ch.md
6 years ago
dyning 5da58b146c
Update README_ch.md
6 years ago
dyning 84a49ca05b
Update README.md
6 years ago
tink2123 fc512a84e3 add anno for rec
6 years ago
WenmuZhou ccd40ec85f set cls image_shape to 3,48,192
6 years ago
MissPenguin 8b64f4c2ea
Merge pull request #843 from LDOUBLEV/fixocr
6 years ago
Double_V 0c8bdc0885
Merge pull request #840 from lgcy/lgc_dev
6 years ago
Double_V e634afe76c
Merge pull request #839 from baiyfbupt/qat_issue
6 years ago
LDOUBLEV d0d0c4f95c update lite nb file,test=document_fix
6 years ago
baiyfbupt 3ec7d48c0f code refine
6 years ago
lgcy 3218b48148 fix lite crash bug
6 years ago
baiyfbupt 02ae18abf9 fix quant module
6 years ago
littletomatodonkey 815f20b550
Merge pull request #834 from tink2123/fix_srn
6 years ago
tink2123 5f8c3e07d9 fix srn fpn
6 years ago
tink2123 a5fbd902fe fix srn fpn
6 years ago
MissPenguin 5e25ed64a2
Update readme_en.md
6 years ago
littletomatodonkey 47703d16ce
Merge pull request #820 from littletomatodonkey/fix_cpp_doc
6 years ago
MissPenguin 764d8f5fc2
Update params.py
6 years ago
MissPenguin 2c35dafeb5
Update params.py
6 years ago
MissPenguin 358182a6d1
Update params.py
6 years ago
littletomatodonkey 829fe749cc test=document_fix, improve cpp infer doc
6 years ago
MissPenguin 8750361a5d
Merge pull request #817 from LDOUBLEV/fixocr
6 years ago
littletomatodonkey ecad10eb02
Merge pull request #816 from littletomatodonkey/add_tia
6 years ago
MissPenguin 51b57c47c7
Update utility.py
6 years ago
MissPenguin 04c5c6ab3b
Merge pull request #797 from wangjiawei04/ocr_0923
6 years ago
LDOUBLEV 1af833e2b6 fix doc typo
6 years ago
Jiawei Wang 63e4074ab4
Update serving_inference.md
6 years ago
Double_V 58e0a62799
Merge pull request #808 from baiyfbupt/patch-1
6 years ago
Double_V c320457d73
Merge pull request #810 from yukavio/develop
6 years ago
Jiawei Wang 83c420bf31
Update serving_inference.md
6 years ago
wangjiawei04 c67d04ad6e adapt to mobile model
6 years ago
Jiawei Wang e11b8aff79
Update serving_inference.md
6 years ago
littletomatodonkey 43f6ab7a63 fix gen label
6 years ago
wangjiawei04 62f85ec0bd remove utility
6 years ago
Double_V 115b517584
Merge pull request #814 from littletomatodonkey/add_tia
6 years ago
wangjiawei04 0005f4d171 add inference to serving model tool
6 years ago
yukavio 2d07a0bcb9 fix slim prune
6 years ago
MissPenguin 5d202e44d7
Merge pull request #811 from LDOUBLEV/fixocr
6 years ago
MissPenguin d93f006212
Update README_ch.md
6 years ago
MissPenguin 9411df5ae7
Merge pull request #815 from MissPenguin/develop
6 years ago
MissPenguin f196376249 update readme
6 years ago
littletomatodonkey 3a18b08fc5 fix warn
6 years ago
littletomatodonkey 896e573975 add tia aug
6 years ago
MissPenguin 2dfb1cfaa1
Update README_ch.md
6 years ago
Double_V e266466a9a
Merge pull request #802 from TingquanGao/develop
6 years ago
MissPenguin f94ebce2f5
Merge pull request #813 from MissPenguin/develop
6 years ago
MissPenguin 29405e325d update readme
6 years ago
LDOUBLEV d8b9e7a063 add faq
6 years ago
MissPenguin 10808204cd update readme
6 years ago
LDOUBLEV 0de72f5d97 opt doc
6 years ago
LDOUBLEV 6e87c90486 fix bad download link, opt lite doc
6 years ago
MissPenguin 90f30dbeb6
Merge pull request #809 from nblib/develop
6 years ago
nblib f7ae9a5fb3 Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into develop-nblib
6 years ago
yukavio c58fb6e822 update bash of slim pruning
6 years ago
nblib b7e9a81a05 add label tool
6 years ago
Bai Yifan 1063ecbee3
Update README.md
6 years ago
xiaoting 9bcba212b2
Merge pull request #800 from tink2123/add_multi_imgs
6 years ago
wangjiawei04 e53c427330 fix rec local
6 years ago
Tingquan Gao ac439ae1aa
fix path error
6 years ago
wangjiawei04 95f820b835 CLOSE data augment if use pdserving
6 years ago
wangjiawei04 f7dbf2b702 CLOSE data augment if use pdserving
6 years ago
wangjiawei04 3a347ebc3a fix doc
6 years ago
wangjiawei04 a52587d91f fix doc
6 years ago
wangjiawei04 e5fcccc495 Merge branch 'ocr_0923' of https://github.com/wangjiawei04/PaddleOCR into ocr_0923
6 years ago
wangjiawei04 7e97976ce6 fix doc
6 years ago
Jiawei Wang 0d12338fa9
Merge branch 'develop' into ocr_0923
6 years ago
wangjiawei04 4d1e17e70b fix doc
6 years ago
wangjiawei04 c4720557e8 fix all minor bugs
6 years ago
tink2123 8ed0882996 add multi-imgs
6 years ago
MissPenguin ac7e9dd9f2
Merge pull request #799 from tink2123/update_dict
6 years ago
tink2123 4a839b9d92 update clas_train link
6 years ago
tink2123 60763646b9 update clas link
6 years ago
littletomatodonkey 97c767ccfb
Merge pull request #798 from littletomatodonkey/fix_reco_doc
6 years ago
tink2123 853f6db37d fix srn typo
6 years ago
tink2123 0eab30cb17 update japan and korean dict
6 years ago
littletomatodonkey 571275e03c fix visualize
6 years ago
Daniel Yang bad8211491
Update README.md
6 years ago
Daniel Yang 6825ee4e11
Update visualization_en.md
6 years ago
Daniel Yang d9e005d2a7
Update visualization.md
6 years ago
wangjiawei04 7cacfc97d9 first commit
6 years ago
MissPenguin bb7eca34e7
Merge pull request #796 from tink2123/model_list
6 years ago
tink2123 f37745ff7c update model list
6 years ago
MissPenguin fa53bc3817
Update README.md
6 years ago
dyning 72faa11b77
Merge pull request #792 from LDOUBLEV/fixslim
6 years ago
Double_V 89ea21bf9e
Merge pull request #791 from LDOUBLEV/fixocr
6 years ago
dyning b195d7586f
Update update_en.md
6 years ago
dyning 667d393ecf
Update README.md
6 years ago
dyning e8a649ab5b
Update update.md
6 years ago
dyning 580a973841
Update README_ch.md
6 years ago
dyning 4fb914dafe
Update README_ch.md
6 years ago
dyning 8b74966a28
Update README_ch.md
6 years ago
dyning 706b25bff3
Update README.md
6 years ago
Daniel Yang 250412a408
Update README_ch.md
6 years ago
dyning 0f86cebb57
Update README.md
6 years ago
LDOUBLEV 03125024cc fix lite doc, test=document_fix
6 years ago
Daniel Yang e10e788855
Merge pull request #790 from tink2123/fix_typo_and_polish_infer
6 years ago
LDOUBLEV 732bb6eb21 fix ch doc, test=document_doc
6 years ago
xiaoting e8ba14955c
Merge branch 'develop' into fix_typo_and_polish_infer
6 years ago
LDOUBLEV 3f89879c19 add slim introduction,test=document_fix
6 years ago
Daniel Yang 1cc991e5a8
Update recognition.md
6 years ago
LDOUBLEV cf8bc662de fix type
6 years ago
LDOUBLEV 80608bd618 fix slim doc, test=develop
6 years ago
MissPenguin a9e7c8f923
Merge pull request #793 from MissPenguin/develop
6 years ago
MissPenguin a6db27161a update detection.md for v1.1
6 years ago
LDOUBLEV 7d5ce84956 fix conflicts
6 years ago
LDOUBLEV bd2370f1b9 fix ocr slim doc
6 years ago
MissPenguin 6be762d6a0
Merge pull request #783 from yukavio/develop
6 years ago
yukavio 4ac63947c4 add some content to slim doc
6 years ago
MissPenguin de05f4fa43
Merge pull request #782 from tink2123/update_doc_new
6 years ago
MissPenguin 0a6537845b
Merge pull request #774 from WenmuZhou/fix_whl_doc1
6 years ago
tink2123 e5d7571503 fix typo and add srn for inference,test=document_fix
6 years ago
LDOUBLEV 3d11aba92d fix lite doc, test=document_fix
6 years ago
MissPenguin d8ac92cdad
Merge pull request #789 from MissPenguin/develop
6 years ago
Daniel Yang 03960fde89
Update README_ch.md
6 years ago
MissPenguin c66b97f840 rename det_r18_vd_db_v1.1.yml
6 years ago
xiaoting 1614282b23
Merge pull request #768 from littletomatodonkey/fix_direection_cls_doc
6 years ago
MissPenguin 96c2e3f136
Merge pull request #776 from MissPenguin/develop
6 years ago
Double_V 3b286e70c3
Merge pull request #786 from LDOUBLEV/fixocr
6 years ago
tink2123 6af341a37b change pip source, test=document_fix
6 years ago
LDOUBLEV f4d826a5f3 fix doc, test=document_fix
6 years ago
littletomatodonkey a0f13f4340 fix recognition doc
6 years ago
yukavio f6408e11e1 complete the doc of sensitivity analysis
6 years ago
littletomatodonkey 25d7eb87c2 fix det path
6 years ago
MissPenguin bcc8f208ec add det_mv3_db_v1.1.yml & update config link for rec model
6 years ago
WenmuZhou a38de9bdbe update doc
6 years ago
WenmuZhou 278530239d update doc
6 years ago
tink2123 b578edd6a1 fix typo
6 years ago
dyning 6ac1497a31
Update README_ch.md
6 years ago
yukavio 3e3d06b606 refine prune doc
6 years ago
dyning 16352beb89
Update README.md
6 years ago
littletomatodonkey f57e23a902 fix inference doc
6 years ago
tink2123 75fde81704 update doc for install and angle_class
6 years ago
Double_V e086071da2
Merge pull request #778 from LDOUBLEV/fixslim
6 years ago
dyning 36fbabb108
Merge pull request #781 from dyning/develop
6 years ago
dyning f0ce9b90ef add PPOCR doc
6 years ago
littletomatodonkey 706cfe8391 fix cls link
6 years ago
littletomatodonkey 7831f18b08 fix recognition.md
6 years ago
LDOUBLEV 954c3313d2 fix predict det
6 years ago
littletomatodonkey d7080099e9 revert config
6 years ago
LDOUBLEV bc7dd36e0e rename readme
6 years ago
LDOUBLEV afc752248b opt slim doc and add res18 yml
6 years ago
Double_V e600d787f5
Merge pull request #770 from LDOUBLEV/fixocr
6 years ago
littletomatodonkey dcbc20e20e add quick start en model
6 years ago
MissPenguin 28cfb93df5
Merge pull request #772 from MissPenguin/develop
6 years ago
MissPenguin 6b35afb50a add config in models list
6 years ago
WenmuZhou 47f9972a20 update pip to pip3
6 years ago
WenmuZhou 5fa8b5c666 update python to python3
6 years ago
MissPenguin e01a4b623d update hubserving readme and params
6 years ago
WenmuZhou 15be2fb979 update whl doc
6 years ago
littletomatodonkey 0439dfb112 add yaml
6 years ago
MissPenguin 2681ad5f90 update algorithm overview
6 years ago
LDOUBLEV 8e90a40547 opt lite demo doc
6 years ago
littletomatodonkey 9028077999 fix qs
6 years ago
littletomatodonkey 17e722de59 fix table format
6 years ago
zhoujun 3fb28d2a87
Merge pull request #9 from PaddlePaddle/develop
6 years ago
Double_V 9228a49342
Merge pull request #767 from WenmuZhou/fix_readme1
6 years ago
littletomatodonkey f4d2ebcb3a fix quick start
6 years ago
zhoujun 3dce09ead4
Update README_ch.md
6 years ago
zhoujun 3d43a760e6
Update README.md
6 years ago
zhoujun 136ff79047
Merge pull request #8 from PaddlePaddle/develop
6 years ago
dyning 1a19bce923
Update README.md
6 years ago
dyning d181c7a3ed
Update README_ch.md
6 years ago
dyning b254cdb73a
Update README_ch.md
6 years ago
dyning fb2c33bcb1
Update README.md
6 years ago
dyning d6b83901fc
Update README.md
6 years ago
dyning bb873ce14d
Update README.md
6 years ago
dyning f3bac1b981
Merge pull request #765 from grasswolfs/update_readme_en_0920
6 years ago
dyning 0983ca7ad2
Merge pull request #764 from tink2123/add_en_doc
6 years ago
grasswolfs 3cfffcb5c5 test=develop, test=update_readme_en_0920
6 years ago
tink2123 21d0869b6e add en doc for rec
6 years ago
MissPenguin 30648fbc84
Update models_list_en.md
6 years ago
MissPenguin 60967e8b77
Update models_list.md
6 years ago
dyning 9295e25091
Update benchmark_en.md
6 years ago
dyning c762ca4707
Merge pull request #762 from LDOUBLEV/fixocr
6 years ago
LDOUBLEV 17e5df1de3 mv en.doc to ./doc_en
6 years ago
dyning d53dcb225e
Update benchmark.md
6 years ago
dyning 5ea014f5bf
Merge pull request #761 from LDOUBLEV/fixocr
6 years ago
LDOUBLEV fe35728b7d add framework.png
6 years ago
LDOUBLEV a8c8ec1f82 Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into fixocr
6 years ago
LDOUBLEV 0f8dc0a622 update benchmark and doc.jpg
6 years ago
MissPenguin 1ee51e2f56
Update README_en.md
6 years ago
MissPenguin 3872da8de0
Update README_en.md
6 years ago
MissPenguin bf60c4e7e3
Update README.md
6 years ago
MissPenguin 64ae0c4e38
Merge pull request #759 from grasswolfs/update_doc_0919
6 years ago
MissPenguin 7cfc0b910b
Merge pull request #760 from yukavio/develop
6 years ago
grasswolfs ad1aca64d3 test=develop, test=document_fix
6 years ago
grasswolfs 72e4f3643b Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into update_doc_0919
6 years ago
grasswolfs eef60848ba test=develop, test=document_fix
6 years ago
Double_V d64a4c3f6d
Merge pull request #756 from LDOUBLEV/fixocr
6 years ago
yukavio f27b7edd99 refine slim prune doc
6 years ago
yukavio 37f5ff9696 Merge remote-tracking branch 'upstream/develop' into develop
6 years ago
yukavio dc0aea4ec3 refine slim prune doc
6 years ago
grasswolfs 1a024c69c7 test=develop, test=document_fix
6 years ago
littletomatodonkey edd4c33f4a
Merge pull request #757 from littletomatodonkey/fix_whl_language
6 years ago
MissPenguin b287673a0b
Merge pull request #758 from MissPenguin/develop
6 years ago
MissPenguin 2a03948d7c update docs
6 years ago
littletomatodonkey 2ee7dcb53a fix cpp infer doc for cls
6 years ago
Daniel Yang 7a45786ab7
Update README.md
6 years ago
Daniel Yang 1392c9c477
Update README.md
6 years ago
dyning ad545e52f2
Merge pull request #729 from tink2123/tree
6 years ago
littletomatodonkey 24dfd8b2b2 fix whl doc and add multi-language
6 years ago
dyning de5c741a91
Merge pull request #753 from baiyfbupt/doc
6 years ago
LDOUBLEV b6289d0eb0 advance db post_process
6 years ago
MissPenguin 77cd8c1e66
Merge pull request #754 from tink2123/lan_doc
6 years ago
MissPenguin 0d17196f94
Merge pull request #755 from MissPenguin/develop
6 years ago
MissPenguin 84576471c3 modify hubserving doc
6 years ago
MissPenguin 1fd763f89b
Merge pull request #752 from MissPenguin/develop
6 years ago
tink2123 8e53734f35 update model_list
6 years ago
MissPenguin 235b3aff8e
Merge pull request #749 from tink2123/make_label
6 years ago
MissPenguin e9a39e2d27 modify hubserving doc
6 years ago
MissPenguin ae68afd622 modify hubserving doc
6 years ago
MissPenguin 06feb23dff modify hubserving doc
6 years ago
tink2123 821149e090 update model list
6 years ago
tink2123 98c01dabce add doc and font for languages
6 years ago
baiyfbupt 2b68ae333a refine slim readme
6 years ago
MissPenguin b063599418 remove det_mv3_db_v1.1.yml & add code annotation
6 years ago
Daniel Yang 3942482e2d
Update README.md
6 years ago
Daniel Yang 78a428dce6
Update visualization.md
6 years ago
Daniel Yang aee0a1fe96
Update README.md
6 years ago
Daniel Yang be6e69a84f
Update README.md
6 years ago
Double_V f1c4f413be
Merge pull request #751 from yukavio/develop
6 years ago
littletomatodonkey aafa88db70
Merge pull request #746 from tink2123/languages
6 years ago
MissPenguin a6ccaa513e
Merge pull request #750 from grasswolfs/update_readme_0918
6 years ago
tink2123 cf054cffc1 add copyright
6 years ago
tink2123 f9170fcfce polish gen_label
6 years ago
tink2123 289bf76067 add stride and mv to languages
6 years ago
yukavio 9958fdde66 fix some bug
6 years ago
grasswolfs f415f5fcb6 test=develop, test=document_fix
6 years ago
yukavio cf7372475e complete prune doc
6 years ago
grasswolfs 3e1d8f2dee test=develop, test=document_fix
6 years ago
grasswolfs 9cd6e11b3e test=develop, test=document_fix
6 years ago
grasswolfs a63d91c83f test=develop, test=document_fix
6 years ago
tink2123 4d816b6149 make label for paddleocr
6 years ago
MissPenguin 4559f16ec7
Merge pull request #741 from WenmuZhou/whl
6 years ago
MissPenguin 867a60f474
Merge pull request #747 from littletomatodonkey/fix_vis
6 years ago
littletomatodonkey 4a81e9481c fix docker link
6 years ago
tink2123 1edfc308b1 add languages
6 years ago
WenmuZhou cf2a483369 分类支持传参置信度
6 years ago
WenmuZhou 06430c9359 ppocr支持多语言切换
6 years ago
MissPenguin b10bd395c9
Update models_list.md
6 years ago
MissPenguin d4c47e2f50
Merge pull request #744 from wangjiawei04/pdserving_readme
6 years ago
MissPenguin b479372cd3
Merge pull request #745 from MissPenguin/develop
6 years ago
root 2cdf7a666e add models_list.md
6 years ago
root 76b8bb7ef1 add models_list.md
6 years ago
Jiawei Wang e01515599b
Update readme.md
6 years ago
tink2123 e3ac559430 update tree
6 years ago
WenmuZhou 79180223dc 更新分类模型地址
6 years ago
MissPenguin df14801b43
Merge pull request #740 from MissPenguin/develop
6 years ago
root c5f9b69c4e add db mv3 yml for v1.1
6 years ago
WenmuZhou ede5a3f4b6 更新检测识别模型地址
6 years ago
MissPenguin b8ed953142 modify cls model path
6 years ago
Double_V 42f0219cda
Merge pull request #719 from yukavio/develop
6 years ago
WenmuZhou bf60cd827b whl包添加分类模型
6 years ago
yukavio a3dee6a4b1 remove env flags
6 years ago
yukavio b8bf9b2c66 add sensitivity ratio
6 years ago
lichenxia fd76c1234b disable se & add cls params for hub serving
6 years ago
tink2123 6b906ad239 add tree for repo
6 years ago
tink2123 27384a5a5d add tree for repo
6 years ago
WenmuZhou ecba3f85d6 Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into whl
6 years ago
MissPenguin 5b5b72e651
Update inference.md
6 years ago
MissPenguin 594d34f5ed
Merge pull request #708 from WenmuZhou/angle_class
6 years ago
xiaoting cb1cc43259
Merge pull request #718 from tink2123/save_log
6 years ago
WenmuZhou 227f5f3a36 Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into master
6 years ago
yukavio d9d51f7daf rm eval_det_utils
6 years ago
Double_V 0da95ed13b
Merge pull request #717 from baiyfbupt/slim_qat
6 years ago
WenmuZhou 5d248b168f 解决冲突
6 years ago
WenmuZhou 99f253bc41 添加方向分类器inference文档
6 years ago
WenmuZhou c7819af417 对输出的scores和label进行顺序判断
6 years ago
WenmuZhou 25ff7eb517 添加方向分类器导出支持
6 years ago
tink2123 f8e01b2ea7 polish doc
6 years ago
MissPenguin 00a889e166
Merge pull request #610 from BeyondYourself/develop
6 years ago
Double_V a88764eae4
Merge pull request #721 from littletomatodonkey/fix_mkldnn
6 years ago
littletomatodonkey dbbfe96761
Merge pull request #722 from LDOUBLEV/fixocr
6 years ago
littletomatodonkey 2aa0c8eb2d remove re-init
6 years ago
littletomatodonkey 5858441b3d add notes
6 years ago
littletomatodonkey f78678dd66 fix py infer
6 years ago
LDOUBLEV 74f983d182 mv docker to deploy/docker
6 years ago
littletomatodonkey a7e915bf7b fix mklnn memory leak
6 years ago
yukavio d4f1758d55 add slim/prune
6 years ago
baiyfbupt 14dfa73e07 fix issue
6 years ago
baiyfbupt 2ac3ec96f4 fix issue
6 years ago
tink2123 eafa136cf1 update doc for saving log
6 years ago
baiyfbupt 2c6f0b0d55 add slim quantization
6 years ago
WenmuZhou f3f2b38efb 方向分类器设为默认不启用
6 years ago
WenmuZhou 03979d71d2 修改文件头
6 years ago
WenmuZhou 742cb9a3c6 移除注释和删掉不用的代码
6 years ago
WenmuZhou 74f6a5cb3d merge paddleocr
6 years ago
WenmuZhou 144b022fb6 添加分类模型
6 years ago
xiaoting ed6b2f0c71
Merge pull request #700 from tink2123/fix_doc
6 years ago
tink2123 fc9933354d update rec doc
6 years ago
Double_V d31effaf97
Merge pull request #600 from LDOUBLEV/fixocr
6 years ago
xiaoting 5fb3c419c9
Merge pull request #665 from tink2123/support_srn_inference
6 years ago
tink2123 5fc9fff98f Merge branch 'support_srn_inference' of https://github.com/tink2123/PaddleOCR
6 years ago
tink2123 29e2fed39c update code
6 years ago
xiaoting f265f94c65
Merge branch 'develop' into support_srn_inference
6 years ago
tink2123 aa7e9ac34e polish code
6 years ago
tink2123 bc1ad20701 support srn inference
6 years ago
littletomatodonkey 21af7660b5
Merge pull request #662 from littletomatodonkey/rm_readme
6 years ago
littletomatodonkey 7165f5899d rm duplicate readme
6 years ago
MissPenguin 4009fcf3d0
Merge pull request #654 from LiXiaYu/patch-1
6 years ago
dyning 3ebf46dae6
Update README_en.md
6 years ago
LiXiaYu f76ef16e9f
Update serving.md
6 years ago
WenmuZhou 567c74c508 修复cpp_infer的bug
6 years ago
WenmuZhou 54d562bfd9 merge PaddleOCR
6 years ago
dyning c75ad203e9
Update README_en.md
6 years ago
dyning e33026f38a
Update README.md
6 years ago
dyning 78f894f607
Merge pull request #648 from grasswolfs/revise_joinus_png
6 years ago
grasswolfs 725b17a111 test=develop, test=document_fix
6 years ago
WenmuZhou e11b2108fa 添加分类模型
6 years ago
shaohua.zhang f7cf83eab3
Merge pull request #15 from BeyondYourself/revert-14-BeyondYourself-patch-1
6 years ago
shaohua.zhang 7bfbbe47bc
Revert "fix the path "
6 years ago
shaohua.zhang bf9833bd94
Merge pull request #14 from BeyondYourself/BeyondYourself-patch-1
6 years ago
shaohua.zhang 935966a2c2
fix the path
6 years ago
shaohua.zhang e0bf9c9cfa
Merge pull request #13 from PaddlePaddle/develop
6 years ago
LDOUBLEV fef18931bd fix faq
6 years ago
LDOUBLEV f893d5bb86 fix FAQ
6 years ago
LDOUBLEV ff6ba9edcc Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleOCR into fixocr
6 years ago
shaohua.zhang 6887a320a5
Delete duplicate function
6 years ago
shaohua.zhang ea91f26f06
Merge pull request #12 from PaddlePaddle/develop
6 years ago
LDOUBLEV 59cdce6a88 fix bug in randomcropdata func
6 years ago
shaohua.zhang 91341b81bd
Merge pull request #11 from PaddlePaddle/develop
6 years ago

@ -1,7 +1,8 @@
include LICENSE.txt
include README.md
recursive-include ppocr/utils *.txt utility.py logging.py
recursive-include ppocr/data/ *.py
recursive-include ppocr/utils *.txt utility.py character.py check.py
recursive-include ppocr/data/det *.py
recursive-include ppocr/postprocess *.py
recursive-include tools/infer *.py
recursive-include ppocr/postprocess/lanms *.*
recursive-include tools/infer *.py

@ -1,35 +0,0 @@
# ex: set ts=8 noet:
all: qt5 test
test: testpy3
testpy2:
python -m unittest discover tests
testpy3:
python3 -m unittest discover tests
qt4: qt4py2
qt5: qt5py3
qt4py2:
pyrcc4 -py2 -o libs/resources.py resources.qrc
qt4py3:
pyrcc4 -py3 -o libs/resources.py resources.qrc
qt5py3:
pyrcc5 -o libs/resources.py resources.qrc
clean:
rm -rf ~/.labelImgSettings.pkl *.pyc dist labelImg.egg-info __pycache__ build
pip_upload:
python3 setup.py upload
long_description:
restview --long-description
.PHONY: all

File diff suppressed because it is too large Load Diff

@ -1,170 +0,0 @@
English | [简体中文](README_ch.md)
# PPOCRLabel
PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, with built-in PPOCR model to automatically detect and re-recognize data. It is written in python3 and pyqt5, supporting rectangular box annotation and four-point annotation modes. Annotations can be directly used for the training of PPOCR detection and recognition models.
<img src="./data/gif/steps_en.gif" width="100%"/>
### Recent Update
- 2021.1.11: Optimize the labeling experience (by [edencfc](https://github.com/edencfc)),
- Users can choose whether to pop up the label input dialog after drawing the detection box in "View - Pop-up Label Input Dialog".
- The recognition result scrolls synchronously when users click related detection box.
- Click to modify the recognition result.(If you can't change the result, please switch to the system default input method, or switch back to the original input method again)
- 2020.12.18: Support re-recognition of a single label box (by [ninetailskim](https://github.com/ninetailskim) ), perfect shortcut keys.
### TODO:
- Lock box mode: For the same scene data, the size and position of the locked detection box can be transferred between different pictures.
- Experience optimization: Add undo, batch operation include move, copy, delete and so on, optimize the annotation process.
## Installation
### 1. Install PaddleOCR
PaddleOCR models has been built in PPOCRLabel, please refer to [PaddleOCR installation document](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/installation.md) to prepare PaddleOCR and make sure it works.
### 2. Install PPOCRLabel
#### Windows + Anaconda
Download and install [Anaconda](https://www.anaconda.com/download/#download) (Python 3+)
```
pip install pyqt5
cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder
python PPOCRLabel.py
```
#### Ubuntu Linux
```
pip3 install pyqt5
pip3 install trash-cli
cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder
python3 PPOCRLabel.py
```
#### macOS
```
pip3 install pyqt5
pip3 uninstall opencv-python # Uninstall opencv manually as it conflicts with pyqt
pip3 install opencv-contrib-python-headless==4.2.0.32 # Install the headless version of opencv
cd ./PPOCRLabel # Change the directory to the PPOCRLabel folder
python3 PPOCRLabel.py
```
## Usage
### Steps
1. Build and launch using the instructions above.
2. Click 'Open Dir' in Menu/File to select the folder of the picture.<sup>[1]</sup>
3. Click 'Auto recognition', use PPOCR model to automatically annotate images which marked with 'X' <sup>[2]</sup>before the file name.
4. Create Box:
4.1 Click 'Create RectBox' or press 'W' in English keyboard mode to draw a new rectangle detection box. Click and release left mouse to select a region to annotate the text area.
4.2 Press 'Q' to enter four-point labeling mode which enables you to create any four-point shape by clicking four points with the left mouse button in succession and DOUBLE CLICK the left mouse as the signal of labeling completion.
5. After the marking frame is drawn, the user clicks "OK", and the detection frame will be pre-assigned a "TEMPORARY" label.
6. Click 're-Recognition', model will rewrite ALL recognition results in ALL detection box<sup>[3]</sup>.
7. Double click the result in 'recognition result' list to manually change inaccurate recognition results.
8. Click "Check", the image status will switch to "√",then the program automatically jump to the next(The results will not be written directly to the file at this time).
9. Click "Delete Image" and the image will be deleted to the recycle bin.
10. Labeling result: the user can save manually through the menu "File - Save Label", while the program will also save automatically after every 5 images confirmed by the user.the manually checked label will be stored in *Label.txt* under the opened picture folder.
Click "PaddleOCR"-"Save Recognition Results" in the menu bar, the recognition training data of such pictures will be saved in the *crop_img* folder, and the recognition label will be saved in *rec_gt.txt*<sup>[4]</sup>.
### Note
[1] PPOCRLabel uses the opened folder as the project. After opening the image folder, the picture will not be displayed in the dialog. Instead, the pictures under the folder will be directly imported into the program after clicking "Open Dir".
[2] The image status indicates whether the user has saved the image manually. If it has not been saved manually it is "X", otherwise it is "√", PPOCRLabel will not relabel pictures with a status of "√".
[3] After clicking "Re-recognize", the model will overwrite ALL recognition results in the picture.
Therefore, if the recognition result has been manually changed before, it may change after re-recognition.
[4] The files produced by PPOCRLabel can be found under the opened picture folder including the following, please do not manually change the contents, otherwise it will cause the program to be abnormal.
| File name | Description |
| :-----------: | :----------------------------------------------------------: |
| Label.txt | The detection label file can be directly used for PPOCR detection model training. After the user saves 5 label results, the file will be automatically saved. It will also be written when the user closes the application or changes the file folder. |
| fileState.txt | The picture status file save the image in the current folder that has been manually confirmed by the user. |
| Cache.cach | Cache files to save the results of model recognition. |
| rec_gt.txt | The recognition label file, which can be directly used for PPOCR identification model training, is generated after the user clicks on the menu bar "File"-"Save recognition result". |
| crop_img | The recognition data, generated at the same time with *rec_gt.txt* |
## Explanation
### Shortcut keys
| Shortcut keys | Description |
| ---------------- | ------------------------------------------------ |
| Ctrl + shift + A | Automatically label all unchecked images |
| Ctrl + shift + R | Re-recognize all the labels of the current image |
| W | Create a rect box |
| Q | Create a four-points box |
| Ctrl + E | Edit label of the selected box |
| Ctrl + R | Re-recognize the selected box |
| Backspace | Delete the selected box |
| Ctrl + V | Check image |
| Ctrl + Shift + d | Delete image |
| D | Next image |
| A | Previous image |
| Ctrl++ | Zoom in |
| Ctrl-- | Zoom out |
| ↑→↓← | Move selected box |
### Built-in Model
- Default model: PPOCRLabel uses the Chinese and English ultra-lightweight OCR model in PaddleOCR by default, supports Chinese, English and number recognition, and multiple language detection.
- Model language switching: Changing the built-in model language is supportable by clicking "PaddleOCR"-"Choose OCR Model" in the menu bar. Currently supported languagesinclude French, German, Korean, and Japanese.
For specific model download links, please refer to [PaddleOCR Model List](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/models_list_en.md#multilingual-recognition-modelupdating)
- Custom model: The model trained by users can be replaced by modifying PPOCRLabel.py in [PaddleOCR class instantiation](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/PPOCRLabel/PPOCRLabel.py#L110) referring [Custom Model Code](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/whl_en.md#use-custom-model)
### Save
PPOCRLabel supports three ways to save Label.txt
- Automatically save: When it detects that the user has manually checked 5 pictures, the program automatically writes the annotations into Label.txt. The user can change the value of ``self.autoSaveNum`` in ``PPOCRLabel.py`` to set the number of images to be automatically saved after confirmation.
- Manual save: Click "File-Save Marking Results" to manually save the label.
- Close application save
### Export partial recognition results
For some data that are difficult to recognize, the recognition results will not be exported by **unchecking** the corresponding tags in the recognition results checkbox.
*Note: The status of the checkboxes in the recognition results still needs to be saved manually by clicking Save Button.*
### Error message
- If paddleocr is installed with whl, it has a higher priority than calling PaddleOCR class with paddleocr.py, which may cause an exception if whl package is not updated.
- For Linux users, if you get an error starting with **objc[XXXXX]** when opening the software, it proves that your opencv version is too high. It is recommended to install version 4.2:
```
pip install opencv-python==4.2.0.32
```
- If you get an error starting with **Missing string id **,you need to recompile resources:
```
pyrcc5 -o libs/resources.py resources.qrc
```
- If you get an error ``` module 'cv2' has no attribute 'INTER_NEAREST'```, you need to delete all opencv related packages first, and then reinstall the 4.2.0.32 version of headless opencv
```
pip install opencv-contrib-python-headless==4.2.0.32
```
### Related
1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg)

@ -1,155 +0,0 @@
[English](README.md) | 简体中文
# PPOCRLabel
PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具内置PPOCR模型对数据自动标注和重新识别。使用python3和pyqt5编写支持矩形框标注和四点标注模式导出格式可直接用于PPOCR检测和识别模型的训练。
<img src="./data/gif/steps.gif" width="100%"/>
#### 近期更新
- 2021.1.11优化标注体验by [edencfc](https://github.com/edencfc)
- 用户可在“视图 - 弹出标记输入框”选择在画完检测框后标记输入框是否弹出。
- 识别结果与检测框同步滚动。
- 识别结果更改为单击修改。(如果无法修改,请切换为系统自带输入法,或再次切回原输入法)
- 2020.12.18 支持对单个标记框进行重新识别by [ninetailskim](https://github.com/ninetailskim)),完善快捷键。
#### 尽请期待
- 锁定框模式:针对同一场景数据,被锁定的检测框的大小与位置能在不同图片之间传递。
- 体验优化:增加撤销操作,批量移动、复制、删除等功能。优化标注流程。
如果您对以上内容感兴趣或对完善工具有不一样的想法,欢迎加入我们的队伍与我们共同开发
## 安装
### 1. 安装PaddleOCR
PPOCRLabel内置PaddleOCR模型故请参考[PaddleOCR安装文档](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/installation.md)准备好PaddleOCR并确保PaddleOCR安装成功。
### 2. 安装PPOCRLabel
#### Windows + Anaconda
```
pip install pyqt5
cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
python PPOCRLabel.py --lang ch
```
#### Ubuntu Linux
```
pip3 install pyqt5
pip3 install trash-cli
cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
python3 PPOCRLabel.py --lang ch
```
#### macOS
```
pip3 install pyqt5
pip3 uninstall opencv-python # 由于mac版本的opencv与pyqt有冲突需先手动卸载opencv
pip3 install opencv-contrib-python-headless==4.2.0.32 # 安装headless版本的open-cv
cd ./PPOCRLabel # 将目录切换到PPOCRLabel文件夹下
python3 PPOCRLabel.py --lang ch
```
## 使用
### 操作步骤
1. 安装与运行:使用上述命令安装与运行程序。
2. 打开文件夹:在菜单栏点击 “文件” - "打开目录" 选择待标记图片的文件夹<sup>[1]</sup>.
3. 自动标注:点击 ”自动标注“使用PPOCR超轻量模型对图片文件名前图片状态<sup>[2]</sup>为 “X” 的图片进行自动标注。
4. 手动标注:点击 “矩形标注”(推荐直接在英文模式下点击键盘中的 “W”)用户可对当前图片中模型未检出的部分进行手动绘制标记框。点击键盘Q则使用四点标注模式或点击“编辑” - “四点标注”用户依次点击4个点后双击左键表示标注完成。
5. 标记框绘制完成后,用户点击 “确认”,检测框会先被预分配一个 “待识别” 标签。
6. 重新识别:将图片中的所有检测画绘制/调整完成后,点击 “重新识别”PPOCR模型会对当前图片中的**所有检测框**重新识别<sup>[3]</sup>
7. 内容更改:双击识别结果,对不准确的识别结果进行手动更改。
8. 确认标记:点击 “确认”,图片状态切换为 “√”,跳转至下一张(此时不会直接将结果写入文件)。
9. 删除:点击 “删除图像”,图片将会被删除至回收站。
10. 保存结果:用户可以通过菜单中“文件-保存标记结果”手动保存同时程序也会在用户每确认5张图片后自动保存一次。手动确认过的标记将会被存放在所打开图片文件夹下的*Label.txt*中。在菜单栏点击 “文件” - "保存识别结果"后,会将此类图片的识别训练数据保存在*crop_img*文件夹下,识别标签保存在*rec_gt.txt*中<sup>[4]</sup>
### 注意
[1] PPOCRLabel以文件夹为基本标记单位打开待标记的图片文件夹后不会在窗口栏中显示图片而是在点击 "选择文件夹" 之后直接将文件夹下的图片导入到程序中。
[2] 图片状态表示本张图片用户是否手动保存过,未手动保存过即为 “X”手动保存过为 “√”。点击 “自动标注”按钮后PPOCRLabel不会对状态为 “√” 的图片重新标注。
[3] 点击“重新识别”后,模型会对图片中的识别结果进行覆盖。因此如果在此之前手动更改过识别结果,有可能在重新识别后产生变动。
[4] PPOCRLabel产生的文件放置于标记图片文件夹下包括一下几种请勿手动更改其中内容否则会引起程序出现异常。
| 文件名 | 说明 |
| :-----------: | :----------------------------------------------------------: |
| Label.txt | 检测标签可直接用于PPOCR检测模型训练。用户每保存5张检测结果后程序会进行自动写入。当用户关闭应用程序或切换文件路径后同样会进行写入。 |
| fileState.txt | 图片状态标记文件,保存当前文件夹下已经被用户手动确认过的图片名称。 |
| Cache.cach | 缓存文件,保存模型自动识别的结果。 |
| rec_gt.txt | 识别标签。可直接用于PPOCR识别模型训练。需用户手动点击菜单栏“文件” - "保存识别结果"后产生。 |
| crop_img | 识别数据。按照检测框切割后的图片。与rec_gt.txt同时产生。 |
## 说明
### 快捷键
| 快捷键 | 说明 |
| ---------------- | ---------------------------- |
| Ctrl + shift + A | 自动标注所有未确认过的图片 |
| Ctrl + shift + R | 对当前图片的所有标记重新识别 |
| W | 新建矩形框 |
| Q | 新建四点框 |
| Ctrl + E | 编辑所选框标签 |
| Ctrl + R | 重新识别所选标记 |
| Backspace | 删除所选框 |
| Ctrl + V | 确认本张图片标记 |
| Ctrl + Shift + d | 删除本张图片 |
| D | 下一张图片 |
| A | 上一张图片 |
| Ctrl++ | 缩小 |
| Ctrl-- | 放大 |
| ↑→↓← | 移动标记框 |
### 内置模型
- 默认模型PPOCRLabel默认使用PaddleOCR中的中英文超轻量OCR模型支持中英文与数字识别多种语言检测。
- 模型语言切换:用户可通过菜单栏中 "PaddleOCR" - "选择模型" 切换内置模型语言,目前支持的语言包括法文、德文、韩文、日文。具体模型下载链接可参考[PaddleOCR模型列表](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/models_list.md).
- 自定义模型:用户可根据[自定义模型代码使用](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/whl.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9E%8B)通过修改PPOCRLabel.py中针对[PaddleOCR类的实例化](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/PPOCRLabel/PPOCRLabel.py#L110)替换成自己训练的模型。
### 保存方式
PPOCRLabel支持三种保存方式
- 程序自动保存当检测到用户手动确认过5张图片后程序自动将标记结果写入Label.txt中。其中用户可通过更改```PPOCRLabel.py```中的```self.autoSaveNum```的数值设置确认几张图片后进行自动保存。
- 手动保存:点击“文件 - 保存标记结果”手动保存标记。
- 关闭应用程序保存
### 导出部分识别结果
针对部分难以识别的数据,通过在识别结果的复选框中**取消勾选**相应的标记,其识别结果不会被导出。
*注意:识别结果中的复选框状态仍需用户手动点击保存后才能保留*
### 错误提示
- 如果同时使用whl包安装了paddleocr其优先级大于通过paddleocr.py调用PaddleOCR类whl包未更新时会导致程序异常。
- PPOCRLabel**不支持对中文文件名**的图片进行自动标注。
- 针对Linux用户如果您在打开软件过程中出现**objc[XXXXX]**开头的错误证明您的opencv版本太高建议安装4.2版本:
```
pip install opencv-python==4.2.0.32
```
- 如果出现 ```Missing string id``` 开头的错误,需要重新编译资源:
```
pyrcc5 -o libs/resources.py resources.qrc
```
- 如果出现``` module 'cv2' has no attribute 'INTER_NEAREST'```错误需要首先删除所有opencv相关包然后重新安装4.2.0.32版本的headless opencv
```
pip install opencv-contrib-python-headless==4.2.0.32
```
### 参考资料
1.[Tzutalin. LabelImg. Git code (2015)](https://github.com/tzutalin/labelImg)

@ -1,46 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import sys
try:
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QComboBox
except ImportError:
# needed for py3+qt4
# Ref:
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
# http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
if sys.version_info.major >= 3:
import sip
sip.setapi('QVariant', 2)
from PyQt4.QtGui import QWidget, QHBoxLayout, QComboBox
class ComboBox(QWidget):
def __init__(self, parent=None, items=[]):
super(ComboBox, self).__init__(parent)
layout = QHBoxLayout()
self.cb = QComboBox()
self.items = items
self.cb.addItems(self.items)
self.cb.currentIndexChanged.connect(parent.comboSelectionChanged)
layout.addWidget(self.cb)
self.setLayout(layout)
def update_items(self, items):
self.items = items
self.cb.clear()
self.cb.addItems(self.items)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

@ -1,2 +0,0 @@
__version_info__ = ('1', '0', '0')
__version__ = '.'.join(__version_info__)

@ -1,162 +0,0 @@
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
except ImportError:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import json
import cv2
import numpy as np
from libs.utils import newIcon
BB = QDialogButtonBox
class Worker(QThread):
progressBarValue = pyqtSignal(int)
listValue = pyqtSignal(str)
endsignal = pyqtSignal(int, str)
handle = 0
def __init__(self, ocr, mImgList, mainThread, model):
super(Worker, self).__init__()
self.ocr = ocr
self.mImgList = mImgList
self.mainThread = mainThread
self.model = model
self.setStackSize(1024*1024)
def run(self):
try:
findex = 0
for Imgpath in self.mImgList:
if self.handle == 0:
self.listValue.emit(Imgpath)
if self.model == 'paddle':
h, w, _ = cv2.imdecode(np.fromfile(Imgpath, dtype=np.uint8), 1).shape
if h > 32 and w > 32:
self.result_dic = self.ocr.ocr(Imgpath, cls=True, det=True)
else:
print('The size of', Imgpath, 'is too small to be recognised')
self.result_dic = None
# 结果保存
if self.result_dic is None or len(self.result_dic) == 0:
print('Can not recognise file', Imgpath)
pass
else:
strs = ''
for res in self.result_dic:
chars = res[1][0]
cond = res[1][1]
posi = res[0]
strs += "Transcription: " + chars + " Probability: " + str(cond) + \
" Location: " + json.dumps(posi) +'\n'
# Sending large amounts of data repeatedly through pyqtSignal may affect the program efficiency
self.listValue.emit(strs)
self.mainThread.result_dic = self.result_dic
self.mainThread.filePath = Imgpath
# 保存
self.mainThread.saveFile(mode='Auto')
findex += 1
self.progressBarValue.emit(findex)
else:
break
self.endsignal.emit(0, "readAll")
self.exec()
except Exception as e:
print(e)
raise
class AutoDialog(QDialog):
def __init__(self, text="Enter object label", parent=None, ocr=None, mImgList=None, lenbar=0):
super(AutoDialog, self).__init__(parent)
self.setFixedWidth(1000)
self.parent = parent
self.ocr = ocr
self.mImgList = mImgList
self.pb = QProgressBar()
self.pb.setRange(0, lenbar)
self.pb.setValue(0)
layout = QVBoxLayout()
layout.addWidget(self.pb)
self.model = 'paddle'
self.listWidget = QListWidget(self)
layout.addWidget(self.listWidget)
self.buttonBox = bb = BB(BB.Ok | BB.Cancel, Qt.Horizontal, self)
bb.button(BB.Ok).setIcon(newIcon('done'))
bb.button(BB.Cancel).setIcon(newIcon('undo'))
bb.accepted.connect(self.validate)
bb.rejected.connect(self.reject)
layout.addWidget(bb)
bb.button(BB.Ok).setEnabled(False)
self.setLayout(layout)
# self.setWindowTitle("自动标注中")
self.setWindowModality(Qt.ApplicationModal)
# self.setWindowFlags(Qt.WindowCloseButtonHint)
self.thread_1 = Worker(self.ocr, self.mImgList, self.parent, 'paddle')
self.thread_1.progressBarValue.connect(self.handleProgressBarSingal)
self.thread_1.listValue.connect(self.handleListWidgetSingal)
self.thread_1.endsignal.connect(self.handleEndsignalSignal)
def handleProgressBarSingal(self, i):
self.pb.setValue(i)
def handleListWidgetSingal(self, i):
self.listWidget.addItem(i)
titem = self.listWidget.item(self.listWidget.count() - 1)
self.listWidget.scrollToItem(titem)
def handleEndsignalSignal(self, i, str):
if i == 0 and str == "readAll":
self.buttonBox.button(BB.Ok).setEnabled(True)
self.buttonBox.button(BB.Cancel).setEnabled(False)
def reject(self):
print("reject")
self.thread_1.handle = -1
self.thread_1.quit()
# del self.thread_1
# if self.thread_1.isRunning():
# self.thread_1.terminate()
# self.thread_1.quit()
# super(AutoDialog,self).reject()
while not self.thread_1.isFinished():
pass
self.accept()
def validate(self):
self.accept()
def postProcess(self):
try:
self.edit.setText(self.edit.text().trimmed())
# print(self.edit.text())
except AttributeError:
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
self.edit.setText(self.edit.text())
print(self.edit.text())
def popUp(self):
self.thread_1.start()
return 1 if self.exec_() else None
def closeEvent(self, event):
print("???")
# if self.thread_1.isRunning():
# self.thread_1.quit()
#
# # self._thread.terminate()
# # del self.thread_1
# super(AutoDialog, self).closeEvent(event)
self.reject()

File diff suppressed because it is too large Load Diff

@ -1,49 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QColorDialog, QDialogButtonBox
except ImportError:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
BB = QDialogButtonBox
class ColorDialog(QColorDialog):
def __init__(self, parent=None):
super(ColorDialog, self).__init__(parent)
self.setOption(QColorDialog.ShowAlphaChannel)
# The Mac native dialog does not support our restore button.
self.setOption(QColorDialog.DontUseNativeDialog)
# Add a restore defaults button.
# The default is set at invocation time, so that it
# works across dialogs for different elements.
self.default = None
self.bb = self.layout().itemAt(1).widget()
self.bb.addButton(BB.RestoreDefaults)
self.bb.clicked.connect(self.checkRestore)
def getColor(self, value=None, title=None, default=None):
self.default = default
if title:
self.setWindowTitle(title)
if value:
self.setCurrentColor(value)
return self.currentColor() if self.exec_() else None
def checkRestore(self, button):
if self.bb.buttonRole(button) & BB.ResetRole and self.default:
self.setCurrentColor(self.default)

@ -1,31 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
SETTING_FILENAME = 'filename'
SETTING_RECENT_FILES = 'recentFiles'
SETTING_WIN_SIZE = 'window/size'
SETTING_WIN_POSE = 'window/position'
SETTING_WIN_GEOMETRY = 'window/geometry'
SETTING_LINE_COLOR = 'line/color'
SETTING_FILL_COLOR = 'fill/color'
SETTING_ADVANCE_MODE = 'advanced'
SETTING_WIN_STATE = 'window/state'
SETTING_SAVE_DIR = 'savedir'
SETTING_PAINT_LABEL = 'paintlabel'
SETTING_LAST_OPEN_DIR = 'lastOpenDir'
SETTING_AUTO_SAVE = 'autosave'
SETTING_SINGLE_CLASS = 'singleclass'
FORMAT_PASCALVOC='PascalVOC'
FORMAT_YOLO='YOLO'
SETTING_DRAW_SQUARE = 'draw/square'
SETTING_LABEL_FILE_FORMAT= 'labelFileFormat'
DEFAULT_ENCODING = 'utf-8'

@ -1,143 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#!/usr/bin/env python
# -*- coding: utf8 -*-
import json
from pathlib import Path
from libs.constants import DEFAULT_ENCODING
import os
JSON_EXT = '.json'
ENCODE_METHOD = DEFAULT_ENCODING
class CreateMLWriter:
def __init__(self, foldername, filename, imgsize, shapes, outputfile, databasesrc='Unknown', localimgpath=None):
self.foldername = foldername
self.filename = filename
self.databasesrc = databasesrc
self.imgsize = imgsize
self.boxlist = []
self.localimgpath = localimgpath
self.verified = False
self.shapes = shapes
self.outputfile = outputfile
def write(self):
if os.path.isfile(self.outputfile):
with open(self.outputfile, "r") as file:
input_data = file.read()
outputdict = json.loads(input_data)
else:
outputdict = []
outputimagedict = {
"image": self.filename,
"annotations": []
}
for shape in self.shapes:
points = shape["points"]
x1 = points[0][0]
y1 = points[0][1]
x2 = points[1][0]
y2 = points[2][1]
height, width, x, y = self.calculate_coordinates(x1, x2, y1, y2)
shapedict = {
"label": shape["label"],
"coordinates": {
"x": x,
"y": y,
"width": width,
"height": height
}
}
outputimagedict["annotations"].append(shapedict)
# check if image already in output
exists = False
for i in range(0, len(outputdict)):
if outputdict[i]["image"] == outputimagedict["image"]:
exists = True
outputdict[i] = outputimagedict
break
if not exists:
outputdict.append(outputimagedict)
Path(self.outputfile).write_text(json.dumps(outputdict), ENCODE_METHOD)
def calculate_coordinates(self, x1, x2, y1, y2):
if x1 < x2:
xmin = x1
xmax = x2
else:
xmin = x2
xmax = x1
if y1 < y2:
ymin = y1
ymax = y2
else:
ymin = y2
ymax = y1
width = xmax - xmin
if width < 0:
width = width * -1
height = ymax - ymin
# x and y from center of rect
x = xmin + width / 2
y = ymin + height / 2
return height, width, x, y
class CreateMLReader:
def __init__(self, jsonpath, filepath):
self.jsonpath = jsonpath
self.shapes = []
self.verified = False
self.filename = filepath.split("/")[-1:][0]
try:
self.parse_json()
except ValueError:
print("JSON decoding failed")
def parse_json(self):
with open(self.jsonpath, "r") as file:
inputdata = file.read()
outputdict = json.loads(inputdata)
self.verified = True
if len(self.shapes) > 0:
self.shapes = []
for image in outputdict:
if image["image"] == self.filename:
for shape in image["annotations"]:
self.add_shape(shape["label"], shape["coordinates"])
def add_shape(self, label, bndbox):
xmin = bndbox["x"] - (bndbox["width"] / 2)
ymin = bndbox["y"] - (bndbox["height"] / 2)
xmax = bndbox["x"] + (bndbox["width"] / 2)
ymax = bndbox["y"] + (bndbox["height"] / 2)
points = [(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)]
self.shapes.append((label, points, None, None, True))
def get_shapes(self):
return self.shapes

@ -1,31 +0,0 @@
import sys, time
from PyQt5 import QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class EditInList(QListWidget):
def __init__(self):
super(EditInList,self).__init__()
# click to edit
self.clicked.connect(self.item_clicked)
def item_clicked(self, modelindex: QModelIndex) -> None:
self.edited_item = self.currentItem()
self.closePersistentEditor(self.edited_item)
item = self.item(modelindex.row())
# time.sleep(0.2)
self.edited_item = item
self.openPersistentEditor(item)
# time.sleep(0.2)
self.editItem(item)
def mouseDoubleClickEvent(self, event):
# close edit
for i in range(self.count()):
self.closePersistentEditor(self.item(i))
def leaveEvent(self, event):
# close edit
for i in range(self.count()):
self.closePersistentEditor(self.item(i))

@ -1,40 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
except ImportError:
# needed for py3+qt4
# Ref:
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
# http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
if sys.version_info.major >= 3:
import sip
sip.setapi('QVariant', 2)
from PyQt4.QtGui import *
from PyQt4.QtCore import *
# PyQt5: TypeError: unhashable type: 'QListWidgetItem'
class HashableQListWidgetItem(QListWidgetItem):
def __init__(self, *args):
super(HashableQListWidgetItem, self).__init__(*args)
def __hash__(self):
return hash(id(self))

@ -1,107 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
except ImportError:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from libs.utils import newIcon, labelValidator
BB = QDialogButtonBox
class LabelDialog(QDialog):
def __init__(self, text="Enter object label", parent=None, listItem=None):
super(LabelDialog, self).__init__(parent)
self.edit = QLineEdit() # OLD
# self.edit = QTextEdit()
self.edit.setText(text)
# self.edit.setValidator(labelValidator()) # 验证有效性
self.edit.editingFinished.connect(self.postProcess)
model = QStringListModel()
model.setStringList(listItem)
completer = QCompleter()
completer.setModel(model)
self.edit.setCompleter(completer)
layout = QVBoxLayout()
layout.addWidget(self.edit)
self.buttonBox = bb = BB(BB.Ok | BB.Cancel, Qt.Horizontal, self)
bb.button(BB.Ok).setIcon(newIcon('done'))
bb.button(BB.Cancel).setIcon(newIcon('undo'))
bb.accepted.connect(self.validate)
bb.rejected.connect(self.reject)
layout.addWidget(bb)
# if listItem is not None and len(listItem) > 0:
# self.listWidget = QListWidget(self)
# for item in listItem:
# self.listWidget.addItem(item)
# self.listWidget.itemClicked.connect(self.listItemClick)
# self.listWidget.itemDoubleClicked.connect(self.listItemDoubleClick)
# layout.addWidget(self.listWidget)
self.setLayout(layout)
def validate(self):
try:
if self.edit.text().trimmed():
self.accept()
except AttributeError:
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
if self.edit.text().strip():
self.accept()
def postProcess(self):
try:
self.edit.setText(self.edit.text().trimmed())
# print(self.edit.text())
except AttributeError:
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
self.edit.setText(self.edit.text())
print(self.edit.text())
def popUp(self, text='', move=True):
self.edit.setText(text)
self.edit.setSelection(0, len(text))
self.edit.setFocus(Qt.PopupFocusReason)
if move:
cursor_pos = QCursor.pos()
parent_bottomRight = self.parentWidget().geometry()
max_x = parent_bottomRight.x() + parent_bottomRight.width() - self.sizeHint().width()
max_y = parent_bottomRight.y() + parent_bottomRight.height() - self.sizeHint().height()
max_global = self.parentWidget().mapToGlobal(QPoint(max_x, max_y))
if cursor_pos.x() > max_global.x():
cursor_pos.setX(max_global.x())
if cursor_pos.y() > max_global.y():
cursor_pos.setY(max_global.y())
self.move(cursor_pos)
return self.edit.text() if self.exec_() else None
def listItemClick(self, tQListWidgetItem):
try:
text = tQListWidgetItem.text().trimmed()
except AttributeError:
# PyQt5: AttributeError: 'str' object has no attribute 'trimmed'
text = tQListWidgetItem.text().strip()
self.edit.setText(text)
def listItemDoubleClick(self, tQListWidgetItem):
self.listItemClick(tQListWidgetItem)
self.validate()

File diff suppressed because it is too large Load Diff

@ -1,60 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import pickle
import os
import sys
class Settings(object):
def __init__(self):
# Be default, the home will be in the same folder as labelImg
home = os.path.expanduser("~")
self.data = {}
# self.path = os.path.join(home, '.labelImgSettings.pkl')
self.path = os.path.join(home, '.autoOCRSettings.pkl')
def __setitem__(self, key, value):
self.data[key] = value
def __getitem__(self, key):
return self.data[key]
def get(self, key, default=None):
if key in self.data:
return self.data[key]
return default
def save(self):
if self.path:
with open(self.path, 'wb') as f:
pickle.dump(self.data, f, pickle.HIGHEST_PROTOCOL)
return True
return False
def load(self):
try:
if os.path.exists(self.path):
with open(self.path, 'rb') as f:
self.data = pickle.load(f)
return True
except:
print('Loading setting failed')
return False
def reset(self):
if os.path.exists(self.path):
os.remove(self.path)
print('Remove setting pkl file ${0}'.format(self.path))
self.data = {}
self.path = None

@ -1,217 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#!/usr/bin/python
# -*- coding: utf-8 -*-
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
except ImportError:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from libs.utils import distance
import sys
DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
DEFAULT_SELECT_LINE_COLOR = QColor(255, 255, 255)
DEFAULT_SELECT_FILL_COLOR = QColor(0, 128, 255, 155)
DEFAULT_VERTEX_FILL_COLOR = QColor(0, 255, 0, 255)
DEFAULT_HVERTEX_FILL_COLOR = QColor(255, 0, 0)
MIN_Y_LABEL = 10
class Shape(object):
P_SQUARE, P_ROUND = range(2)
MOVE_VERTEX, NEAR_VERTEX = range(2)
# The following class variables influence the drawing
# of _all_ shape objects.
line_color = DEFAULT_LINE_COLOR
fill_color = DEFAULT_FILL_COLOR
select_line_color = DEFAULT_SELECT_LINE_COLOR
select_fill_color = DEFAULT_SELECT_FILL_COLOR
vertex_fill_color = DEFAULT_VERTEX_FILL_COLOR
hvertex_fill_color = DEFAULT_HVERTEX_FILL_COLOR
point_type = P_ROUND
point_size = 8
scale = 1.0
def __init__(self, label=None, line_color=None, difficult=False, paintLabel=False):
self.label = label
self.points = []
self.fill = False
self.selected = False
self.difficult = difficult
self.paintLabel = paintLabel
self._highlightIndex = None
self._highlightMode = self.NEAR_VERTEX
self._highlightSettings = {
self.NEAR_VERTEX: (4, self.P_ROUND),
self.MOVE_VERTEX: (1.5, self.P_SQUARE),
}
self._closed = False
if line_color is not None:
# Override the class line_color attribute
# with an object attribute. Currently this
# is used for drawing the pending line a different color.
self.line_color = line_color
def close(self):
self._closed = True
def reachMaxPoints(self):
if len(self.points) >= 4:
return True
return False
def addPoint(self, point):
if not self.reachMaxPoints():
self.points.append(point)
def popPoint(self):
if self.points:
return self.points.pop()
return None
def isClosed(self):
return self._closed
def setOpen(self):
self._closed = False
def paint(self, painter):
if self.points:
color = self.select_line_color if self.selected else self.line_color
pen = QPen(color)
# Try using integer sizes for smoother drawing(?)
pen.setWidth(max(1, int(round(2.0 / self.scale))))
painter.setPen(pen)
line_path = QPainterPath()
vrtx_path = QPainterPath()
line_path.moveTo(self.points[0])
# Uncommenting the following line will draw 2 paths
# for the 1st vertex, and make it non-filled, which
# may be desirable.
#self.drawVertex(vrtx_path, 0)
for i, p in enumerate(self.points):
line_path.lineTo(p)
self.drawVertex(vrtx_path, i)
if self.isClosed():
line_path.lineTo(self.points[0])
painter.drawPath(line_path)
painter.drawPath(vrtx_path)
painter.fillPath(vrtx_path, self.vertex_fill_color)
# Draw text at the top-left
if self.paintLabel:
min_x = sys.maxsize
min_y = sys.maxsize
for point in self.points:
min_x = min(min_x, point.x())
min_y = min(min_y, point.y())
if min_x != sys.maxsize and min_y != sys.maxsize:
font = QFont()
font.setPointSize(8)
font.setBold(True)
painter.setFont(font)
if(self.label == None):
self.label = ""
if(min_y < MIN_Y_LABEL):
min_y += MIN_Y_LABEL
painter.drawText(min_x, min_y, self.label)
if self.fill:
color = self.select_fill_color if self.selected else self.fill_color
painter.fillPath(line_path, color)
def drawVertex(self, path, i):
d = self.point_size / self.scale
shape = self.point_type
point = self.points[i]
if i == self._highlightIndex:
size, shape = self._highlightSettings[self._highlightMode]
d *= size
if self._highlightIndex is not None:
self.vertex_fill_color = self.hvertex_fill_color
else:
self.vertex_fill_color = Shape.vertex_fill_color
if shape == self.P_SQUARE:
path.addRect(point.x() - d / 2, point.y() - d / 2, d, d)
elif shape == self.P_ROUND:
path.addEllipse(point, d / 2.0, d / 2.0)
else:
assert False, "unsupported vertex shape"
def nearestVertex(self, point, epsilon):
for i, p in enumerate(self.points):
if distance(p - point) <= epsilon:
return i
return None
def containsPoint(self, point):
return self.makePath().contains(point)
def makePath(self):
path = QPainterPath(self.points[0])
for p in self.points[1:]:
path.lineTo(p)
return path
def boundingRect(self):
return self.makePath().boundingRect()
def moveBy(self, offset):
self.points = [p + offset for p in self.points]
def moveVertexBy(self, i, offset):
self.points[i] = self.points[i] + offset
def highlightVertex(self, i, action):
self._highlightIndex = i
self._highlightMode = action
def highlightClear(self):
self._highlightIndex = None
def copy(self):
shape = Shape("%s" % self.label)
shape.points = [p for p in self.points]
shape.fill = self.fill
shape.selected = self.selected
shape._closed = self._closed
if self.line_color != Shape.line_color:
shape.line_color = self.line_color
if self.fill_color != Shape.fill_color:
shape.fill_color = self.fill_color
shape.difficult = self.difficult
return shape
def __len__(self):
return len(self.points)
def __getitem__(self, key):
return self.points[key]
def __setitem__(self, key, value):
self.points[key] = value

@ -1,86 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import sys
import locale
from libs.ustr import ustr
try:
from PyQt5.QtCore import *
except ImportError:
if sys.version_info.major >= 3:
import sip
sip.setapi('QVariant', 2)
from PyQt4.QtCore import *
class StringBundle:
__create_key = object()
def __init__(self, create_key, localeStr):
assert(create_key == StringBundle.__create_key), "StringBundle must be created using StringBundle.getBundle"
self.idToMessage = {}
paths = self.__createLookupFallbackList(localeStr)
for path in paths:
self.__loadBundle(path)
@classmethod
def getBundle(cls, localeStr=None):
if localeStr is None:
try:
localeStr = locale.getlocale()[0] if locale.getlocale() and len(
locale.getlocale()) > 0 else os.getenv('LANG')
except:
print('Invalid locale')
localeStr = 'en'
return StringBundle(cls.__create_key, localeStr)
def getString(self, stringId):
assert(stringId in self.idToMessage), "Missing string id : " + stringId
return self.idToMessage[stringId]
def __createLookupFallbackList(self, localeStr):
resultPaths = []
basePath = ":/strings"
resultPaths.append(basePath)
if localeStr is not None:
# Don't follow standard BCP47. Simple fallback
tags = re.split('[^a-zA-Z]', localeStr)
for tag in tags:
lastPath = resultPaths[-1]
resultPaths.append(lastPath + '-' + tag)
return resultPaths
def __loadBundle(self, path):
PROP_SEPERATOR = '='
f = QFile(path)
if f.exists():
if f.open(QIODevice.ReadOnly | QFile.Text):
text = QTextStream(f)
text.setCodec("UTF-8")
while not text.atEnd():
line = ustr(text.readLine())
key_value = line.split(PROP_SEPERATOR)
key = key_value[0].strip()
value = PROP_SEPERATOR.join(key_value[1:]).strip().strip('"')
self.idToMessage[key] = value
f.close()

@ -1,51 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
try:
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
except ImportError:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class ToolBar(QToolBar):
def __init__(self, title):
super(ToolBar, self).__init__(title)
layout = self.layout()
m = (0, 0, 0, 0)
layout.setSpacing(0)
layout.setContentsMargins(*m)
self.setContentsMargins(*m)
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
def addAction(self, action):
if isinstance(action, QWidgetAction):
return super(ToolBar, self).addAction(action)
btn = ToolButton()
btn.setDefaultAction(action)
btn.setToolButtonStyle(self.toolButtonStyle())
self.addWidget(btn)
class ToolButton(QToolButton):
"""ToolBar companion class which ensures all buttons have the same size."""
minSize = (60, 60)
def minimumSizeHint(self):
ms = super(ToolButton, self).minimumSizeHint()
w1, h1 = ms.width(), ms.height()
w2, h2 = self.minSize
ToolButton.minSize = max(w1, w2), max(h1, h2)
return QSize(*ToolButton.minSize)

@ -1,29 +0,0 @@
# Copyright (c) <2015-Present> Tzutalin
# Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
# William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction, including without
# limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import sys
from libs.constants import DEFAULT_ENCODING
def ustr(x):
'''py2/py3 unicode helper'''
if sys.version_info < (3, 0, 0):
from PyQt4.QtCore import QString
if type(x) == str:
return x.decode(DEFAULT_ENCODING)
if type(x) == QString:
#https://blog.csdn.net/friendan/article/details/51088476
#https://blog.csdn.net/xxm524/article/details/74937308
return unicode(x.toUtf8(), DEFAULT_ENCODING, 'ignore')
return x
else:
return x

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save