{"id":16707,"date":"2024-12-30T16:35:33","date_gmt":"2024-12-30T08:35:33","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=16707"},"modified":"2025-11-18T17:04:49","modified_gmt":"2025-11-18T09:04:49","slug":"anytext","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/de\/anytext\/","title":{"rendered":"AnyText"},"content":{"rendered":"<p>AnyText\u662f\u4e00\u4e2a\u9769\u547d\u6027\u7684\u591a\u8bed\u8a00\u89c6\u89c9\u6587\u672c\u751f\u6210\u548c\u7f16\u8f91\u5de5\u5177\uff0c\u57fa\u4e8e\u6269\u6563\u6a21\u578b\u5f00\u53d1\u3002\u5b83\u80fd\u591f\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u81ea\u7136\u3001\u9ad8\u8d28\u91cf\u7684\u591a\u8bed\u79cd\u6587\u672c\uff0c\u5e76\u652f\u6301\u7075\u6d3b\u7684\u6587\u672c\u7f16\u8f91\u529f\u80fd\u3002\u8be5\u9879\u76ee\u7531\u7814\u7a76\u56e2\u961f\u5f00\u53d1\uff0c\u5e76\u5728ICLR 2024\u4f1a\u8bae\u4e0a\u83b7\u5f97Spotlight\u8363\u8a89\u3002AnyText\u7684\u6838\u5fc3\u4f18\u52bf\u5728\u4e8e\u5176\u72ec\u7279\u7684\u53cc\u6a21\u5757\u67b6\u6784\uff1a\u8f85\u52a9\u6f5c\u5728\u6a21\u5757\u8d1f\u8d23\u7f16\u7801\u6587\u672c\u5b57\u5f62\u3001\u4f4d\u7f6e\u548c\u8499\u7248\u56fe\u50cf\u4fe1\u606f\uff0c\u6587\u672c\u5d4c\u5165\u6a21\u5757\u5219\u5229\u7528OCR\u6a21\u578b\u5904\u7406\u7b14\u753b\u6570\u636e\u3002\u9879\u76ee\u8fd8\u63d0\u4f9b\u4e86AnyWord-3M\u6570\u636e\u96c6\uff0c\u8fd9\u662f\u9996\u4e2a\u5305\u542b300\u4e07\u5bf9\u5e26\u6709OCR\u6807\u6ce8\u7684\u591a\u8bed\u8a00\u6587\u672c\u56fe\u50cf\u6570\u636e\u96c6\uff0c\u4e3a\u89c6\u89c9\u6587\u672c\u751f\u6210\u9886\u57df\u63d0\u4f9b\u4e86\u91cd\u8981\u7684\u8bc4\u4f30\u57fa\u51c6\u3002<\/p>\n<p><img decoding=\"async\" title=\"AnyText\uff1a\u751f\u6210\u548c\u7f16\u8f91\u591a\u8bed\u8a00\u56fe\u50cf\u6587\u672c\uff0c\u53ef\u63a7\u7684\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u4e2d\u6587-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/ac34f01cb58e1bb.jpg\" alt=\"AnyText\uff1a\u751f\u6210\u548c\u7f16\u8f91\u591a\u8bed\u8a00\u56fe\u50cf\u6587\u672c\uff0c\u53ef\u63a7\u7684\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u4e2d\u6587-1\" \/><\/p>\n<p>&nbsp;<\/p>\n<dl>\n<dt>\n<p><div style=\"width: 1502px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" title=\"AnyText\uff1a\u751f\u6210\u548c\u7f16\u8f91\u591a\u8bed\u8a00\u56fe\u50cf\u6587\u672c\uff0c\u53ef\u63a7\u7684\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u4e2d\u6587-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/b30d39c6cadfd72.png\" alt=\"AnyText\uff1a\u751f\u6210\u548c\u7f16\u8f91\u591a\u8bed\u8a00\u56fe\u50cf\u6587\u672c\uff0c\u53ef\u63a7\u7684\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u4e2d\u6587-1\" width=\"1492\" height=\"902\" \/><p class=\"wp-caption-text\">\u4f53\u9a8c\u5730\u5740\uff1ahttps:\/\/modelscope.cn\/studios\/damo\/studio_anytext\/summary<\/p><\/div><\/dt>\n<dt><\/dt>\n<\/dl>\n<p>\u5907\u7528\u5730\u5740\uff1ahttps:\/\/huggingface.co\/spaces\/modelscope\/AnyText<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li>\u591a\u8bed\u8a00\u6587\u672c\u751f\u6210\uff1a\u652f\u6301\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u591a\u79cd\u8bed\u8a00\u7684\u6587\u672c<\/li>\n<li>\u6587\u672c\u7f16\u8f91\uff1a\u53ef\u4ee5\u7f16\u8f91\u548c\u4fee\u6539\u5df2\u6709\u56fe\u50cf\u4e2d\u7684\u6587\u672c\u5185\u5bb9<\/li>\n<li>\u6837\u5f0f\u63a7\u5236\uff1a\u652f\u6301\u901a\u8fc7\u57fa\u7840\u6a21\u578b\u6216LoRA\u6a21\u578b\u66f4\u6539\u751f\u6210\u6587\u672c\u7684\u6837\u5f0f<\/li>\n<li>FP16\u63a8\u7406\u52a0\u901f\uff1a\u652f\u6301\u5feb\u901f\u63a8\u7406\uff0c\u53ef\u57288GB\u4ee5\u4e0a\u663e\u5b58\u7684GPU\u4e0a\u8fd0\u884c<\/li>\n<li>\u4e2d\u82f1\u6587\u7ffb\u8bd1\uff1a\u5185\u7f6e\u4e2d\u82f1\u6587\u7ffb\u8bd1\u6a21\u578b\uff0c\u652f\u6301\u76f4\u63a5\u8f93\u5165\u4e2d\u6587\u63d0\u793a\u8bcd<\/li>\n<li>\u81ea\u5b9a\u4e49\u5b57\u4f53\uff1a\u5141\u8bb8\u7528\u6237\u4f7f\u7528\u81ea\u5df1\u7684\u5b57\u4f53\u6587\u4ef6<\/li>\n<li>\u6279\u91cf\u5904\u7406\uff1a\u652f\u6301\u6279\u91cf\u751f\u6210\u548c\u7f16\u8f91\u56fe\u50cf\u6587\u672c<\/li>\n<li>\u6a21\u578b\u5408\u5e76\uff1a\u652f\u6301\u5408\u5e76\u793e\u533a\u6a21\u578b\u548cLoRA\u6a21\u578b\u7684\u6743\u91cd<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>1. \u73af\u5883\u5b89\u88c5<\/h3>\n<ol>\n<li>\u9996\u5148\u786e\u4fdd\u7cfb\u7edf\u5df2\u5b89\u88c5Git\uff1a<\/li>\n<\/ol>\n<pre><code>conda install -c anaconda git\r\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u514b\u9686\u9879\u76ee\u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre><code>git clone https:\/\/github.com\/tyxsspa\/AnyText.git\r\ncd AnyText\r\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u51c6\u5907\u5b57\u4f53\u6587\u4ef6\uff08\u63a8\u8350\u4f7f\u7528Arial Unicode MS\uff09\uff1a<\/li>\n<\/ol>\n<pre><code>mv your\/path\/to\/arialuni.ttf .\/font\/Arial_Unicode.ttf\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u521b\u5efa\u5e76\u6fc0\u6d3b\u73af\u5883\uff1a<\/li>\n<\/ol>\n<pre><code>conda env create -f environment.yaml\r\nconda activate anytext\r\n<\/code><\/pre>\n<h3>2. \u4f7f\u7528\u65b9\u6cd5<\/h3>\n<h4>2.1 \u5feb\u901f\u5f00\u59cb<\/h4>\n<p>\u6700\u7b80\u5355\u7684\u9a8c\u8bc1\u65b9\u5f0f\u662f\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>python inference.py\r\n<\/code><\/pre>\n<h4>2.2 \u542f\u52a8\u4ea4\u4e92\u5f0f\u6f14\u793a<\/h4>\n<p>\u5bf9\u4e8e\u914d\u7f6e\u8f83\u597d\u7684GPU\uff088GB\u4ee5\u4e0a\u663e\u5b58\uff09\uff0c\u63a8\u8350\u4f7f\u7528\u6f14\u793a\u754c\u9762\uff1a<\/p>\n<pre><code>export CUDA_VISIBLE_DEVICES=0 &amp;&amp; python demo.py\r\n<\/code><\/pre>\n<h4>2.3 \u9ad8\u7ea7\u914d\u7f6e<\/h4>\n<ul>\n<li>\u4f7f\u7528FP32\u7cbe\u5ea6\u548c\u7981\u7528\u7ffb\u8bd1\u5668\uff1a<\/li>\n<\/ul>\n<pre><code>export CUDA_VISIBLE_DEVICES=0 &amp;&amp; python demo.py --use_fp32 --no_translator\r\n<\/code><\/pre>\n<ul>\n<li>\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\uff1a<\/li>\n<\/ul>\n<pre><code>export CUDA_VISIBLE_DEVICES=0 &amp;&amp; python demo.py --font_path your\/path\/to\/font\/file.ttf\r\n<\/code><\/pre>\n<ul>\n<li>\u52a0\u8f7d\u7279\u5b9a\u7684\u68c0\u67e5\u70b9\uff1a<\/li>\n<\/ul>\n<pre><code>export CUDA_VISIBLE_DEVICES=0 &amp;&amp; python demo.py --model_path your\/path\/to\/your\/own\/anytext.ckpt\r\n<\/code><\/pre>\n<h3>3. \u6837\u5f0f\u8c03\u6574<\/h3>\n<p>\u5728\u6f14\u793a\u754c\u9762\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u8c03\u6574\u751f\u6210\u6587\u672c\u7684\u6837\u5f0f\uff1a<\/p>\n<ol>\n<li>\u66f4\u6539\u57fa\u7840\u6a21\u578b\uff1a\u5728[Base Model Path]\u4e2d\u586b\u5165\u672c\u5730\u57fa\u7840\u6a21\u578b\u7684\u8def\u5f84<\/li>\n<li>\u52a0\u8f7dLoRA\u6a21\u578b\uff1a\u5728[LoRA Path and Ratio]\u4e2d\u8f93\u5165LoRA\u6a21\u578b\u8def\u5f84\u548c\u6743\u91cd\u6bd4\u4f8b\uff0c\u4f8b\u5982\uff1a<\/li>\n<\/ol>\n<pre><code>\/path\/of\/lora1.pth 0.3 \/path\/of\/lora2.safetensors 0.6\r\n<\/code><\/pre>\n<h3>4. \u6027\u80fd\u4f18\u5316<\/h3>\n<ul>\n<li>\u9ed8\u8ba4\u4f7f\u7528FP16\u63a8\u7406\uff0c\u540c\u65f6\u52a0\u8f7d\u4e2d\u82f1\u6587\u7ffb\u8bd1\u6a21\u578b\uff08\u5360\u7528\u7ea64GB\u663e\u5b58\uff09<\/li>\n<li>\u5982\u679c\u4f7f\u7528FP16\u4e14\u4e0d\u4f7f\u7528\u7ffb\u8bd1\u6a21\u578b\uff0c\u751f\u6210\u5355\u5f20512&#215;512\u56fe\u50cf\u4ec5\u9700\u7ea67.5GB\u663e\u5b58<\/li>\n<li>\u9996\u6b21\u8fd0\u884c\u65f6\uff0c\u6a21\u578b\u6587\u4ef6\u4f1a\u4e0b\u8f7d\u5230<code>~\/.cache\/modelscope\/hub<\/code>\u76ee\u5f55<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<code>MODELSCOPE_CACHE<\/code>\u4fee\u6539\u4e0b\u8f7d\u76ee\u5f55<\/li>\n<\/ul>\n<h3>5. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<ol>\n<li>\u786e\u4fdd\u5b89\u88c5\u4e86\u6b63\u786e\u7248\u672c\u7684\u4f9d\u8d56\u5305<\/li>\n<li>\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u53ef\u80fd\u4f1a\u5f71\u54cd\u751f\u6210\u6548\u679c<\/li>\n<li>\u6a21\u578b\u9996\u6b21\u8fd0\u884c\u9700\u8981\u4e0b\u8f7d\u76f8\u5173\u6587\u4ef6<\/li>\n<li>\u5efa\u8bae\u4f7f\u75288GB\u53ca\u4ee5\u4e0a\u663e\u5b58\u7684GPU\u8fd0\u884c<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3>AnyText\u751f\u6210\u56fe\u7247\u64cd\u4f5c\u8bf4\u660e<\/h3>\n<p><strong>\u8fd0\u884c\u793a\u4f8b<\/strong><\/p>\n<p>AnyText\u6709\u4e24\u79cd\u8fd0\u884c\u6a21\u5f0f\uff1a\u6587\u5b57\u751f\u6210\u548c\u6587\u5b57\u7f16\u8f91\uff0c\u6bcf\u79cd\u6a21\u5f0f\u4e0b\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u793a\u4f8b\uff0c\u9009\u62e9\u4e00\u4e2a\uff0c\u70b9\u51fb[Run!]\u5373\u53ef\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u8fd0\u884c\u793a\u4f8b\u524d\u786e\u4fdd\u624b\u7ed8\u4f4d\u7f6e\u533a\u57df\u662f\u7a7a\u7684\uff0c\u9632\u6b62\u5f71\u54cd\u793a\u4f8b\u7ed3\u679c\uff0c\u53e6\u5916\u4e0d\u540c\u793a\u4f8b\u4f7f\u7528\u4e0d\u540c\u7684\u53c2\u6570\uff08\u5982\u5206\u8fa8\u7387\uff0c\u79cd\u5b50\u6570\u7b49\uff09\uff0c\u5982\u679c\u8981\u81ea\u884c\u751f\u6210\u65f6\uff0c\u8bf7\u7559\u610f\u53c2\u6570\u53d8\u5316\uff0c\u6216\u5237\u65b0\u9875\u9762\u6062\u590d\u5230\u9ed8\u8ba4\u53c2\u6570\u3002<\/p>\n<p><strong>\u6587\u5b57\u751f\u6210<\/strong><\/p>\n<p>\u5728Prompt\u4e2d\u8f93\u5165\u63cf\u8ff0\u63d0\u793a\u8bcd\uff08\u652f\u6301\u4e2d\u82f1\u6587\uff09\uff0c\u9700\u8981\u751f\u6210\u7684\u6bcf\u4e00\u884c\u6587\u5b57\u7528\u53cc\u5f15\u53f7\u5305\u88f9\uff0c\u7136\u540e\u4f9d\u6b21\u624b\u7ed8\u6307\u5b9a\u6bcf\u884c\u6587\u5b57\u7684\u4f4d\u7f6e\uff0c\u751f\u6210\u56fe\u7247\u3002 \u6587\u5b57\u4f4d\u7f6e\u7684\u7ed8\u5236\u5bf9\u6210\u56fe\u8d28\u91cf\u5f88\u5173\u952e, \u8bf7\u4e0d\u8981\u753b\u7684\u592a\u968f\u610f\u6216\u592a\u5c0f\uff0c\u4f4d\u7f6e\u7684\u6570\u91cf\u8981\u4e0e\u6587\u5b57\u884c\u6570\u91cf\u4e00\u81f4\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u7684\u5c3a\u5bf8\u8981\u4e0e\u5bf9\u5e94\u7684\u6587\u5b57\u884c\u7684\u957f\u77ed\u6216\u5bbd\u9ad8\u5c3d\u91cf\u5339\u914d\u3002\u5982\u679c\u624b\u7ed8\uff08Manual-draw\uff09\u4e0d\u65b9\u4fbf\uff0c \u53ef\u4ee5\u5c1d\u8bd5\u62d6\u6846\u77e9\u5f62\uff08Manual-rect\uff09\u6216\u968f\u673a\u751f\u6210\uff08Auto-rand\uff09\u3002<\/p>\n<p>\u591a\u884c\u751f\u6210\u65f6\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u6309\u7167\u4e00\u5b9a\u89c4\u5219\u6392\u5e8f\u540e\u4e0e\u6587\u5b57\u884c\u505a\u5bf9\u5e94\uff0cSort Position\u9009\u9879\u7528\u4e8e\u786e\u5b9a\u6392\u5e8f\u65f6\u4f18\u5148\u4ece\u4e0a\u5230\u4e0b\u8fd8\u662f\u4ece\u5de6\u5230\u53f3\u3002 \u53ef\u4ee5\u5728\u53c2\u6570\u8bbe\u7f6e\u4e2d\u6253\u5f00Show Debug\u9009\u9879\uff0c\u5728\u7ed3\u679c\u56fe\u50cf\u4e2d\u89c2\u5bdf\u6587\u5b57\u4f4d\u7f6e\u548c\u5b57\u5f62\u56fe\u3002\u4e5f\u53ef\u4ee5\u52fe\u9009Revise Position\u9009\u9879\uff0c\u8fd9\u6837\u4f1a\u7528\u6e32\u67d3\u6587\u5b57\u7684\u5916\u63a5\u77e9\u5f62\u4f5c\u4e3a\u4fee\u6b63\u540e\u7684\u4f4d\u7f6e\uff0c\u4e0d\u8fc7\u5076\u5c14\u53d1\u73b0\u8fd9\u6837\u751f\u6210\u7684\u6587\u5b57\u521b\u9020\u6027\u7565\u4f4e\u3002<\/p>\n<p><strong>\u6587\u5b57\u7f16\u8f91<\/strong><\/p>\n<p>\u8bf7\u4e0a\u4f20\u4e00\u5f20\u5f85\u7f16\u8f91\u7684\u56fe\u7247\u4f5c\u4e3a\u53c2\u8003\u56fe(Ref)\uff0c\u7136\u540e\u8c03\u6574\u7b14\u89e6\u5927\u5c0f\u540e\uff0c\u5728\u53c2\u8003\u56fe\u4e0a\u6d82\u62b9\u8981\u7f16\u8f91\u7684\u4f4d\u7f6e\uff0c\u5728Prompt\u4e2d\u8f93\u5165\u63cf\u8ff0\u63d0\u793a\u8bcd\u548c\u8981\u4fee\u6539\u7684\u6587\u5b57\u5185\u5bb9\uff0c\u751f\u6210\u56fe\u7247\u3002<\/p>\n<p>\u53c2\u8003\u56fe\u53ef\u4ee5\u4e3a\u4efb\u610f\u5206\u8fa8\u7387\uff0c\u4f46\u5185\u90e8\u5904\u7406\u65f6\u4f1a\u9650\u5236\u957f\u8fb9\u4e0d\u80fd\u8d85\u8fc7768\uff0c\u5e76\u4e14\u5bbd\u9ad8\u90fd\u88ab\u7f29\u653e\u4e3a64\u7684\u6574\u6570\u500d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AnyText\u662f\u4e00\u4e2a\u9769\u547d\u6027\u7684\u591a\u8bed\u8a00\u89c6\u89c9\u6587\u672c\u751f\u6210\u548c\u7f16\u8f91\u5de5\u5177\uff0c\u57fa\u4e8e\u6269\u6563\u6a21\u578b\u5f00\u53d1\u3002\u5b83\u80fd\u591f\u5728\u56fe\u50cf\u4e2d\u751f\u6210\u81ea\u7136\u3001\u9ad8\u8d28\u91cf\u7684\u591a\u8bed\u79cd\u6587\u672c\uff0c\u5e76\u652f\u6301\u7075\u6d3b\u7684\u6587\u672c\u7f16\u8f91\u529f\u80fd\u3002\u8be5\u9879\u76ee\u7531\u7814\u7a76\u56e2\u961f\u5f00\u53d1\uff0c\u5e76\u5728ICLR 2024\u4f1a\u8bae\u4e0a\u83b7\u5f97Spotlight\u8363\u8a89\u3002AnyText\u7684&#8230;<\/p>\n","protected":false},"author":1,"featured_media":32782,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[398,392],"tags":[222,229,230],"class_list":["post-16707","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-image-generation-model","category-models","tag-aituxiangshengchengfuzhu","tag-aituxiangfenggekongzhi","tag-aikaiyuanxiangmu"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/16707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/comments?post=16707"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/16707\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media\/32782"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media?parent=16707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/categories?post=16707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/tags?post=16707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}