Category: Article

Minimalist-Style Demo of Running Neural Networks in Web Browser

This demo shows how to run a pre-trained neural networks in web-browser. The user would first download the pre-trained style transfer model to local by opening up the webpage. Then everything will get processed locally without accessing any remote resource. The user can then open-up a picture from their hard drive and click "run" to

How to contact USCIS and what to expect

For any foreigner in the US, when it comes to immigration related issues, there are always a lot of stories to tell. My recent story is about renewing my EAD (work authorization in the US) card. After I sent out my renewal application, I have tried multiple methods to contact USCIS and would like share

Build a Robot From A Power Wheelchair (1/2)

I have been working on a robotic project for a while. In this project, we build a robotic wheelchair controlled by head motions. It starts from a commercial powered wheelchair (Titan Front Wheel Drive Power Chair). We took over the control signals, added a number of sensors and wrote some computer vision softwares. It is

[OpenCV] detectMultiScale: output detection score

OpenCV provides quite decent implementation of the Viola-Jones Face detector. A quick example looks like this (OpenCV 2.4.5 tested): // File: main.cc #include using namespace cv; int main(int argc, char **argv) { CascadeClassifier cascade; const float scale_factor(1.2f); const int min_neighbors(3); if (cascade.load("./lbpcascade_frontalface.xml")) { for (int i = 1; i < argc; i++) { Mat img

Linux Swap文件

想象一下,两个实验进程跑了两天,还有一天就跑完了,这个时候你发现如果再跑一会儿内存就要爆了…怎么办? (好惊险的感觉 XD) 好吧,其实用到的只是很基本的操作系统知识,不过还真难得用到一回。 程序面对的都是虚拟内存。64位的操作系统下,虚拟内存非常大,但是实际物理内存相对而言小得多。所以,操作系统对内存分页 (就是分成一块一块的,每一块儿叫做一页) 物理内存一旦满了,把暂时不需要的页写到硬盘里。过了一会儿程序又要访问被写到硬盘里的那部分内容,操作系统就在物理内存中选一个页 (怎么选很讲究的),把硬盘里的那个给换回来。程序不停的运行,操作系统就换来换去… 所以,上面我们遇到的情形就可以解决了。把其中一个进程挂起 (suspend),Linux下可以用 Ctrl+Z ,然后这部分内存就是暂时不用的了。这个时候用 $top 查看内存使用情况,可以看到一个CPU占用率为0的进程占用的内存越来越少,另一个越来越多。这样就行了,等一个进程跑完,再用 $fg 命令把挂起的进程调到前台就可以了。 但是等等。虚拟内存具体是在哪里呢?数据终究是写在内存/硬盘上的,Linux下被换到硬盘上的内存在Swap分区 (交换分区) 里。安装系统的时候需要格式化一个分区为Swap格式,就是这个分区。 用 $swapon -s 可以查看交换分区的大小。 糟糕!刚才那个被挂起的进程占用了24G的内存,但是现在看到我的交换分区只用12G,怎么办?一旦交换分区和内存都满了,会发生神马事情,我也没有体验过,估计应该是系统卡死或者卡而不死吧。 所以,应该赶紧增加交换分区的大小才是。可是如果你和我一样,很悲催的没有Root权限 (Root权限貌似是必须的…),而且也根本没有多余的分区可以挂载了,怎么办? 可以用Swap文件 (点题) ! 就是把一个文件用做swap分区,Linux下什么都是文件,分区应该也是吧。要增加系统可用的虚拟内存,当然这要求你硬盘剩余空间够大… $dd if=/dev/zero of=~/swapfile bs=1024 count=41943040 会在HOME下创建一个40G的文件”~/swapfile”,命令要执行一会儿,需要写一段时间硬盘,执行完了会显示写硬盘的速度,可以用来做测速的。 然后告诉系统用这个文件做交换文件 mkswap ~/swapfile 就没问题了。 (实际上不行,还需要这个命令, –!) sudo swapon ~/swapfile 其实最一开始那个情形下,如果两个进程继续跑下去,操作系统仍然会把一部分内容换出来的。只是大量换页操作会让程序执行的时间更长,而且如果交换空间不够大,系统最终仍然可能会被卡死。 感叹一下,一个实验要跑三天的同学伤不起啊..

Draw ROC Curve

A piece of fairly simple Matlab script to draw the ROC Curve from an array of scores and an array of labels. function [Tps, Fps] = ROC(scores, labels) %% Sort Labels and Scores by Scores sl = [scores; labels]; [d1 d2] = sort(sl(1,:)); sorted_sl = sl(:,d2); s_scores = sorted_sl(1,:); s_labels = round(sorted_sl(2,:)); %% Constants counts