{"id":2525,"date":"2025-03-22T18:07:07","date_gmt":"2025-03-22T10:07:07","guid":{"rendered":"https:\/\/www.lanxy.ink\/?p=2525"},"modified":"2025-03-27T21:58:28","modified_gmt":"2025-03-27T13:58:28","slug":"flownet2-%e5%ae%89%e8%a3%85%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/www.lanxy.ink\/?p=2525","title":{"rendered":"Flownet2 \u5b89\u88c5\u3001\u5149\u6d41\u4f30\u8ba1\u63d0\u53d6\u7b14\u8bb0"},"content":{"rendered":"<h4>\u524d\u8a00<\/h4>\n<p>\u6700\u8fd1\u9700\u8981\u7528\u5230\u89c6\u9891\u7684\u5149\u6d41\u6587\u4ef6\uff0c\u6240\u4ee5\u51b3\u5b9a\u8ddf\u968f\u524d\u8f88\u4eec\u7684\u6b65\u4f10\uff0c\u81ea\u884c\u4f7f\u7528 Flownet2 \u63d0\u53d6\u89c6\u9891\u5149\u6d41\uff0c\u4f46\u662f\u7531\u4e8e Flownet2 \u592a\u8001\u4e86\uff0c\u7f51\u4e0a\u7684\u653b\u7565\u4e5f\u90fd\u662f\u51e0\u5e74\u524d\u7684\u4e86\uff0c\u6211\u5b89\u88c5\u7684\u65f6\u5019\u9047\u5230\u4e86\u5f88\u591a\u653b\u7565\u91cc\u6ca1\u63d0\u5230\u7684\u95ee\u9898\uff0c\u88ab\u56f0\u6270\u4e86\u8bb8\u4e45\u624d\u89e3\u51b3\uff0c\u6240\u4ee5\u4e2d\u95f4\u5c31\u6253\u7b97\u8fb9\u505a\u8fb9\u8bb0\uff0c\u65b9\u4fbf\u540e\u9762\u6362\u65b0\u670d\u52a1\u5668\u7684\u65f6\u5019\u91cd\u65b0\u5b89\u88c5 Flownet2 \u4e0d\u4f1a\u592a\u9ebb\u70e6\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>2025.03.24 \u66f4\u65b0<\/h4>\n<div class='alert alert-primary'><span class='alert-inner--text'>\u8fd9\u7bc7\u6587\u7ae0\u63d0\u53d6\u51fa\u6765\u7684\u5149\u6d41\u5c3a\u5bf8\u548c\u89c6\u9891\u5e27\u7684\u5c3a\u5bf8\u4e0d\u4e00\u6837\uff0c\u5982\u679c\u89c6\u9891\u5e27\u7684\u5c3a\u5bf8\u662f 240 * 360\uff0c\u63d0\u53d6\u51fa\u6765\u7684\u5149\u6d41\u5c3a\u5bf8\u53ea\u6709 192 * 320\uff0c\u5982\u679c\u8981\u7528\u5b98\u65b9 Flownet2 \u63d0\u53d6\u6307\u5b9a\u5c3a\u5bf8\u7684\u5149\u6d41\uff0c\u9700\u8981\u989d\u5916\u7f16\u5199\u77eb\u6b63\u5149\u6d41\u56fe\u5c3a\u5bf8\u7684\u4ee3\u7801\u3002\u540e\u9762\u91cd\u65b0\u4f7f\u7528\u4e86\u5176\u4ed6\u4eba\u7684\u63d0\u53d6\u6a21\u5757\u63d0\u53d6\u4e86\u548c\u89c6\u9891\u5e27\u5c3a\u5bf8\u4e00\u6837\u7684\u5149\u6d41\uff0c\u5177\u4f53\u4e5f\u662f\u4e00\u4e2a\u89c6\u9891\u5f02\u5e38\u68c0\u6d4b\u7684\u9879\u76ee\uff1a<span style=\"color: #000000;\"><a style=\"color: #000000;\" href=\"https:\/\/github.com\/LiUzHiAn\/hf2vad\/tree\/master\">LiUzHiAn\/hf2vad<\/a><\/span> <\/span><\/div>\n<p>&nbsp;<\/p>\n<p>\u6307\u5357\u53c2\u80031\uff1a<a href=\"https:\/\/blog.csdn.net\/Strive_For_Future\/article\/details\/120940839\">\u624b\u628a\u624b\u5b89\u88c5flownet2-pytorch_resample2d-CSDN\u535a\u5ba2<\/a><\/p>\n<p>\u6307\u5357\u53c2\u80032\uff1a<a href=\"https:\/\/blog.csdn.net\/nichengshenhe\/article\/details\/145399304?spm=1001.2101.3001.6650.2&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2-145399304-blog-120940839.235%5Ev43%5Econtrol&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2-145399304-blog-120940839.235%5Ev43%5Econtrol&amp;utm_relevant_index=4\">Flownet2-PyTorch \u5b89\u88c5\u4f7f\u7528\u6d41\u7a0b-CSDN\u535a\u5ba2<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>\u670d\u52a1\u5668\u7684\u73af\u5883\uff1a<\/h4>\n<p>Ubuntu 16.04\uff0cCuda 10.2<\/p>\n<p>&nbsp;<\/p>\n<h4>1) \u521b\u5efa\u73af\u5883\uff1a<\/h4>\n<pre class=\"code\">conda create -n flownet2 python=3.7<\/pre>\n<p>\u8fd9\u91cc\u6211\u7528\u8fc7 python 3.6 \u548c 3.8\uff0c\u4f46\u540e\u9762\u5747\u51fa\u73b0\u4e86\u95ee\u9898\u65e0\u6cd5\u89e3\u51b3\uff0c\u5c24\u5176\u662f 3.6\uff0c\u8ddf\u7740\u653b\u7565\u8d70\u4e5f\u4e0d\u884c\uff0c\u592a\u8001\u4e86\u4e0d\u8981\u7528\uff01<\/p>\n<p>&nbsp;<\/p>\n<h4>2) \u8fdb\u5165\u73af\u5883<\/h4>\n<pre class=\"code\">conda activate flownet<span class=\"hljs-number\">2<\/span><\/pre>\n<p>&nbsp;<\/p>\n<h4>3) \u5b89\u88c5 gcc 7, g++ 7<\/h4>\n<pre class=\"code\">sudo add-apt-repository ppa:ubuntu-toolchain-r<span class=\"hljs-operator\">\/<\/span><span class=\"hljs-keyword\">test<\/span> \r\nsudo apt-get update\r\nsudo apt-get install gcc-<span class=\"hljs-number\">7<\/span>\r\nsudo apt-get install g<span class=\"hljs-operator\">+<\/span><span class=\"hljs-operator\">+<\/span>-<span class=\"hljs-number\">7<\/span><\/pre>\n<p>\u8fd9\u91cc\u6211\u5728\u5b89\u88c5\u7684\u65f6\u5019\u4f1a\u63d0\u793a\u201c\u60a8\u7684\u7f51\u7edc\u9700\u8981\u8ba4\u8bc1\u5417\uff1f\u201d\uff0c\u9700\u8981\u624b\u52a8\u4e0a\u670d\u52a1\u5668\u8fdb\u884c\u7f51\u9875\u8ba4\u8bc1\u3002<em>\uff08\u975e\u5e38\u60f3\u5410\u69fd\u7684\u4e00\u70b9\u5c31\u662f\u4ee5\u524d\u6821\u56ed\u7f51\u652f\u63012\u53f0PC\u8bbe\u5907\u767b\u5f55\uff0c\u4f46\u6700\u8fd1\u53ea\u80fd1\u53f0\u8bbe\u5907\u767b\u5f55\u4e86\uff0c\u9700\u8981\u6765\u56de\u5728\u670d\u52a1\u5668\u548c\u81ea\u5df1\u7535\u8111\u4e0a\u8ba4\u8bc1\u6821\u56ed\u7f51\uff0c\u5c31\u5f88\u4e0d\u65b9\u4fbf\uff09<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>4) \u5c06gcc7\uff0cg++7\u4f5c\u4e3a\u9ed8\u8ba4\u9009\u9879<\/h4>\n<pre class=\"code\">sudo update-alternatives --install \/usr\/bin\/gcc gcc \/usr\/bin\/gcc-7 100\r\nsudo update-alternatives --config gcc\r\n\r\nsudo update-alternatives --install \/usr\/bin\/g++ g++ \/usr\/bin\/g++-7 100\r\nsudo update-alternatives --config g++\r\n\r\nsudo update-alternatives --install \/usr\/bin\/gcc gcc \/usr\/bin\/gcc-7 50<\/pre>\n<p>\u8fd9\u91cc\u5982\u679c\u4e4b\u524d\u914d\u7f6e\u8fc7\u4e00\u904d\u540e\u9762\u5c31\u4e0d\u7528\u518d\u914d\u7f6e\u4e86\uff0c\u548c\u73af\u5883\u65e0\u5173<\/p>\n<p>&nbsp;<\/p>\n<h4>5) \u5b89\u88c5 Pytorch<\/h4>\n<pre class=\"code\"># \u5931\u8d25\u6307\u4ee4\r\nconda install pytorch<span class=\"hljs-operator\">=<\/span><span class=\"hljs-operator\">=<\/span><span class=\"hljs-number\">1.9.0<\/span> torchvision<span class=\"hljs-operator\">=<\/span><span class=\"hljs-operator\">=<\/span><span class=\"hljs-number\">0.6.1<\/span> cudatoolkit<span class=\"hljs-operator\">=<\/span><span class=\"hljs-number\">10.2<\/span> -c pytorch<\/pre>\n<div class='alert alert-primary'><span class='alert-inner--text'>\u8fd9\u91cc\u4f7f\u7528 \u5931\u8d25\u6307\u4ee4 \u4f1a\u5361\u5f88\u957f\u65f6\u95f4\uff0c\u4e00\u76f4\u5728 Solving environment\uff0c\u800c\u4e14\u540e\u9762\u6ca1\u529e\u6cd5\u6267\u884c\u7b2c 8 \u6b65\uff0c\u76f4\u63a5\u63d0\u793a\u6ca1\u6709\u627e\u5230\u5305 pytorch\uff0c\u67e5\u9605\u5f88\u4e45\uff0c\u6c42\u52a9\u5927\u6a21\u578b\u5747\u65e0\u679c<\/span><\/div>\n<pre class=\"code\">pip install https:\/\/download.pytorch.org\/whl\/cu102\/torch-1.12.0%2Bcu102-cp37-cp37m-linux_x86_64.whl#sha256=6cdaf3bba2733cabdb96d39d5ca5f733d5e1be9f4e27afc7dabed349dc86<\/pre>\n<p>\u5728\u4e0b\u9762\u7684\u7f51\u7ad9\u4e2d\u627e\u5230\u7b26\u5408\u81ea\u5df1 python \u7248\u672c\u3001torchvision \u7248\u672c\u7684\u5305\uff0c\u7136\u540e\u53f3\u952e\u4fdd\u5b58\u94fe\u63a5\uff0c\u7c98\u8d34\u5230 pip install \u540e\u9762\uff0c\u5404\u4e2a\u7f51\u7ad9\u7684\u8fde\u63a5\u5982\u4e0b\uff08\u5176\u4e2d\u7684 cu102 \u8981\u66ff\u6362\u6210\u81ea\u5df1\u5bf9\u5e94\u7684 cuda \u7248\u672c\uff0ctorch \u7248\u672c\u548c torchvision \u7248\u672c\u4e5f\u8981\u5bf9\u5e94\u4e0a\uff0c\u5bf9\u5e94\u5173\u7cfb\u53ef\u4ee5\u770b\u8fd9\u4e2a\u535a\u5ba2\uff1a<a href=\"https:\/\/blog.csdn.net\/shiwanghualuo\/article\/details\/122860521\">\u70b9\u51fb\u8df3\u8f6c<\/a>\uff09\uff1a<\/p>\n<ul>\n<li>Pytorch \u7684\u7f51\u7ad9\uff1a<a href=\"https:\/\/download.pytorch.org\/whl\/cu102\/torch\/\">download.pytorch.org\/whl\/cu102\/torch\/<\/a><\/li>\n<li>torchvision \u7684\u7f51\u7ad9\uff1a<a href=\"https:\/\/download.pytorch.org\/whl\/cu102\/torchvision\">download.pytorch.org\/whl\/cu102\/torchvision<\/a><\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u6211\u5b89\u88c5\u4e86 <code>pytorch-1.12.0+cu102-cp37<\/code> \u548c <code>torchvision-0.13.0+cu102-cp37<\/code><\/p>\n<p>&nbsp;<\/p>\n<h4>6) \u4e0b\u8f7d flownet2 \u4ee3\u7801<\/h4>\n<pre class=\"code\">git clone https:<span class=\"hljs-operator\">\/<\/span><span class=\"hljs-operator\">\/<\/span>github.com<span class=\"hljs-operator\">\/<\/span>NVIDIA<span class=\"hljs-operator\">\/<\/span>flownet<span class=\"hljs-number\">2<\/span>-pytorch.git\r\ncd flownet<span class=\"hljs-number\">2<\/span>-pytorch<\/pre>\n<p>&nbsp;<\/p>\n<h4>7)\u5bf9\u4ee3\u7801\u8fdb\u884c\u4fee\u6539<\/h4>\n<p><strong>\u5728\u4ee5\u4e0b\u4e09\u4e2a\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li><strong>networks\/channelnorm_package\/setup.py<\/strong><\/li>\n<li><strong>networks\/resample2d_package\/setup.py<\/strong><\/li>\n<li><strong>networks\/correlation_package\/setup.py<\/strong><\/li>\n<\/ul>\n<p><strong>\u4f5c\u5982\u4e0b\u4fee\u6539<\/strong><\/p>\n<pre class=\"code\"># \u539f\u4ee3\u7801\r\ncxx_args <span class=\"hljs-operator\">=<\/span> [<span class=\"hljs-string\">'-std=c++11'<\/span>]<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\ncxx_args <span class=\"hljs-operator\">=<\/span> [<span class=\"hljs-string\">'-std=c++14'<\/span>]<\/pre>\n<p><strong>\u5728 <span style=\"background-color: #f5f5f5; font-family: Consolas, Monaco, monospace;\">flownet2-pytorch\/utils\/frame_utils.py<\/span> \u4f5c\u5982\u4e0b\u4fee\u6539<\/strong><\/p>\n<pre class=\"code\"># \u539f\u4ee3\u7801 \r\n<span class=\"hljs-keyword\">from<\/span> scipy.<span class=\"hljs-property\">misc<\/span> <span class=\"hljs-keyword\">import<\/span> imread<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\n<span class=\"hljs-keyword\">from<\/span> imageio <span class=\"hljs-keyword\">import<\/span> imread<\/pre>\n<p><strong>\u5728 <span style=\"background-color: #f5f5f5; font-family: Consolas, Monaco, monospace;\">flownet2-pytorch\/datasets.py<\/span> \u4f5c\u5982\u4e0b\u4fee\u6539<\/strong><\/p>\n<pre class=\"code\"># \u539f\u4ee3\u7801\r\n<span class=\"hljs-keyword\">from<\/span> scipy.<span class=\"hljs-property\">misc<\/span> <span class=\"hljs-keyword\">import<\/span> imread, imresize<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\n<span class=\"hljs-keyword\">from<\/span> imageio <span class=\"hljs-keyword\">import<\/span> imread<\/pre>\n<p><strong>\u5728 <span style=\"background-color: #f5f5f5; font-family: Consolas, Monaco, monospace;\">flownet2-pytorch\/networks\/channelnorm_package\/channelnorm.py<\/span> \u4e2d\u4f5c\u5982\u4e0b\u4fee\u6539<\/strong><\/p>\n<pre class=\"code\"># \u539f\u4ee3\u7801\r\nclass ChannelNormFunction(Function):\r\n    @staticmethod\r\n    def forward(ctx, input1, norm_deg=2):\r\n        assert input1.is_contiguous()  # \u5728\u4e0a\u65b9\u63d2\u5165<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\nclass ChannelNormFunction(Function):\r\n    @staticmethod\r\n    def forward(ctx, input1, norm_deg=2):\r\n        input1 = input1.contiguous()  # \u65b0\u6dfb\u52a0\u7684\u4ee3\u7801\r\n        assert input1.is_contiguous()<\/pre>\n<p>&nbsp;<\/p>\n<h4>8) \u8fdb\u5165 install.sh \u6240\u5728\u6587\u4ef6\u5939\u540e\u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/h4>\n<pre class=\"code\">.\/install.sh<\/pre>\n<p>&nbsp;<\/p>\n<h4>9) \u8f93\u5165\u5982\u4e0b\u6307\u4ee4\u6d4b\u8bd5\u4e00\u4e0b<\/h4>\n<pre class=\"code\"><span class=\"hljs-selector-tag\">python<\/span> <span class=\"hljs-selector-tag\">main<\/span><span class=\"hljs-selector-class\">.py<\/span> <span class=\"hljs-selector-tag\">-h<\/span><\/pre>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u7f3a\u5565\u88c5\u5565\u7684\u9636\u6bb5\u4e86<br \/>\n\u7f3a\u5931\u7684\u4f9d\u8d56\uff08opencv-python \u548c numpy \u6211\u6ca1\u5b89\u88c5\u8fc7\u4e0d\u77e5\u9053\u4e3a\u4f55\u4e5f\u6d4b\u8bd5\u6210\u529f\u4e86\uff09\uff1a<\/p>\n<pre class=\"code\">pip install tensorboardX\r\npip install setproctitle\r\npip install colorama\r\npip install tqdm\r\npip install imageio\r\npip install scipy\r\npip install matplotlib\r\npip install pytz\r\npip install opencv-python\r\npip install numpy<\/pre>\n<div  class='collapse-block shadow-sm collapse-block-transparent collapsed hide-border-left'><div class='collapse-block-title'><span class='collapse-block-title-inner'>\u6211\u5b89\u88c5\u65f6\u7684\u4f9d\u8d56\u7248\u672c\u4e00\u89c8<\/span><i class='collapse-icon fa fa-angle-down'><\/i><\/div><div class='collapse-block-body' style='display:none;'><br \/>\ntensorboardX-2.6.2.2\u00a0 \u00a0 \u540c\u65f6\u4f1a\u5b89\u88c5:<br \/>\n&#8211; packaging-24.0<br \/>\n&#8211; protobuf-4.24.4<br \/>\nsetproctitle-1.3.3<br \/>\ncolorama-0.4.6<br \/>\ntqdm-4.67.1<br \/>\nimageio-2.31.2<br \/>\nmatplotlib-3.5.3\u00a0 \u00a0 \u540c\u65f6\u4f1a\u5b89\u88c5:<br \/>\n&#8211; cycler-0.11.0<br \/>\n&#8211; fonttools-4.38.0<br \/>\n&#8211; kiwisolver-1.4.5<br \/>\n&#8211; pyparsing-3.1.4<br \/>\n&#8211; python-dateutil-2.9.0.post0<br \/>\n&#8211; six-1.17.0<br \/>\npytz-2025.1<br \/>\n<\/div><\/div>\n<p>&nbsp;<\/p>\n<h4>10) \u4e0b\u8f7d\u9884\u8bad\u7ec3\u7684\u6743\u91cd\u6587\u4ef6<\/h4>\n<p>\u6211\u53ea\u7528 Flownet2 \u6765\u505a\u5149\u6d41\u4f30\u8ba1\uff0c\u6240\u4ee5\u76f4\u63a5\u4e0b\u8f7d\u8bad\u7ec3\u597d\u7684\u6743\u91cd\u6587\u4ef6\uff0c\u7531\u4e8e\u5b98\u65b9 github \u4ed3\u5e93\u91cc\u7684\u94fe\u63a5\u9700\u8981\u7533\u8bf7\uff0c\u7b49\u4e0d\u4e86\u4e86\u5c31\u76f4\u63a5\u627e\u4e86\u8fd9\u4e2a\u5e16\u5b50\u91cc\u7684\u767e\u5ea6\u7f51\u76d8\uff1a<a href=\"https:\/\/blog.csdn.net\/Strive_For_Future\/article\/details\/120940839\">\u624b\u628a\u624b\u5b89\u88c5flownet2-pytorch_resample2d-CSDN\u535a\u5ba2<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>11) \u5f00\u59cb\u6b63\u5f0f\u63a8\u7406<\/h4>\n<p>\u65b0\u5efa\u4e00\u4e2a run.sh \u6587\u4ef6\uff0c\u5199\u5165\u5982\u4e0b\u4ee3\u7801<\/p>\n<pre class=\"code\">python .\/flownet2-pytorch\/main.py \\\r\n--inference \\\r\n--save_flow \\\r\n--model FlowNet2 \\\r\n--inference_dataset ImagesFromFolder \\\r\n--resume \/path\/to\/your\/flownet2\/checkpoint \\\r\n--inference_dataset_root \/path\/to\/your\/dataset\/root\/ \\\r\n--save \/path\/to\/your\/saved\/folder\/ \\\r\n--number_gpus 1<\/pre>\n<p>\u7b80\u5355\u4e86\u89e3\u4e86\u4e00\u4e0b\uff0c<code>--inference<\/code> \u662f\u63a8\u7406\u6a21\u5f0f\uff0c<code>--save-flow<\/code> \u662f\u8981\u5c06\u5149\u6d41\u6587\u4ef6\u4fdd\u5b58\u4e0b\u6765\uff0c<code>--model<\/code> \u5c31\u662f\u8981\u4f7f\u7528\u7684\u6a21\u578b\uff0c<code>--inference_dataset ImagesFromFolder<\/code> \u8868\u793a\u4ece\u6587\u4ef6\u5939\u91cc\u8bfb\u53d6\u56fe\u7247\uff0c<code>--resume<\/code> \u662f\u4e0b\u8f7d\u7684\u6743\u91cd\u6587\u4ef6\u8def\u5f84\uff0c<code>--inference_dataset_root<\/code> \u662f\u8981\u5904\u7406\u7684\u6570\u636e\u96c6\u8def\u5f84\uff0c\u91cc\u9762\u5305\u542b\u56fe\u7247\uff0c<code>--save<\/code> \u5c31\u662f\u5149\u6d41\u6587\u4ef6\u4fdd\u5b58\u7684\u8def\u5f84\uff0c<code>--number_gpus<\/code> \u4e0d\u660e\uff0c\u6709\u4eba\u8bf4\u786e\u4fdd\u8f93\u51fa\u7684\u5149\u6d41\u6587\u4ef6\u6570\u91cf\u4e3a\u56fe\u7247\u6570\u91cf\u51cf1\uff0c\u8fd9\u91cc\u6ca1\u6709\u52a8\u5b83\u3002\u8981\u4fee\u6539\u7684\u5730\u65b9\u5c31\u662f <code>--resume<\/code>\u3001<code>--inference_dataset_root<\/code>\u3001<code>--save<\/code> \u8fd9\u4e09\u4e2a\u8def\u5f84<\/p>\n<p>\u5728\u51c6\u5907\u8fd0\u884c <code>run.sh<\/code> \u65f6\u53d1\u73b0\u6743\u9650\u4e0d\u591f\uff0c\u53c8\u641c\u4e86\u4e00\u4e0b\u5982\u4f55\u4fee\u6539\u6743\u9650\u3002\u540e\u9762\u53d1\u73b0\u76f4\u63a5\u8fd0\u884c <code>run.sh<\/code> \u4e0d\u663e\u793a\u62a5\u9519\u7ec6\u8282\u3002\u3002\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>12) \u8fd0\u884c\u4e2d\u51fa\u73b0\u7684\u5176\u4ed6\u95ee\u9898<\/h4>\n<h5>\u2460\u4e00\u5f00\u59cb\u8fd0\u884c\u51fa\u73b0\u4e86\u8fd9\u4e2a\u95ee\u9898\uff1a<\/h5>\n<pre class=\"code\">ValueError: Function has keyword-only parameters or annotations, use getfullargspec() API which can support them<\/pre>\n<p>\u7f51\u4e0a\u5404\u8bf4\u5404\u7684\uff0c\u53bb\u95ee\u4e86 GPT\uff0c\u8bf4 python 3.7 \u5df2\u7ecf\u5f03\u7528\u4e86 <code>getargspec<\/code>\uff0c\u5f97\u5230\u7684\u89e3\u51b3\u65b9\u6cd5\u662f\u627e\u5230 utils\/tools.py\uff0c\u5b9a\u4f4d\u5230\u7b2c 64 \u884c\uff0c\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<pre class=\"code\"># \u6e90\u4ee3\u7801\r\n    argspec = inspect.getargspec(class_obj.__init__)<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\n    argspec = inspect.getfullargspec(class_obj.__init__)<\/pre>\n<h5>\u2461 \u53c8\u9047\u5230\u95ee\u9898\u4e86<\/h5>\n<pre class=\"code\"> File \"\/home\/zlab-3\/xxx\/flownet_work\/flownet2-pytorch\/datasets.py\", line 66, in __init__\r\n    self.frame_size = frame_utils.read_gen(self.image_list[0][0]).shape\r\nIndexError: list index out of range<\/pre>\n<p>GPT \u7684\u8bf4\u6cd5\u662f <code>self.image_list<\/code> \u4e3a\u7a7a\uff0c\u770b\u4e86\u6e90\u4ee3\u7801\u540e\u53d1\u73b0\u5b83\u9ed8\u8ba4\u8bfb\u53d6 <code>MPI Sintel<\/code>\uff0c\u8fd9\u610f\u5473\u7740\u5982\u679c\u8981\u60f3\u8ba9 <code>flownet2<\/code> \u5728\u6211\u7684\u6570\u636e\u96c6\u4e0a\u63a8\u7406\uff0c\u5c31\u9700\u8981\u6dfb\u52a0 <code>--inference_dataset ImagesFromFolder<\/code> \u3002\uff08\u597d\u5728\u540e\u9762\u67e5\u5230\u89e3\u51b3\u65b9\u6cd5\u4e86\uff0c\u5dee\u70b9\u6253\u7b97\u81ea\u5df1\u6413\u4e00\u4e2a <code>Dataset<\/code> \u7c7b\uff09<\/p>\n<p>\u6539\u4e86\u4e4b\u540e\u8fd8\u662f\u62a5\u9519\uff0c\u5c31\u8dd1\u53bb\u770b <code>ImagesFromFolder<\/code> \u7c7b\uff0c\u53d1\u73b0 <code>iext<\/code> \u5f62\u53c2(321\u884c\u5de6\u53f3)\u9ed8\u8ba4\u662f <code>png<\/code>\uff0c\u624b\u52a8\u6539\u6210\u4e86\u9002\u914dped2\u6570\u636e\u96c6\u7684\u00a0<code>tif<\/code>\u00a0\u683c\u5f0f\uff0c\u8fd9\u4e2a\u95ee\u9898\u5c31\u89e3\u51b3\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<h5>\u2462 \u53c8\u53c8\u9047\u5230\u95ee\u9898\u4e86<\/h5>\n<pre class=\"code\">  File \"\/home\/zlab-3\/xxx\/flownet_work\/flownet2-pytorch\/datasets.py\", line 337, in __init__\r\n    self.frame_size = frame_utils.read_gen(self.image_list[0][0]).shape\r\nAttributeError: 'list' object has no attribute 'shape'<\/pre>\n<p>\u5217\u8868\u5f53\u7136\u6ca1\u6709 <code>shape<\/code> \u5c5e\u6027\uff0c\u90a3\u4e3a\u4ec0\u4e48\u662f\u5217\u8868\uff1f\u5662\uff0c<code>read_gen<\/code> \u8fd4\u56de\u4e86\u5217\u8868\u3002<br \/>\n<code>read_gen<\/code> \u662f\u5e72\u561b\u7684\uff1f\u770b\u4e86\u4e0b\uff0c\u7b2c 8 \u884c\u5e94\u8be5\u662f\u5224\u65ad\u56fe\u7247\u7c7b\u578b\u540e\u7f00\u662f\u4e0d\u662f<code>[png, jpeg, ppm, jpg]<\/code>\uff0c\u4f46\u662f <code>tif<\/code> \u6587\u4ef6\u4e0d\u5728\u91cc\u9762\uff0c\u540e\u9762\u76f4\u63a5\u5c31\u8fd4\u56de\u4e00\u4e2a\u7a7a\u5217\u8868\u3002\u6309\u7167\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<pre class=\"code\"># \u4fee\u6539\u524d\r\nif ext == '.png' or ext == '.jpeg' or ext == '.ppm' or ext == '.jpg':<\/pre>\n<pre class=\"code\"># \u4fee\u6539\u540e\r\nif ext in ['.png', '.jpeg', '.ppm', '.jpg', '.tif', '.tiff']<\/pre>\n<p>\u8fd9\u4e2a\u6587\u4ef6\u91cc\u8fd8\u6709\u4e00\u4e2a\u5730\u65b9\u9700\u8981\u6ce8\u610f\uff0c\u5982\u679c\u5b89\u88c5\u7684 <code>imageio<\/code> \u7248\u672c\u6bd4\u8f83\u9ad8\uff0c\u9700\u8981\u5c06 <code>from imageio import imread<\/code> \u6539\u4e3a <code>from imageio.v2 import imread<\/code> \u3002<\/p>\n<p>&nbsp;<\/p>\n<h5>\u2463\u53c8\u53c8\u53c8\u51fa\u95ee\u9898\u4e86<\/h5>\n<p>\u8fd8\u662f\u8fd9\u4e2a <code>read_gen<\/code> \u51fd\u6570<\/p>\n<pre class=\"code\">   if im.shape[2] &gt; 3:\r\nIndexError: tuple index out of range<\/pre>\n<p>\u6211\u7684 <code>tif<\/code> \u56fe\u7247\u662f\u7070\u5ea6\u56fe\uff0c\u53ea\u6709\u4e24\u4e2a\u7ef4\u5ea6\uff0c\u5f97\u5148\u5c06\u5176\u590d\u5236\u4e3a\u4e09\u4e2a\u901a\u9053\uff1a<\/p>\n<pre class=\"code\">if ext in ['.png', '.jpeg', '.ppm', '.jpg', '.tif', '.tiff']:\r\n  im = imread(file_name)\r\n  if im.ndim == 2:                         # \u6dfb\u52a0\r\n    im = np.stack((im, im, im), axis=-1)   # \u6dfb\u52a0\r\n  if im.shape[2] &gt; 3:\r\n    return im[:,:,:3]<\/pre>\n<p>\u4e0d\u6e05\u695a\u8fd9\u6837\u5bf9\u5149\u6d41\u7684\u63d0\u53d6\u662f\u5426\u6709\u5f71\u54cd\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u6210\u529f\u8fd0\u884c<\/h3>\n<p>\u7136\u540e Flownet2 \u7ec8\u4e8e\u6210\u529f\u63d0\u53d6\u51fa\u7b2c\u4e00\u4e2a\u89c6\u9891\u7684\u5149\u6d41\uff01\u81f3\u6b64\u6a21\u578b\u5df2\u7ecf\u8dd1\u901a\u3002\u63a5\u4e0b\u6765\u5c31\u662f\u4fee\u6539 run.sh \u8ba9\u6a21\u578b\u5f00\u59cb\u6279\u91cf\u5904\u7406\u89c6\u9891\uff1a<\/p>\n<pre class=\"code\">#!\/bin\/bash\r\n# \u8bbe\u7f6e\u901a\u7528\u53c2\u6570\r\nCHECKPOINT=\"\/home\/zlab-3\/xxx\/flownet_work\/checkpoints\/FlowNet2_checkpoint.pth.tar\"\r\nSAVE_ROOT=\"\/home\/zlab-3\/xxx\/dataset\/UCSD_Anomaly_Dataset.v1p2\/UCSDped2\/Train_Flow\"\r\nBASE_DATASET=\"\/home\/zlab-3\/xxx\/dataset\/UCSD_Anomaly_Dataset.v1p2\/UCSDped2\/Train\"\r\n\r\n# \u904d\u5386 BASE_DATASET \u4e0b\u7684\u6240\u6709\u89c6\u9891\u6587\u4ef6\u5939\uff08\u5047\u8bbe\u6587\u4ef6\u5939\u547d\u540d\u4e3a Train001, Train002, ...\uff09\r\nfor folder in ${BASE_DATASET}\/Train*; do\r\n  folder_name=$(basename \"$folder\")\r\n  output_dir=\"${SAVE_ROOT}\/${folder_name}\"\r\n  mkdir -p \"$output_dir\"\r\n\r\n  echo \"Processing $folder, saving flow to $output_dir\"\r\n\r\n  python .\/flownet2-pytorch\/main.py \\\r\n    --inference \\\r\n    --save_flow \\\r\n    --model FlowNet2 \\\r\n    --inference_dataset ImagesFromFolder \\\r\n    --resume ${CHECKPOINT} \\\r\n    --inference_dataset_root ${folder} \\\r\n    --save ${output_dir} \\\r\n    --number_gpus 1\r\ndone<\/pre>\n<p>\u505a\u5b8c\u67e5\u770b\u4e86\u4e00\u4e0b\u5149\u6d41\u56fe\u7247\u6240\u5360\u7a7a\u95f4\u5927\u5c0f\uff0c<code>UCSDped2<\/code>+ \u603b\u5171\u7684\u5149\u6d41 .flo \u6587\u4ef6\u5927\u7ea6\u5360 2G\uff0c\u5982\u679c\u6211\u76f4\u63a5\u627e\u73b0\u6210\u7684\u5149\u6d41\u6587\u4ef6\u4e0b\u8f7d\u4f1a\u4e0d\u4f1a\u66f4\u5feb\u4e00\u4e9b\u5462&#8230;&#8230;<\/p>\n<p style=\"font-size: 28px;\"><strong>\u81f3\u5c11\u4e0b\u6b21\u518d\u9700\u8981\u5149\u6d41\u6587\u4ef6\u7684\u65f6\u5019\u6211\u5c31\u4e0d\u7528\u518d\u91cd\u65b0\u8d70\u4e00\u904d Flownet2 \u7684\u201c\u82e6\u75db\u4e4b\u8def\u201d \u4e86\u5427\ud83d\ude2d<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h3>\u5176\u4ed6\u60c5\u51b5<\/h3>\n<p>\u5982\u679c\u9047\u5230\u7c7b\u4f3c\u7684\u9519\u8bef\uff1a<\/p>\n<pre class=\"code\">The detected CUDA version (10.2) mismatches the version that was used to compile\r\nPyTorch (12.1). Please make sure to use the same CUDA versions.<\/pre>\n<p>\u8bf4\u660e\u7cfb\u7edf\u7684 CUDA \u7248\u672c\u548c Pytorch \u7684\u4e0d\u4e00\u6837\uff0c\u9700\u8981\u66f4\u65b0 CUDA \u7248\u672c\u6216 \u964d\u7ea7 Pytorch \u7684 CUDA\u3002\uff08\u5c1d\u8bd5\u8fc7\u5347\u7ea7 cuda\uff0c\u4f46\u662f\u9047\u5230 \u670d\u52a1\u5668 ubuntu \u7248\u672c 16.04 \u592a\u8001\uff0c\u5347\u7ea7 ubuntu \u53c8\u8981\u82b1\u65f6\u95f4\uff0c\u53c8\u5c1d\u8bd5\u964d\u7ea7 pytorch\uff0c\u4f46 conda \u53c8\u592a\u6162\uff0c\u5361\u4e86\u592a\u4e45\u7d22\u6027\u5220\u73af\u5883\u4ece\u5934\u53c8\u914d\u4e86\u4e00\u4e2a\uff09<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5176\u4ed6\u7528\u5230\u7684\u6307\u4ee4<\/h3>\n<h4>\u67e5\u770b\u5f53\u524d ubuntu \u7248\u672c<\/h4>\n<pre class=\"code\">lsb_release -a<\/pre>\n<h4>\u67e5\u770b\u5f53\u524d cuda \u7248\u672c<\/h4>\n<pre class=\"code\">nvcc -V<\/pre>\n<h4><strong>\u4e3a\u67d0\u4e00\u4e2a .sh \u6587\u4ef6\u6388\u4e88\u53ef\u6267\u884c\u6743\u9650<\/strong><\/h4>\n<pre class=\"code\">chmod u+x run.sh<\/pre>\n<h4>\u67e5\u770b\u5f53\u524d\u6587\u4ef6\u5939\u5927\u5c0f<\/h4>\n<pre class=\"code\">df -h<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6700\u8fd1\u9700\u8981\u7528\u5230\u89c6\u9891\u7684\u5149\u6d41\u6587\u4ef6\uff0c\u6240\u4ee5\u51b3\u5b9a\u8ddf\u968f\u524d\u8f88\u4eec\u7684\u6b65\u4f10\uff0c\u81ea\u884c\u4f7f\u7528 Flownet2 \u63d0\u53d6\u89c6\u9891\u5149\u6d41\uff0c\u4f46\u662f\u7531\u4e8e [&hellip;]<\/p>\n","protected":false},"author":311,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[7,1],"tags":[],"class_list":["post-2525","post","type-post","status-publish","format-standard","hentry","category-7","category-common"],"_links":{"self":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/2525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/users\/311"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2525"}],"version-history":[{"count":16,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/2525\/revisions"}],"predecessor-version":[{"id":2541,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/2525\/revisions\/2541"}],"wp:attachment":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}