{"id":83503,"date":"2026-07-26T00:09:09","date_gmt":"2026-07-25T16:09:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/83503.html"},"modified":"2026-07-26T00:09:09","modified_gmt":"2026-07-25T16:09:09","slug":"mogface%e4%ba%ba%e8%84%b8%e6%a3%80%e6%b5%8b%e6%a8%a1%e5%9e%8b-webui%e7%ae%97%e5%8a%9b%e9%80%82%e9%85%8d%e6%8c%87%e5%8d%97%ef%bc%9a%e4%bd%8e%e9%85%8d%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%882%e6%a0%b82gb","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/83503.html","title":{"rendered":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7"},"content":{"rendered":"<h2>MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357&#xff1a;\u4f4e\u914d\u670d\u52a1\u5668&#xff08;2\u68382GB&#xff09;\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7<\/h2>\n<h3>1. \u5f15\u8a00&#xff1a;\u5f53\u5f3a\u5927\u6a21\u578b\u9047\u4e0a\u6709\u9650\u7b97\u529b<\/h3>\n<p>\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4f60\u624b\u5934\u6709\u4e00\u53f0\u95f2\u7f6e\u7684\u65e7\u670d\u52a1\u5668&#xff0c;\u6216\u8005\u4e00\u4e2a\u914d\u7f6e\u4e0d\u9ad8\u7684\u4e91\u4e3b\u673a&#xff0c;\u53ea\u67092\u4e2aCPU\u6838\u5fc3\u548c2GB\u5185\u5b58\u3002\u4f60\u60f3\u5728\u4e0a\u9762\u90e8\u7f72\u4e00\u4e2a\u5148\u8fdb\u7684\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#xff0c;\u7528\u6765\u5904\u7406\u56fe\u7247\u3001\u8bc6\u522b\u7528\u6237&#xff0c;\u751a\u81f3\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u5b89\u9632\u76d1\u63a7\u3002\u4f46\u4e00\u770b\u5230\u90a3\u4e9b\u52a8\u8f84\u8981\u6c428GB\u300116GB\u5185\u5b58\u7684AI\u6a21\u578b&#xff0c;\u662f\u4e0d\u662f\u89c9\u5f97\u5e0c\u671b\u6e3a\u832b&#xff1f;<\/p>\n<p>\u522b\u6025\u7740\u653e\u5f03\u3002\u4eca\u5929\u6211\u8981\u5206\u4eab\u7684&#xff0c;\u5c31\u662f\u5982\u4f55\u5728\u8fd9\u6837\u7684\u201c\u4f4e\u914d\u201d\u73af\u5883\u4e0b&#xff0c;\u6210\u529f\u8fd0\u884cMogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b\u53ca\u5176WebUI\u754c\u9762\u3002MogFace\u662fCVPR 2022\u4e0a\u63d0\u51fa\u7684\u4e00\u4e2a\u4f18\u79c0\u4eba\u8138\u68c0\u6d4b\u5668&#xff0c;\u7cbe\u5ea6\u9ad8\u3001\u7a33\u5b9a\u6027\u597d&#xff0c;\u80fd\u8bc6\u522b\u4fa7\u8138\u3001\u6234\u53e3\u7f69\u3001\u5149\u7ebf\u6697\u7b49\u5404\u79cd\u590d\u6742\u573a\u666f\u4e0b\u7684\u4eba\u8138\u3002\u66f4\u91cd\u8981\u7684\u662f&#xff0c;\u7ecf\u8fc7\u4e00\u4e9b\u4f18\u5316\u6280\u5de7&#xff0c;\u5b83\u5b8c\u5168\u53ef\u4ee5\u5728\u8d44\u6e90\u6709\u9650\u7684\u670d\u52a1\u5668\u4e0a\u6d41\u7545\u8fd0\u884c\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4f60\u51c6\u5907\u7684\u201c\u7626\u8eab\u201d\u6307\u5357\u3002\u6211\u4f1a\u5e26\u4f60\u4e00\u6b65\u6b65\u8c03\u6574\u914d\u7f6e\u3001\u4f18\u5316\u53c2\u6570&#xff0c;\u8ba9\u8fd9\u4e2a\u5f3a\u5927\u7684\u6a21\u578b\u5728\u4f60\u7684\u5c0f\u670d\u52a1\u5668\u4e0a\u201c\u5b89\u5bb6\u843d\u6237\u201d\u3002\u65e0\u8bba\u4f60\u662f\u4e2a\u4eba\u5f00\u53d1\u8005\u3001\u5c0f\u56e2\u961f&#xff0c;\u8fd8\u662f\u53ea\u662f\u60f3\u4f4e\u6210\u672c\u4f53\u9a8cAI\u80fd\u529b&#xff0c;\u8fd9\u5957\u65b9\u6cd5\u90fd\u80fd\u5e2e\u4f60\u7701\u4e0b\u4e0d\u5c11\u786c\u4ef6\u6210\u672c\u3002<\/p>\n<h3>2. \u7406\u89e3MogFace&#xff1a;\u4e3a\u4ec0\u4e48\u5b83\u9002\u5408\u4f4e\u914d\u73af\u5883&#xff1f;<\/h3>\n<p>\u5728\u5f00\u59cb\u52a8\u624b\u4e4b\u524d&#xff0c;\u6211\u4eec\u5148\u7b80\u5355\u4e86\u89e3\u4e00\u4e0bMogFace\u6a21\u578b\u7684\u7279\u70b9&#xff0c;\u8fd9\u80fd\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<h4>2.1 MogFace\u7684\u6838\u5fc3\u4f18\u52bf<\/h4>\n<p>MogFace\u5e76\u4e0d\u662f\u4e00\u4e2a\u201c\u8f7b\u91cf\u7ea7\u201d\u6a21\u578b&#xff0c;\u5b83\u7684\u57fa\u7840\u7248\u672c\u57fa\u4e8eResNet101&#xff0c;\u53c2\u6570\u91cf\u4e0d\u5c0f\u3002\u4f46\u5b83\u5728\u8bbe\u8ba1\u4e0a\u6709\u51e0\u4e2a\u7279\u70b9&#xff0c;\u8ba9\u6211\u4eec\u6709\u673a\u4f1a\u5728\u4f4e\u914d\u73af\u5883\u4e0b\u8fd0\u884c&#xff1a;<\/p>\n<ul>\n<li>\u7cbe\u5ea6\u4e0e\u901f\u5ea6\u7684\u5e73\u8861&#xff1a;\u867d\u7136\u6a21\u578b\u4e0d\u7b97\u5c0f&#xff0c;\u4f46\u5b83\u7684\u68c0\u6d4b\u7b97\u6cd5\u6548\u7387\u5f88\u9ad8&#xff0c;\u5355\u5f20\u56fe\u7247\u63a8\u7406\u65f6\u95f4\u901a\u5e38\u5728\u51e0\u5341\u6beb\u79d2\u7ea7\u522b\u3002\u8fd9\u610f\u5473\u7740\u5bf9CPU\u7684\u6301\u7eed\u538b\u529b\u4e0d\u4f1a\u592a\u5927\u3002<\/li>\n<li>\u81ea\u9002\u5e94\u8f93\u5165\u5c3a\u5bf8&#xff1a;\u6a21\u578b\u4e0d\u5f3a\u5236\u8981\u6c42\u56fa\u5b9a\u7684\u8f93\u5165\u56fe\u7247\u5c3a\u5bf8&#xff0c;\u8fd9\u8ba9\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u670d\u52a1\u5668\u6027\u80fd\u52a8\u6001\u8c03\u6574\u56fe\u7247\u9884\u5904\u7406\u7684\u5927\u5c0f&#xff0c;\u8fd9\u662f\u964d\u4f4e\u5185\u5b58\u5360\u7528\u7684\u5173\u952e\u3002<\/li>\n<li>\u7a33\u5b9a\u7684\u5185\u5b58\u5360\u7528&#xff1a;\u4e0e\u4e00\u4e9b\u9700\u8981\u5927\u91cf\u663e\u5b58&#xff08;GPU\u5185\u5b58&#xff09;\u7684\u6a21\u578b\u4e0d\u540c&#xff0c;MogFace\u4e3b\u8981\u8fd0\u884c\u5728CPU\u4e0a&#xff0c;\u5176\u5185\u5b58\u5360\u7528\u5728\u63a8\u7406\u8fc7\u7a0b\u4e2d\u76f8\u5bf9\u7a33\u5b9a&#xff0c;\u4fbf\u4e8e\u6211\u4eec\u8fdb\u884c\u63a7\u5236\u548c\u9884\u4f30\u3002<\/li>\n<\/ul>\n<h4>2.2 2\u68382GB\u670d\u52a1\u5668\u7684\u6311\u6218\u4e0e\u673a\u9047<\/h4>\n<p>\u6211\u4eec\u7684\u76ee\u6807\u73af\u5883\u662f2\u6838CPU\u548c2GB\u5185\u5b58\u3002\u8fd9\u542c\u8d77\u6765\u5f88\u7d27\u5f20&#xff0c;\u4f46\u5e76\u975e\u4e0d\u53ef\u80fd\u3002<\/p>\n<ul>\n<li>\n<p>\u4e3b\u8981\u6311\u6218&#xff1a;<\/p>\n<li>\u5185\u5b58\u74f6\u9888&#xff1a;2GB\u5185\u5b58\u9700\u8981\u540c\u65f6\u5bb9\u7eb3\u64cd\u4f5c\u7cfb\u7edf\u3001Python\u73af\u5883\u3001\u6a21\u578b\u6743\u91cd\u3001Web\u670d\u52a1\u5668&#xff08;\u5982Gradio&#xff09;\u4ee5\u53ca\u5f85\u5904\u7406\u7684\u56fe\u7247\u6570\u636e\u3002\u4efb\u4f55\u4e00\u4e2a\u73af\u8282\u81a8\u80c0\u90fd\u4f1a\u5bfc\u81f4\u5d29\u6e83\u3002<\/li>\n<li>\u8ba1\u7b97\u74f6\u9888&#xff1a;2\u4e2aCPU\u6838\u5fc3\u5904\u7406\u6df1\u5ea6\u5b66\u4e60\u63a8\u7406&#xff0c;\u901f\u5ea6\u4e0d\u4f1a\u5feb&#xff0c;\u9700\u8981\u907f\u514d\u5e76\u53d1\u8bf7\u6c42\u5bfc\u81f4\u7cfb\u7edf\u5361\u6b7b\u3002<\/li>\n<li>\u54cd\u5e94\u5ef6\u8fdf&#xff1a;\u7528\u6237\u901a\u8fc7WebUI\u4e0a\u4f20\u56fe\u7247\u540e&#xff0c;\u5982\u679c\u7b49\u5f85\u65f6\u95f4\u8fc7\u957f&#xff0c;\u4f53\u9a8c\u4f1a\u5f88\u5dee\u3002<\/li>\n<\/li>\n<li>\n<p>\u6211\u4eec\u7684\u4f18\u5316\u601d\u8def&#xff1a;<\/p>\n<li>\u7cbe\u7b80\u8fd0\u884c\u65f6&#xff1a;\u79fb\u9664\u6240\u6709\u975e\u5fc5\u8981\u7684\u5e93\u548c\u670d\u52a1\u3002<\/li>\n<li>\u63a7\u5236\u8f93\u5165\u89c4\u6a21&#xff1a;\u9650\u5236\u7528\u6237\u4e0a\u4f20\u56fe\u7247\u7684\u5c3a\u5bf8\u548c\u5e76\u53d1\u6570\u3002<\/li>\n<li>\u4f18\u5316\u6a21\u578b\u52a0\u8f7d&#xff1a;\u91c7\u7528\u66f4\u8282\u7701\u5185\u5b58\u7684\u6a21\u578b\u52a0\u8f7d\u65b9\u5f0f\u3002<\/li>\n<li>\u8c03\u6574Web\u670d\u52a1\u914d\u7f6e&#xff1a;\u4f7f\u7528\u8f7b\u91cf\u7ea7\u7684\u8bbe\u7f6e\u542f\u52a8WebUI\u3002<\/li>\n<\/li>\n<\/ul>\n<p>\u7406\u89e3\u4e86\u8fd9\u4e9b&#xff0c;\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u52a8\u624b\u4e86\u3002<\/p>\n<h3>3. \u73af\u5883\u51c6\u5907\u4e0e\u7cbe\u7b80\u90e8\u7f72<\/h3>\n<p>\u5047\u8bbe\u4f60\u5df2\u7ecf\u6309\u7167\u57fa\u7840\u6559\u7a0b&#xff0c;\u5728\u670d\u52a1\u5668\u4e0a\u62c9\u53d6\u4e86MogFace\u7684\u955c\u50cf\u6216\u4ee3\u7801\u3002\u6211\u4eec\u73b0\u5728\u8981\u505a\u7684\u4e0d\u662f\u201c\u5b89\u88c5\u201d&#xff0c;\u800c\u662f\u201c\u7cbe\u7b80\u201d\u3002<\/p>\n<h4>3.1 \u68c0\u67e5\u4e0e\u6e05\u7406\u7cfb\u7edf\u8d44\u6e90<\/h4>\n<p>\u9996\u5148&#xff0c;\u767b\u5f55\u4f60\u7684\u670d\u52a1\u5668&#xff0c;\u770b\u770b\u5f53\u524d\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<p># \u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<br \/>\nfree -h<\/p>\n<p># \u67e5\u770bCPU\u6838\u5fc3\u6570<br \/>\nnproc<\/p>\n<p># \u67e5\u770b\u5df2\u542f\u52a8\u7684\u4e0d\u5fc5\u8981\u670d\u52a1&#xff08;\u6839\u636e\u4f60\u7684\u7cfb\u7edf&#xff0c;\u547d\u4ee4\u53ef\u80fd\u4e0d\u540c&#xff09;<br \/>\n# \u5bf9\u4e8e\u4f7f\u7528systemd\u7684\u7cfb\u7edf&#xff08;\u5982Ubuntu 18.04&#043;&#xff0c; CentOS 7&#043;&#xff09;<br \/>\nsudo systemctl list-units &#8211;type&#061;service &#8211;state&#061;running<\/p>\n<p>\u76ee\u6807&#xff1a;\u786e\u4fdd\u5728\u542f\u52a8\u4eba\u8138\u68c0\u6d4b\u670d\u52a1\u524d&#xff0c;\u7cfb\u7edf\u7a7a\u95f2\u5185\u5b58\u81f3\u5c11\u8fd8\u67091.2GB\u4ee5\u4e0a\u3002\u5982\u679c\u5176\u4ed6\u670d\u52a1\u5360\u7528\u4e86\u8fc7\u591a\u5185\u5b58&#xff0c;\u8003\u8651\u6682\u65f6\u505c\u7528\u5b83\u4eec&#xff08;\u5982\u4e0d\u5fc5\u8981\u7684\u6570\u636e\u5e93\u3001docker\u670d\u52a1\u7b49&#xff09;\u3002<\/p>\n<h4>3.2 \u4f18\u5316Python\u73af\u5883\u4e0e\u4f9d\u8d56<\/h4>\n<p>\u901a\u5e38\u7684pip install -r requirements.txt\u53ef\u80fd\u4f1a\u5b89\u88c5\u4e00\u4e9b\u6211\u4eec\u7528\u4e0d\u5230\u7684\u5927\u578b\u5e93&#xff08;\u5982\u67d0\u4e9b\u7248\u672c\u7684TensorFlow\u6216\u5b8c\u6574\u7684OpenCV&#xff09;\u3002\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u9009\u62e9\u6027\u5b89\u88c5\u3002<\/p>\n<p># \u8fdb\u5165\u9879\u76ee\u76ee\u5f55&#xff0c;\u5047\u8bbe\u662f \/root\/cv_resnet101_face-detection_cvpr22papermogface<br \/>\ncd \/root\/cv_resnet101_face-detection_cvpr22papermogface<\/p>\n<p># \u521b\u5efa\u4e00\u4e2a\u7cbe\u7b80\u7248\u7684\u4f9d\u8d56\u6587\u4ef6<br \/>\ncat &gt; requirements_light.txt &lt;&lt; EOF<br \/>\ntorch&gt;&#061;1.7.0,&lt;2.0.0  # \u6838\u5fc3\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6&#xff0c;\u6ce8\u610f\u7248\u672c<br \/>\ntorchvision<br \/>\nopencv-python-headless&#061;&#061;4.5.5.64  # \u4f7f\u7528headless\u7248\u672c&#xff0c;\u8282\u7701\u7a7a\u95f4<br \/>\ngradio&gt;&#061;3.0.0,&lt;4.0.0  # WebUI\u6846\u67b6<br \/>\nnumpy<br \/>\npillow  # \u56fe\u7247\u5904\u7406<br \/>\nrequests  # \u7528\u4e8eAPI\u5065\u5eb7\u68c0\u67e5<br \/>\nEOF<\/p>\n<p># \u4f7f\u7528\u6e05\u534e\u955c\u50cf\u6e90\u52a0\u901f\u5b89\u88c5&#xff0c;\u5e76\u907f\u514d\u5b89\u88c5\u989d\u5916\u4f9d\u8d56<br \/>\npip install -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple -r requirements_light.txt &#8211;no-deps<br \/>\n# \u5982\u679c\u51fa\u73b0\u4f9d\u8d56\u7f3a\u5931\u9519\u8bef&#xff0c;\u518d\u5355\u72ec\u5b89\u88c5\u7f3a\u5931\u7684\u5305<\/p>\n<p>\u5173\u952e\u70b9&#xff1a;<\/p>\n<ul>\n<li>opencv-python-headless&#xff1a;\u6bd4\u5b8c\u6574\u7684opencv-python\u5c0f\u5f88\u591a&#xff0c;\u56e0\u4e3a\u5b83\u4e0d\u5305\u542bGUI\u76f8\u5173\u7684\u5e93&#xff08;\u6211\u4eec\u5728\u670d\u52a1\u5668\u4e0a\u7528\u4e0d\u5230&#xff09;\u3002<\/li>\n<li>&#8211;no-deps&#xff1a;\u5148\u4e0d\u5b89\u88c5\u4f9d\u8d56&#xff0c;\u9632\u6b62pip\u81ea\u52a8\u5b89\u88c5\u4e00\u4e9b\u6211\u4eec\u4e0d\u9700\u8981\u7684\u5e9e\u5927\u9644\u5c5e\u5305\u3002\u5982\u679c\u8fd0\u884c\u65f6\u62a5\u9519\u7f3a\u5c11\u67d0\u4e2a\u5305&#xff0c;\u518d\u624b\u52a8\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<h4>3.3 \u8f7b\u91cf\u7ea7\u542f\u52a8WebUI\u670d\u52a1<\/h4>\n<p>\u9ed8\u8ba4\u7684\u542f\u52a8\u547d\u4ee4\u53ef\u80fd\u4e3a\u6027\u80fd\u505a\u4e86\u59a5\u534f\u3002\u6211\u4eec\u9700\u8981\u8c03\u6574Gradio\u7684\u542f\u52a8\u53c2\u6570\u3002<\/p>\n<p>\u627e\u5230\u542f\u52a8WebUI\u7684\u811a\u672c\u6216\u547d\u4ee4&#xff0c;\u901a\u5e38\u662fpython app.py\u6216gradio app.py\u3002\u6211\u4eec\u9700\u8981\u4fee\u6539\u5176\u542f\u52a8\u65b9\u5f0f\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u542f\u52a8\u811a\u672crun_lightweight.sh&#xff1a;<\/p>\n<p>#!\/bin\/bash<br \/>\ncd \/root\/cv_resnet101_face-detection_cvpr22papermogface<\/p>\n<p># \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf&#xff0c;\u9650\u5236PyTorch\u7684\u7ebf\u7a0b\u6570&#xff0c;\u907f\u514d\u5360\u6ee1CPU\u5f71\u54cd\u7cfb\u7edf<br \/>\nexport OMP_NUM_THREADS&#061;1<br \/>\nexport MKL_NUM_THREADS&#061;1<\/p>\n<p># \u542f\u52a8Gradio\u5e94\u7528&#xff0c;\u5173\u952e\u53c2\u6570\u5982\u4e0b&#xff1a;<br \/>\n# &#8211;max-file-size: \u9650\u5236\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f&#xff0c;\u4f8b\u598220MB&#xff0c;\u9632\u6b62\u5927\u56fe\u7247\u5403\u5149\u5185\u5b58<br \/>\n# &#8211;concurrency-count: \u8bbe\u7f6e\u5e76\u53d1\u5904\u7406\u6570&#xff0c;\u4f4e\u914d\u670d\u52a1\u5668\u5efa\u8bae\u8bbe\u4e3a1&#xff0c;\u540c\u4e00\u65f6\u95f4\u53ea\u5904\u7406\u4e00\u4e2a\u8bf7\u6c42<br \/>\n# &#8211;server-name: \u7ed1\u5b9a\u5230\u6240\u6709\u7f51\u7edc\u63a5\u53e3<br \/>\n# &#8211;server-port: \u6307\u5b9a\u7aef\u53e3<br \/>\n# \u5047\u8bbe\u4f60\u7684\u4e3b\u7a0b\u5e8f\u6587\u4ef6\u662f webui.py<br \/>\npython webui.py \\\\<br \/>\n  &#8211;max-file-size 20 \\\\<br \/>\n  &#8211;concurrency-count 1 \\\\<br \/>\n  &#8211;server-name 0.0.0.0 \\\\<br \/>\n  &#8211;server-port 7860<\/p>\n<p>\u7ed9\u811a\u672c\u6dfb\u52a0\u6267\u884c\u6743\u9650\u5e76\u8fd0\u884c&#xff1a;<\/p>\n<p>chmod &#043;x run_lightweight.sh<br \/>\n.\/run_lightweight.sh<\/p>\n<p>\u53c2\u6570\u89e3\u91ca&#xff1a;<\/p>\n<ul>\n<li>OMP_NUM_THREADS&#061;1 \u548c MKL_NUM_THREADS&#061;1&#xff1a;\u8fd9\u80fd\u9632\u6b62PyTorch\u7684\u540e\u7aef\u8ba1\u7b97\u5e93\u4f7f\u7528\u6240\u6709CPU\u7ebf\u7a0b&#xff0c;\u7559\u51fa\u8d44\u6e90\u7ed9\u7cfb\u7edf\u548c\u5176\u4ed6\u4efb\u52a1&#xff0c;\u867d\u7136\u53ef\u80fd\u7a0d\u5fae\u964d\u4f4e\u5355\u6b21\u63a8\u7406\u901f\u5ea6&#xff0c;\u4f46\u80fd\u663e\u8457\u63d0\u5347\u7cfb\u7edf\u6574\u4f53\u7a33\u5b9a\u6027\u3002<\/li>\n<li>&#8211;concurrency-count 1&#xff1a;\u8fd9\u662f\u6700\u91cd\u8981\u7684\u53c2\u6570\u3002\u5b83\u610f\u5473\u7740WebUI\u4e00\u6b21\u53ea\u5904\u7406\u4e00\u4e2a\u68c0\u6d4b\u8bf7\u6c42\u3002\u57282\u6838\u73af\u5883\u4e0b&#xff0c;\u5e76\u53d1\u5904\u7406\u591a\u4e2a\u8bf7\u6c42\u6781\u6613\u5bfc\u81f4\u5185\u5b58\u6ea2\u51fa\u548cCPU 100%&#xff0c;\u4ece\u800c\u670d\u52a1\u5d29\u6e83\u3002\u8bbe\u7f6e\u4e3a1\u4fdd\u8bc1\u4e86\u670d\u52a1\u7684\u7a33\u5b9a\u3002<\/li>\n<li>&#8211;max-file-size 20&#xff1a;\u9650\u5236\u7528\u6237\u4e0a\u4f20\u7684\u56fe\u7247\u6700\u5927\u4e3a20MB&#xff0c;\u907f\u514d\u5355\u5f20\u8d85\u5927\u56fe\u7247\u8017\u5c3d\u5185\u5b58\u3002<\/li>\n<\/ul>\n<h3>4. \u6838\u5fc3\u4f18\u5316\u6280\u5de7&#xff1a;\u6a21\u578b\u4e0e\u5904\u7406\u6d41\u7a0b\u8c03\u4f18<\/h3>\n<p>\u670d\u52a1\u80fd\u8dd1\u8d77\u6765\u53ea\u662f\u7b2c\u4e00\u6b65&#xff0c;\u8981\u8dd1\u5f97\u7a33\u3001\u8dd1\u5f97\u597d&#xff0c;\u8fd8\u9700\u8981\u5bf9\u6a21\u578b\u52a0\u8f7d\u548c\u56fe\u7247\u5904\u7406\u6d41\u7a0b\u52a8\u624b\u672f\u3002<\/p>\n<h4>4.1 \u6a21\u578b\u52a0\u8f7d\u4f18\u5316&#xff1a;\u4f7f\u7528CPU\u6a21\u5f0f\u4e0eFloat16\u7cbe\u5ea6<\/h4>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;\u6a21\u578b\u53ef\u80fd\u4f1a\u5c1d\u8bd5\u4f7f\u7528GPU&#xff0c;\u6216\u8005\u5728CPU\u4e0a\u4f7f\u7528Float32&#xff08;\u5355\u7cbe\u5ea6&#xff09;\u8ba1\u7b97\u3002\u6211\u4eec\u53ef\u4ee5\u5f3a\u5236\u5176\u4f7f\u7528CPU\u5e76\u5c1d\u8bd5\u66f4\u4f4e\u7cbe\u5ea6\u7684Float16&#xff0c;\u4ee5\u8282\u7701\u5185\u5b58\u548c\u8ba1\u7b97\u91cf\u3002<\/p>\n<p>\u4f60\u9700\u8981\u627e\u5230\u6a21\u578b\u52a0\u8f7d\u7684\u4ee3\u7801\u90e8\u5206&#xff08;\u901a\u5e38\u5728detector.py\u6216\u7c7b\u4f3c\u6587\u4ef6\u4e2d&#xff09;\u3002\u4fee\u6539\u7684\u601d\u8def\u5982\u4e0b&#xff1a;<\/p>\n<p># \u539f\u4ee3\u7801\u53ef\u80fd\u7c7b\u4f3c\u8fd9\u6837<br \/>\nimport torch<br \/>\nfrom models.mogface import MogFaceDetector<\/p>\n<p>device &#061; torch.device(&#039;cuda&#039; if torch.cuda.is_available() else &#039;cpu&#039;)<br \/>\nmodel &#061; MogFaceDetector(&#8230;).to(device)<br \/>\nmodel.load_state_dict(torch.load(&#039;mogface_resnet101.pth&#039;))<br \/>\nmodel.eval()<\/p>\n<p># \u4f18\u5316\u540e\u7684\u4ee3\u7801<br \/>\nimport torch<br \/>\nfrom models.mogface import MogFaceDetector<\/p>\n<p># 1. \u5f3a\u5236\u4f7f\u7528CPU<br \/>\ndevice &#061; torch.device(&#039;cpu&#039;)<\/p>\n<p># 2. \u52a0\u8f7d\u6a21\u578b\u6743\u91cd\u5230CPU<br \/>\nmodel &#061; MogFaceDetector(&#8230;)<br \/>\nstate_dict &#061; torch.load(&#039;mogface_resnet101.pth&#039;, map_location&#061;&#039;cpu&#039;)<br \/>\nmodel.load_state_dict(state_dict)<\/p>\n<p># 3. \u5c1d\u8bd5\u8f6c\u6362\u4e3a\u534a\u7cbe\u5ea6 (Float16)&#xff0c;\u5982\u679c\u6a21\u578b\u652f\u6301\u7684\u8bdd<br \/>\n# \u6ce8\u610f&#xff1a;\u5e76\u975e\u6240\u6709\u6a21\u578b\u64cd\u4f5c\u90fd\u5b8c\u5168\u652f\u6301Float16&#xff0c;\u5982\u679c\u8f6c\u6362\u540e\u51fa\u9519\u6216\u7cbe\u5ea6\u635f\u5931\u4e25\u91cd&#xff0c;\u5219\u8df3\u8fc7\u6b64\u6b65<br \/>\ntry:<br \/>\n    model &#061; model.half()  # \u8f6c\u6362\u4e3a\u534a\u7cbe\u5ea6<br \/>\n    print(&#034;\u6a21\u578b\u5df2\u8f6c\u6362\u4e3a\u534a\u7cbe\u5ea6(Float16)\u6a21\u5f0f\u3002&#034;)<br \/>\nexcept Exception as e:<br \/>\n    print(f&#034;\u6a21\u578b\u4e0d\u652f\u6301\u534a\u7cbe\u5ea6\u8f6c\u6362&#xff0c;\u5c06\u4f7f\u7528\u5355\u7cbe\u5ea6(Float32)\u3002\u9519\u8bef: {e}&#034;)<br \/>\n    pass<\/p>\n<p>model.to(device)<br \/>\nmodel.eval()<\/p>\n<p># 4. \u5728\u63a8\u7406\u65f6&#xff0c;\u786e\u4fdd\u8f93\u5165\u6570\u636e\u4e5f\u5728CPU\u4e0a&#xff0c;\u5e76\u4e14\u7cbe\u5ea6\u5339\u914d<br \/>\ndef detect(image_tensor):<br \/>\n    with torch.no_grad():<br \/>\n        # \u5c06\u56fe\u7247\u6570\u636e\u4e5f\u653e\u5230CPU&#xff0c;\u5e76\u5339\u914d\u6a21\u578b\u7cbe\u5ea6<br \/>\n        if next(model.parameters()).dtype &#061;&#061; torch.float16:<br \/>\n            image_tensor &#061; image_tensor.half()<br \/>\n        image_tensor &#061; image_tensor.to(device)<br \/>\n        predictions &#061; model(image_tensor)<br \/>\n    return predictions<\/p>\n<p>\u91cd\u8981\u63d0\u793a&#xff1a;model.half()\u8fd9\u4e00\u6b65\u9700\u8981\u6d4b\u8bd5\u3002\u534a\u7cbe\u5ea6\u80fd\u51cf\u5c11\u8fd1\u4e00\u534a\u7684\u5185\u5b58\u5360\u7528&#xff0c;\u4f46\u53ef\u80fd\u5bfc\u81f4\u6570\u503c\u4e0d\u7a33\u5b9a&#xff0c;\u5f71\u54cd\u68c0\u6d4b\u7cbe\u5ea6\u3002\u5982\u679c\u53d1\u73b0\u8f6c\u6362\u540e\u68c0\u6d4b\u6548\u679c\u53d8\u5dee\u6216\u62a5\u9519&#xff0c;\u8bf7\u79fb\u9664\u8fd9\u884c\u4ee3\u7801&#xff0c;\u4fdd\u7559Float32\u6a21\u5f0f\u3002<\/p>\n<h4>4.2 \u56fe\u7247\u9884\u5904\u7406\u4f18\u5316&#xff1a;\u52a8\u6001\u7f29\u653e\u4e0e\u6279\u91cf\u9650\u5236<\/h4>\n<p>\u56fe\u7247\u5728\u9001\u5165\u6a21\u578b\u524d&#xff0c;\u4f1a\u88ab\u9884\u5904\u7406&#xff08;\u7f29\u653e\u3001\u5f52\u4e00\u5316\u7b49&#xff09;\u3002\u5904\u7406\u8d85\u5927\u539f\u56fe\u4f1a\u6d88\u8017\u5927\u91cf\u5185\u5b58\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u9884\u5904\u7406\u9636\u6bb5\u5c31\u8fdb\u884c\u9650\u5236\u3002<\/p>\n<p>\u5728\u4f60\u7684\u56fe\u7247\u9884\u5904\u7406\u51fd\u6570\u4e2d&#xff08;\u53ef\u80fd\u5728utils.py\u6216preprocess.py&#xff09;&#xff0c;\u6dfb\u52a0\u5c3a\u5bf8\u9650\u5236&#xff1a;<\/p>\n<p>import cv2<br \/>\nfrom PIL import Image<\/p>\n<p>def preprocess_image_for_low_memory(image_path, max_side_length&#061;1024):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u4e3a\u4f4e\u5185\u5b58\u73af\u5883\u4f18\u5316\u7684\u56fe\u7247\u9884\u5904\u7406\u3002<br \/>\n    \u5c06\u56fe\u7247\u7684\u957f\u8fb9\u7f29\u653e\u5230 max_side_length \u4ee5\u5185&#xff0c;\u4fdd\u6301\u5bbd\u9ad8\u6bd4\u3002<br \/>\n    &#034;&#034;&#034;<br \/>\n    # \u4f7f\u7528PIL\u6216OpenCV\u8bfb\u53d6\u56fe\u7247<br \/>\n    img &#061; cv2.imread(image_path)<br \/>\n    if img is None:<br \/>\n        # \u5982\u679ccv2\u8bfb\u5931\u8d25&#xff0c;\u5c1d\u8bd5PIL<br \/>\n        img &#061; Image.open(image_path)<br \/>\n        img &#061; cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)<\/p>\n<p>    height, width &#061; img.shape[:2]<br \/>\n    max_dim &#061; max(height, width)<\/p>\n<p>    # \u5982\u679c\u56fe\u7247\u592a\u5927&#xff0c;\u8fdb\u884c\u7f29\u653e<br \/>\n    if max_dim &gt; max_side_length:<br \/>\n        scale &#061; max_side_length \/ max_dim<br \/>\n        new_width &#061; int(width * scale)<br \/>\n        new_height &#061; int(height * scale)<br \/>\n        img &#061; cv2.resize(img, (new_width, new_height), interpolation&#061;cv2.INTER_LINEAR)<br \/>\n        print(f&#034;\u56fe\u7247\u5df2\u4ece ({width}, {height}) \u7f29\u653e\u81f3 ({new_width}, {new_height})&#034;)<\/p>\n<p>    # \u540e\u7eed\u7684\u5f52\u4e00\u5316\u7b49\u64cd\u4f5c&#8230;<br \/>\n    # &#8230; [\u4f60\u7684\u539f\u6709\u9884\u5904\u7406\u4ee3\u7801] &#8230;<\/p>\n<p>    return processed_tensor<\/p>\n<p>\u540c\u65f6&#xff0c;\u5728WebUI\u7684\u6279\u91cf\u5904\u7406\u529f\u80fd\u4e2d&#xff0c;\u4e25\u683c\u9650\u5236\u4e00\u6b21\u5904\u7406\u7684\u56fe\u7247\u6570\u91cf\u3002\u4fee\u6539\u6279\u91cf\u5904\u7406\u903b\u8f91&#xff0c;\u4f8b\u5982\u4e00\u6b21\u6700\u591a\u5904\u74065\u5f20\u56fe\u7247&#xff0c;\u5e76\u5728\u524d\u7aef\u7ed9\u51fa\u63d0\u793a\u3002<\/p>\n<h4>4.3 WebUI\u754c\u9762\u7b80\u5316<\/h4>\n<p>Gradio\u754c\u9762\u9ed8\u8ba4\u53ef\u80fd\u5305\u542b\u4e00\u4e9b\u52a8\u753b\u3001\u9ad8\u7ea7\u7ec4\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u7b80\u5316\u754c\u9762&#xff0c;\u51cf\u5c11\u524d\u7aef\u8d44\u6e90\u6d88\u8017\u3002\u4fee\u6539\u4f60\u7684webui.py\u4e2d\u521b\u5efa\u754c\u9762\u7684\u90e8\u5206&#xff1a;<\/p>\n<p>import gradio as gr<\/p>\n<p># \u521b\u5efa\u754c\u9762\u65f6&#xff0c;\u4f7f\u7528\u66f4\u7b80\u5355\u7684\u7ec4\u4ef6<br \/>\nwith gr.Blocks(title&#061;&#034;\u8f7b\u91cf\u7ea7\u4eba\u8138\u68c0\u6d4b&#034;, theme&#061;gr.themes.Base()) as demo: # \u4f7f\u7528\u57fa\u7840\u4e3b\u9898<br \/>\n    gr.Markdown(&#034;# &#x1f3af; \u8f7b\u91cf\u7ea7\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#034;)<br \/>\n    with gr.Row():<br \/>\n        with gr.Column():<br \/>\n            input_image &#061; gr.Image(label&#061;&#034;\u4e0a\u4f20\u56fe\u7247&#034;, type&#061;&#034;filepath&#034;) # \u4f7f\u7528\u6587\u4ef6\u8def\u5f84\u7c7b\u578b&#xff0c;\u6709\u65f6\u6bd4numpy\u6570\u7ec4\u66f4\u7701\u5185\u5b58<br \/>\n            conf_threshold &#061; gr.Slider(0, 1, value&#061;0.5, label&#061;&#034;\u7f6e\u4fe1\u5ea6\u9608\u503c&#034;)<br \/>\n            btn &#061; gr.Button(&#034;\u5f00\u59cb\u68c0\u6d4b&#034;, variant&#061;&#034;primary&#034;)<br \/>\n        with gr.Column():<br \/>\n            output_image &#061; gr.Image(label&#061;&#034;\u68c0\u6d4b\u7ed3\u679c&#034;)<br \/>\n            output_json &#061; gr.JSON(label&#061;&#034;\u4eba\u8138\u6570\u636e&#034;)<\/p>\n<p>    # &#8230; \u7ed1\u5b9a\u5904\u7406\u51fd\u6570 &#8230;<\/p>\n<p># \u542f\u52a8\u65f6\u4f7f\u7528\u6211\u4eec\u7684\u8f7b\u91cf\u53c2\u6570<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    # \u8fd9\u4e9b\u53c2\u6570\u4e5f\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f20\u5165<br \/>\n    demo.launch(<br \/>\n        server_name&#061;&#034;0.0.0.0&#034;,<br \/>\n        server_port&#061;7860,<br \/>\n        max_file_size&#061;&#034;20MB&#034;, # \u9650\u5236\u4e0a\u4f20<br \/>\n        concurrency_count&#061;1,   # \u9650\u5236\u5e76\u53d1<br \/>\n        show_error&#061;True,<br \/>\n        quiet&#061;True, # \u51cf\u5c11\u63a7\u5236\u53f0\u8f93\u51fa<br \/>\n        share&#061;False # \u4f4e\u914d\u670d\u52a1\u5668\u4e0d\u8981\u5f00\u542fshare\u94fe\u63a5<br \/>\n    )<\/p>\n<h3>5. \u7cfb\u7edf\u7ea7\u76d1\u63a7\u4e0e\u7a33\u5b9a\u6027\u4fdd\u969c<\/h3>\n<p>\u670d\u52a1\u8dd1\u8d77\u6765\u540e&#xff0c;\u6211\u4eec\u9700\u8981\u786e\u4fdd\u5b83\u80fd\u5728\u538b\u529b\u4e0b\u4fdd\u6301\u7a33\u5b9a\u3002<\/p>\n<h4>5.1 \u4f7f\u7528\u7cfb\u7edf\u5de5\u5177\u76d1\u63a7\u8d44\u6e90<\/h4>\n<p>\u5728\u53e6\u4e00\u4e2a\u7ec8\u7aef\u7a97\u53e3&#xff0c;\u8fd0\u884c\u76d1\u63a7\u547d\u4ee4&#xff1a;<\/p>\n<p># \u52a8\u6001\u67e5\u770b\u5185\u5b58\u548cCPU\u4f7f\u7528\u60c5\u51b5<br \/>\nhtop  # \u5982\u679c\u672a\u5b89\u88c5&#xff0c;\u4f7f\u7528 &#096;apt install htop&#096; \u6216 &#096;yum install htop&#096;<br \/>\n# \u6216\u8005\u4f7f\u7528\u7b80\u5355\u7684top<br \/>\ntop<\/p>\n<p># \u67e5\u770b\u7279\u5b9a\u8fdb\u7a0b\u7684\u8d44\u6e90\u4f7f\u7528&#xff08;\u627e\u5230\u4f60\u7684Python\u8fdb\u7a0bPID&#xff09;<br \/>\nps aux | grep python<br \/>\n# \u5047\u8bbePID\u662f 12345<br \/>\ntop -p 12345<\/p>\n<p>\u89c2\u5bdf\u5728\u5355\u6b21\u68c0\u6d4b\u8fc7\u7a0b\u4e2d&#xff0c;\u5185\u5b58\u4f7f\u7528\u91cf\u7684\u5cf0\u503c\u3002\u7406\u60f3\u60c5\u51b5\u4e0b&#xff0c;\u5cf0\u503c\u5e94\u63a7\u5236\u57281.5GB\u4ee5\u5185&#xff0c;\u7ed9\u7cfb\u7edf\u7559\u51fa\u51e0\u767eMB\u7684\u7f13\u51b2\u7a7a\u95f4\u3002<\/p>\n<h4>5.2 \u8bbe\u7f6e\u8fdb\u7a0b\u5b88\u62a4\u4e0e\u81ea\u52a8\u91cd\u542f<\/h4>\n<p>\u5982\u679c\u670d\u52a1\u56e0\u4e3a\u4e0d\u53ef\u9884\u77e5\u7684\u539f\u56e0\u5d29\u6e83&#xff0c;\u6211\u4eec\u9700\u8981\u5b83\u80fd\u81ea\u52a8\u91cd\u542f\u3002\u53ef\u4ee5\u7528\u7b80\u5355\u7684while\u5faa\u73af\u811a\u672c&#xff0c;\u6216\u8005\u66f4\u597d\u7684\u5de5\u5177\u5982supervisor\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u5b88\u62a4\u811a\u672cdaemon.sh&#xff1a;<\/p>\n<p>#!\/bin\/bash<br \/>\ncd \/root\/cv_resnet101_face-detection_cvpr22papermogface<\/p>\n<p>while true; do<br \/>\n    echo &#034;$(date): \u542f\u52a8\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#8230;&#034;<br \/>\n    # \u8fd9\u91cc\u8c03\u7528\u6211\u4eec\u4e4b\u524d\u5199\u7684\u8f7b\u91cf\u542f\u52a8\u811a\u672c<br \/>\n    .\/run_lightweight.sh<\/p>\n<p>    # \u5982\u679c\u4e0a\u9762\u7684\u811a\u672c\u9000\u51fa&#xff08;\u670d\u52a1\u5d29\u6e83&#xff09;&#xff0c;\u4f1a\u6267\u884c\u5230\u8fd9\u91cc<br \/>\n    echo &#034;$(date): \u670d\u52a1\u610f\u5916\u9000\u51fa&#xff0c;10\u79d2\u540e\u91cd\u542f&#8230;&#034;<br \/>\n    sleep 10<br \/>\ndone<\/p>\n<p>\u7136\u540e\u4f7f\u7528nohup\u5728\u540e\u53f0\u8fd0\u884c\u5b83&#xff1a;<\/p>\n<p>chmod &#043;x daemon.sh<br \/>\nnohup .\/daemon.sh &gt; service.log 2&gt;&amp;1 &amp;<\/p>\n<p>\u8fd9\u6837\u5373\u4f7f\u670d\u52a1\u5d29\u6e83&#xff0c;\u4e5f\u4f1a\u572810\u79d2\u540e\u91cd\u542f\u3002\u65e5\u5fd7\u4f1a\u8bb0\u5f55\u5728service.log\u6587\u4ef6\u4e2d\u3002<\/p>\n<h4>5.3 \u6027\u80fd\u4e0e\u6548\u679c\u5e73\u8861\u70b9<\/h4>\n<p>\u5728\u4f4e\u914d\u670d\u52a1\u5668\u4e0a&#xff0c;\u6211\u4eec\u9700\u8981\u63a5\u53d7\u4e00\u4e9b\u6298\u8877&#xff1a;<\/p>\n<ul>\n<li>\u901f\u5ea6&#xff1a;\u5355\u5f20\u56fe\u7247\u68c0\u6d4b\u65f6\u95f4\u53ef\u80fd\u57281-3\u79d2&#xff0c;\u6bd4\u9ad8\u6027\u80fd\u670d\u52a1\u5668\u6162\u3002\u901a\u8fc7\u8bbe\u7f6econcurrency_count&#061;1&#xff0c;\u907f\u514d\u4e86\u6392\u961f\u62e5\u5835&#xff0c;\u7528\u6237\u4f53\u9a8c\u662f\u201c\u6162\u4f46\u7a33\u5b9a\u201d&#xff0c;\u800c\u4e0d\u662f\u201c\u5361\u6b7b\u65e0\u54cd\u5e94\u201d\u3002<\/li>\n<li>\u7cbe\u5ea6&#xff1a;\u5982\u679c\u4f7f\u7528\u4e86half()\u7cbe\u5ea6\u4e14\u6548\u679c\u53ef\u63a5\u53d7&#xff0c;\u90a3\u662f\u6700\u597d\u7684\u3002\u5982\u679c\u4e0d\u884c&#xff0c;\u5c31\u9000\u56deFloat32&#xff0c;\u5185\u5b58\u5360\u7528\u4f1a\u9ad8\u4e00\u4e9b&#xff0c;\u4f46\u7cbe\u5ea6\u6709\u4fdd\u969c\u3002<\/li>\n<li>\u56fe\u7247\u5c3a\u5bf8&#xff1a;\u901a\u8fc7max_side_length\u9650\u5236&#xff08;\u59821024\u50cf\u7d20&#xff09;&#xff0c;\u5927\u90e8\u5206\u624b\u673a\u548c\u76f8\u673a\u7167\u7247\u90fd\u80fd\u5904\u7406&#xff0c;\u4e14\u80fd\u663e\u8457\u964d\u4f4e\u5185\u5b58\u6d88\u8017\u3002\u5bf9\u4e8e\u7279\u522b\u5c0f\u7684\u8138&#xff0c;\u53ef\u80fd\u4f1a\u5f71\u54cd\u68c0\u6d4b&#xff0c;\u4f46\u8fd9\u5728\u4f4e\u914d\u73af\u5883\u4e0b\u662f\u5408\u7406\u7684\u53d6\u820d\u3002<\/li>\n<\/ul>\n<h3>6. \u603b\u7ed3\u4e0e\u5efa\u8bae<\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4&#xff0c;\u6211\u4eec\u6210\u529f\u5730\u5c06\u4e00\u4e2a\u9700\u8981\u4e00\u5b9a\u7b97\u529b\u7684MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b\u53ca\u5176WebUI&#xff0c;\u9002\u914d\u5230\u4e86\u4ec52\u68382GB\u7684\u4f4e\u914d\u670d\u52a1\u5668\u4e0a\u3002\u6211\u4eec\u6765\u56de\u987e\u4e00\u4e0b\u5173\u952e\u70b9&#xff1a;<\/p>\n<li>\u7cbe\u7b80\u73af\u5883&#xff1a;\u4f7f\u7528headless\u7248\u672c\u7684\u5e93&#xff0c;\u6309\u9700\u5b89\u88c5\u4f9d\u8d56\u3002<\/li>\n<li>\u9650\u5236\u5e76\u53d1&#xff1a;\u8fd9\u662f\u4fdd\u8bc1\u7a33\u5b9a\u6027\u7684\u6700\u91cd\u8981\u63aa\u65bd&#xff0c;\u5c06Gradio\u7684concurrency-count\u8bbe\u7f6e\u4e3a1\u3002<\/li>\n<li>\u4f18\u5316\u6a21\u578b&#xff1a;\u5f3a\u5236\u4f7f\u7528CPU&#xff0c;\u5e76\u8c28\u614e\u5c1d\u8bd5\u534a\u7cbe\u5ea6(float16)\u4ee5\u8282\u7701\u5185\u5b58\u3002<\/li>\n<li>\u63a7\u5236\u8f93\u5165&#xff1a;\u9650\u5236\u4e0a\u4f20\u56fe\u7247\u5927\u5c0f&#xff0c;\u5e76\u5728\u9884\u5904\u7406\u9636\u6bb5\u7f29\u653e\u8fc7\u5927\u56fe\u7247\u3002<\/li>\n<li>\u7cfb\u7edf\u76d1\u63a7&#xff1a;\u4f7f\u7528htop\u7b49\u5de5\u5177\u76d1\u63a7\u8d44\u6e90&#xff0c;\u5e76\u8bbe\u7f6e\u7b80\u5355\u7684\u5b88\u62a4\u8fdb\u7a0b\u786e\u4fdd\u670d\u52a1\u5d29\u6e83\u540e\u80fd\u91cd\u542f\u3002<\/li>\n<p>\u8fd9\u5957\u65b9\u6848\u7684\u610f\u4e49\u5728\u4e8e&#xff0c;\u5b83\u6781\u5927\u5730\u964d\u4f4e\u4e86AI\u6280\u672f\u843d\u5730\u7684\u95e8\u69db\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u6837\u7684\u670d\u52a1\u90e8\u7f72\u5728\u6811\u8393\u6d3e\u3001\u8001\u65e7\u7b14\u8bb0\u672c\u3001\u6216\u8005\u6700\u4fbf\u5b9c\u7684\u4e91\u670d\u52a1\u5668\u4e0a&#xff0c;\u7528\u4e8e\u4e2a\u4eba\u9879\u76ee\u3001\u539f\u578b\u9a8c\u8bc1\u3001\u4f4e\u5e76\u53d1\u91cf\u7684\u5185\u90e8\u5de5\u5177\u7b49\u573a\u666f\u3002<\/p>\n<p>\u6700\u540e\u7684\u5c0f\u5efa\u8bae&#xff1a;\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d&#xff0c;\u5982\u679c\u4e3b\u8981\u901a\u8fc7API\u8c03\u7528&#xff0c;\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u66f4\u8f7b\u91cf\u7684Web\u6846\u67b6&#xff08;\u5982FastAPI&#xff09;\u66ff\u4ee3Gradio&#xff0c;\u5e76\u5173\u95edWebUI\u754c\u9762&#xff0c;\u8fd9\u6837\u53ef\u4ee5\u8fdb\u4e00\u6b65\u8282\u7701\u8d44\u6e90\u3002\u4f46\u5bf9\u4e8e\u9700\u8981\u53ef\u89c6\u5316\u64cd\u4f5c\u7684\u60c5\u51b5&#xff0c;\u672c\u6587\u63d0\u4f9b\u7684Gradio\u65b9\u6848\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5e73\u8861\u70b9\u3002<\/p>\n<p>\u5e0c\u671b\u8fd9\u4efd\u6307\u5357\u80fd\u5e2e\u52a9\u4f60&#xff0c;\u8ba9\u6709\u9650\u7684\u7b97\u529b\u4e5f\u80fd\u53d1\u6325\u51faAI\u7684\u4ef7\u503c\u3002<\/p>\n<hr \/>\n<p>\u83b7\u53d6\u66f4\u591aAI\u955c\u50cf<\/p>\n<p>\u60f3\u63a2\u7d22\u66f4\u591aAI\u955c\u50cf\u548c\u5e94\u7528\u573a\u666f&#xff1f;\u8bbf\u95ee CSDN\u661f\u56fe\u955c\u50cf\u5e7f\u573a&#xff0c;\u63d0\u4f9b\u4e30\u5bcc\u7684\u9884\u7f6e\u955c\u50cf&#xff0c;\u8986\u76d6\u5927\u6a21\u578b\u63a8\u7406\u3001\u56fe\u50cf\u751f\u6210\u3001\u89c6\u9891\u751f\u6210\u3001\u6a21\u578b\u5fae\u8c03\u7b49\u591a\u4e2a\u9886\u57df&#xff0c;\u652f\u6301\u4e00\u952e\u90e8\u7f72\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357&#xff1a;\u4f4e\u914d\u670d\u52a1\u5668&#xff08;2\u68382GB&#xff09;\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7<br \/>\n1. \u5f15\u8a00&#xff1a;\u5f53\u5f3a\u5927\u6a21\u578b\u9047\u4e0a\u6709\u9650\u7b97\u529b<br \/>\n\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4f60\u624b\u5934\u6709\u4e00\u53f0\u95f2\u7f6e\u7684\u65e7\u670d\u52a1\u5668&#xff0c;\u6216\u8005\u4e00\u4e2a\u914d\u7f6e\u4e0d\u9ad8\u7684\u4e91\u4e3b\u673a&#xff0c;\u53ea\u67092\u4e2aCPU\u6838\u5fc3\u548c2GB\u5185\u5b58\u3002\u4f60\u60f3\u5728\u4e0a\u9762\u90e8\u7f72\u4e00\u4e2a\u5148\u8fdb\u7684\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#xff0c;\u7528\u6765\u5904\u7406\u56fe\u7247\u3001\u8bc6\u522b\u7528\u6237&#xff0c;\u751a\u81f3\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u5b89\u9632\u76d1\u63a7\u3002\u4f46\u4e00\u770b\u5230\u90a3\u4e9b\u52a8\u8f84\u8981\u6c428GB\u300116GB\u5185\u5b58<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7591,9349,5961,523],"topic":[],"class_list":["post-83503","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-mogface","tag-5961","tag-523"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/83503.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357&#xff1a;\u4f4e\u914d\u670d\u52a1\u5668&#xff08;2\u68382GB&#xff09;\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 1. \u5f15\u8a00&#xff1a;\u5f53\u5f3a\u5927\u6a21\u578b\u9047\u4e0a\u6709\u9650\u7b97\u529b \u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4f60\u624b\u5934\u6709\u4e00\u53f0\u95f2\u7f6e\u7684\u65e7\u670d\u52a1\u5668&#xff0c;\u6216\u8005\u4e00\u4e2a\u914d\u7f6e\u4e0d\u9ad8\u7684\u4e91\u4e3b\u673a&#xff0c;\u53ea\u67092\u4e2aCPU\u6838\u5fc3\u548c2GB\u5185\u5b58\u3002\u4f60\u60f3\u5728\u4e0a\u9762\u90e8\u7f72\u4e00\u4e2a\u5148\u8fdb\u7684\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#xff0c;\u7528\u6765\u5904\u7406\u56fe\u7247\u3001\u8bc6\u522b\u7528\u6237&#xff0c;\u751a\u81f3\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u5b89\u9632\u76d1\u63a7\u3002\u4f46\u4e00\u770b\u5230\u90a3\u4e9b\u52a8\u8f84\u8981\u6c428GB\u300116GB\u5185\u5b58\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/83503.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T16:09:09+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83503.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/83503.html\",\"name\":\"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T16:09:09+00:00\",\"dateModified\":\"2026-07-25T16:09:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/83503.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/83503.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/83503.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/83503.html","og_locale":"zh_CN","og_type":"article","og_title":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357&#xff1a;\u4f4e\u914d\u670d\u52a1\u5668&#xff08;2\u68382GB&#xff09;\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 1. \u5f15\u8a00&#xff1a;\u5f53\u5f3a\u5927\u6a21\u578b\u9047\u4e0a\u6709\u9650\u7b97\u529b \u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4f60\u624b\u5934\u6709\u4e00\u53f0\u95f2\u7f6e\u7684\u65e7\u670d\u52a1\u5668&#xff0c;\u6216\u8005\u4e00\u4e2a\u914d\u7f6e\u4e0d\u9ad8\u7684\u4e91\u4e3b\u673a&#xff0c;\u53ea\u67092\u4e2aCPU\u6838\u5fc3\u548c2GB\u5185\u5b58\u3002\u4f60\u60f3\u5728\u4e0a\u9762\u90e8\u7f72\u4e00\u4e2a\u5148\u8fdb\u7684\u4eba\u8138\u68c0\u6d4b\u670d\u52a1&#xff0c;\u7528\u6765\u5904\u7406\u56fe\u7247\u3001\u8bc6\u522b\u7528\u6237&#xff0c;\u751a\u81f3\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u5b89\u9632\u76d1\u63a7\u3002\u4f46\u4e00\u770b\u5230\u90a3\u4e9b\u52a8\u8f84\u8981\u6c428GB\u300116GB\u5185\u5b58","og_url":"https:\/\/www.wsisp.com\/helps\/83503.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T16:09:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/83503.html","url":"https:\/\/www.wsisp.com\/helps\/83503.html","name":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T16:09:09+00:00","dateModified":"2026-07-25T16:09:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/83503.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/83503.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/83503.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"MogFace\u4eba\u8138\u68c0\u6d4b\u6a21\u578b-WebUI\u7b97\u529b\u9002\u914d\u6307\u5357\uff1a\u4f4e\u914d\u670d\u52a1\u5668\uff082\u68382GB\uff09\u8f7b\u91cf\u8fd0\u884c\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=83503"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/83503\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=83503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=83503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=83503"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=83503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}