小编Eha*_*awy的帖子

如何在Jupyter笔记本中设置env变量

我有一个问题,Jupyter在bashrc文件中看不到env变量,有没有办法在jupyter中加载这些变量或者为它添加custom变量?

python bash environment-variables jupyter-notebook

55
推荐指数
7
解决办法
6万
查看次数

'utf-8'编解码器无法解码字节0x80

我正在尝试下载受BVLC训练的模型,我遇到了这个错误

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 110: invalid start byte
Run Code Online (Sandbox Code Playgroud)

我认为这是因为以下功能(完整代码)

  # Closure-d function for checking SHA1.
  def model_checks_out(filename=model_filename, sha1=frontmatter['sha1']):
      with open(filename, 'r') as f:
          return hashlib.sha1(f.read()).hexdigest() == sha1
Run Code Online (Sandbox Code Playgroud)

知道如何解决这个问题吗?

python utf-8 caffe

9
推荐指数
2
解决办法
4万
查看次数

如何使用TVL1 OpenCV函数计算光流

我正在尝试找到用于使用tvl1 opencv函数计算光流的python示例,createOptFlow_DualTVL1但似乎没有足够的文档。

有人可以让我这样做吗?我曾经calcOpticalFlowFarneback在这里提到http://docs.opencv.org/master/d7/d8b/tutorial_py_lucas_kanade.html,但它没有给我准确的结果,tvl1是否足够好,如果没有,我应该寻找另一种方法吗?

[[编辑]]

我有一些区域来自选择性搜索,我只想让区域保持运动,因此计算给定帧的OF,然后获取每个区域的平均值即可。在本文第3.1节中也对此进行了描述

谢谢。

python opencv opticalflow

6
推荐指数
1
解决办法
3973
查看次数

如何在python中加载m4a文件

Is there an easy way to load m4a sound file in python. I've came across audiotools lib but I'm getting an error while using to_pcm fn

audiotools.open('file.m4a').to_pcm()

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-76-e12405d92ce3> in <module>()
----> 1 audiotools.open(p).to_pcm()

/path/to/m4a.py in to_pcm(self)
    456             stdout=subprocess.PIPE,
    457             stderr=subprocess.DEVNULL if hasattr(subprocess, "DEVNULL") else
--> 458             open(os.devnull, "wb"))
    459         return PCMFileReader(sub.stdout,
    460                              sample_rate=self.sample_rate(),

/path/to/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo,    creationflags, restore_signals, start_new_session, pass_fds, …
Run Code Online (Sandbox Code Playgroud)

python audio m4a

6
推荐指数
1
解决办法
1万
查看次数

opencv:在numpy数组上找到轮廓

我试图在一个二进制图像中找到轮廓,这是一个 numpy 数组

a = np.array(np.random.rand(1024,768),dtype='float32')    
_, t2 = cv2.threshold(a,127,255,0)
im2, contours, hierarchy = cv2.findContours(t2,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
Run Code Online (Sandbox Code Playgroud)

当我尝试运行该代码时,出现此错误

OpenCV Error: Unsupported format or combination of formats
([Start]FindContours supports only CV_8UC1 images when 
mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only)
in cvStartFindContours
Run Code Online (Sandbox Code Playgroud)

python opencv numpy opencv-contour

5
推荐指数
1
解决办法
2695
查看次数

使用Python构建caffe(找不到-lboost_python3)

我正在尝试使用python构建caffe,但它一直在说这个

CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
/usr/bin/ld: cannot find -lboost_python3
collect2: error: ld returned 1 exit status
make: *** [python/caffe/_caffe.so] Error 1
Run Code Online (Sandbox Code Playgroud)

这是我尝试找到的时候得到的 boost_python

$ sudo locate boost_python
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python-py33.a
/usr/lib/x86_64-linux-gnu/libboost_python-py33.so
/usr/lib/x86_64-linux-gnu/libboost_python-py33.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python-py34.a
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.55.0
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python.so
Run Code Online (Sandbox Code Playgroud)

我也添加了这条路径

## .bashrc
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu":$LD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)

知道为什么会那么讨厌吗?

python boost caffe

2
推荐指数
1
解决办法
3749
查看次数