I am Charmie

メモとログ

2018-01-01から1年間の記事一覧

Install Octave on Mac OSX

[code lang='bash'] brew install octave [/code]

OpenCV Python calibration code

[code lang='python'] -- coding: utf-8 -- import os import numpy as np import glob import cv2 def generate_points_3d(rows, cols, square_size): """ prepare object points as ( 0, 0, 0), (1square_size, 0, 0), (2square_size, 0, 0), ... *1 img =…

Mac OS X: フォントのインストール

XeLaTeXのコンパイルにIPAフォントやIPA exフォントが必要だったので,まとめ.ウェブで色々見た情報のゴッタ煮.全ユーザに有効なフォントのインストール方法なので,管理者権限が必要.IPAフォントのインストール方法が正解なのかな? フォントファイルを…

Spyder reset

spyder --reset [code lang='bash'] Reset Spyder settings to defaults removing: C:\Users\oyamada.AR-DUNE-1.spyder-py3\spyder.ini removing: C:\Users\oyamada.AR-DUNE-1.spyder-py3\history_internal.py removing: C:\Users\oyamada.AR-DUNE-1.spyder-…

OpenCV-Python GUI outputs GTK related error

This stackoverflow post gives us the answer!! OpenCV for python installed on Linux (Ubuntu) by anaconda outputs GTK+2.x related error as OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GT…

IPA fonts installation on Ubuntu 16.04

To compile Japanese document with xelatex, I decided to use IPA fonts. Download IPA font files files (*.ttf files) from here. Create a directory to save the font files as sudo mkdir /usr/share/fonts/truetype/ttf-ipa-font Copy the font file…

PyTorch: visualize trained filters and feature maps

I just wrote a simple code to visualize trained filters and feature maps of pytorch. For simplicity, the below code uses pretrained AlexNet but the code must work with any network with Conv2d layers. [code lang="python"] !/usr/bin/env pyth…

Install OpenCV-Python 3.4.1 via Anaconda

See here. conda install -c anaconda opencv

OpenCV-Pythonチュートリアル

OpenCV-Pythonチュートリアルの和訳を2.5年ぶりに更新. 和訳は以前と同じURLからアクセス可能です. ソースはgithubからgitlabに移行しました. 誤訳,変な訳があればgitlabにイシュー登録してもらえるとハッピーです.

Mac OS X high sierra: install homebrew

run the following command from terminal $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

sed: replace and in-place edit

The following command delete all lines starting with WORD_TO_DELETE and overwrite the original file. sed -i -e '/WORD_TO_DELETE/d' FILE_NAME

Beamer: font of equations

Default beamer settings provide weird font equations. This problem is solved by adding the following command in preamble. \usefonttheme[onlymath]{serif}

Seminar on Computer Vision 2018

For newbie in the lab, I'll give a seminar series on computer vision. I selected lecture slides published by Professor Shapiro. Week 1 (2018/05/11) Introduction Image and filtering Week 2 (2018/05/18) Morphology operations Edge detection (…

Anaconda: install OpenCV 3.4.1 on Windows 10

conda install ... opencv, conda install ... opencv-python ruined my environment built on Windows 10. The error seemed to related to PyQt and authentication/path setting but couldn't specify the true cause. So, instead of using anaconda bin…

Anaconda: OpenCV for Python 3.6 on Windows 10

OpenCV installation on Windows via Anaconda with conda -c conda-forge opencv makes import error like ImportError: DLL load failed: access denied. The solution is to use pip instead as pip install opencv-python.

python: natural sort for a list of strings

See this. The process is super simple. stack a set of strings into a list. define a function converts a string object to its corresponding int object. define a function runs through a list to extract numbers from strings. sort a list with …

PyTorch: fine-tune a pre-trained model

See the tutorial. Important note: torchvision provides several pre-trained models with their trained parameters. AlexNet, DenseNet, Inception, ResNet, VGG are available, see here. With pretrained=True, pre-trained parameters are available.…

PyTorch: at evaluation/test phase

I got a runtime error at evaluation phase of my simple siamese network as RuntimeError: cuda runtime error (2) : out of memory at the line of executing forward pass. Some comments on stackoverflow suggests to define x and y with volatile=T…

Spyder: QOpenGL related error

See spyder's issue. For my case, installing PyOpenGL fixed the error as conda install pyopengl

PyTorch: AutoGrad

See this tutorial. Set requires_grad=True for all tensors we compute gradients w.r.t. them. [code lang='python'] input and output x = torch.randn(N, D_in, device=device, dtype=dtype) y = torch.randn(N, D_out, device=device, dtype=dtype) pa…

PyTorch: define a neural network

See the tutorial. It's quite simple (Keras provides simpler interface though). A neural network is defined as a class that has a forward function. The forward function defines how input data is processed through the network. PyTorch automa…

PyTorch: installation

Super easy installation GUI on the web as below

Keras: a callback function to save loss on each batch

Inspired by this stackoverflow answer and keras.callbacks.CSVLogger, I implemented a callback function to save loss on each batch. [code lang='python'] class LossHistory(Callback): def __init__(self, filename, separator=',', append=False):…

Leap Motion SDK installation on Ubuntu 16.04

If Leap Motion SDK installation failed with dpkg command, the site gives you the answer. Before running sudo dpkg --install Leap-*-x64.deb, we should first make a file /lib/systemd/system/leapd.service with the following contents. Otherwis…

ネイティブに笑われないクールイングリッシュ ―日本人の9割はダサい英語を話している

ネイティブに笑われないクールイングリッシュ ―日本人の9割はダサい英語を話している サマー・レイン インプレス イケてない英語表現について,何が問題でどのような表現にするべきか説明してくれているありがたい本.英語で誰かとコミュニケーションする機…

libcudnn related error after Ubuntu apt update

I got "ImportError of libcudnn.so.6" after Ubuntu apt update although I have no idea how apt update causes the error. The solution is re-install cuDNN. Library files of cuDNN disappeared from a directory where is one of LD_LIBRARY_PATH. So…