FPN for Object Detection

My notes of reading this paper.

FPN stands for Feature Pyramid Network, used for improving Object Detection.

One traditional way to do Object Detection is to use sliding window with multiple window sizes which is in (a). However this method is slow and computational intensive. (b) and (c) are mentioned for approaches that used by others to overcome the disadvantage of (a).

The author also mentioned that a deep ConvNet can generate multiple scale features by sampling. However these feature maps for different spatial resolutions have large gaps which can harm the result.

(d) is the method this paper is promoting.

Resolution and semantic of feature :

Bottom-up, up-down path way and lateral connections

Bottom-up pathway is a regular ConvNet backbone with scale step=2(ResNet here), Up-down pathway is scaling up with step size=2 (with nearest neighbor upsampling).

When adding the Bottom-up layer to the Up-down layer, the Bottom-up layer on the left has x2 times more channels, so it uses Conv 1×1 to reduce channel number to add the layer on the right by element wise. The up-down layer on the right has to upsample (x2) to match the hight and width of the left. The upsample can cause aliasing effect. Conv 3×3 is used to reduce this aliasing effect.

Code can find found here. Also thanks to this video for better understanding.

Nested X Server

Use Xephyr to run a second X window with 8bit color depth in Raspberry Pi
https://nims11.wordpress.com/2012/06/24/nested-x-servers-with-xephyr/

Xephyr -ac -screen 800x600x8 -reset :1 &

This will open a blank window
In the original window, type
DISPLAY=:1

Then run the C program. It show “Colomap_size: 256”.
It worked!

Softmax vs. Sigmoid function

We are familiar with Sigmoid function when learning Logestic regrestion, as well as in Neural Network as the non-linear active function.

Softmax function is another type of non-linear function

 

 

While Sigmoid is as the following in math,

 

 

How to separate them in usage? Here is a good explanation.

Also some good example for Softmax in Wiki

If we take an input of [1, 2, 3, 4, 1, 2, 3], the softmax of that is [0.024, 0.064, 0.175, 0.475, 0.024, 0.064, 0.175]. The output has most of its weight where the ‘4’ was in the original input. This is what the function is normally used for: to highlight the largest values and suppress values which are significantly below the maximum value…

Flash Nexus 5 with Android 6.0.1 and root

Rooted my Nexus 5 android following this instruction.

1. Backup the phone (Rooting will erase all setting and personal files on the phone & SD card)

2. Enable USB debugging:
Go to phone’s Setting -> About Phone, then keep tapping on “Build Number” until it shows “You are now a developer”

3. Unlock the bootloader & Flash Nexus 5 with the factory image

  • connect the phone to Mac by USB cable
  • Boot into Fastboot mode by “Volume Up + Volume Down + Power”
  • download the image.
    Factory images can be found here.
    Extract the downloaded file hammerhead-mob30y-factory-7f05cd7f.tgz
  • According to the instructions, normally running ./flash-all.sh will be enough. However this version might have a problem which cause the reboot after this stucks (or maybe just takes really long to boot up). The following way, which is to manually running the scripts, seemed helpful.(Found the solution from here)
  • Open a terminal on my MAC and ran the following commands,

    fastboot oem unlock
    fastboot erase boot
    fastboot erase recovery
    fastboot erase system
    fastboot erase userdata
    fastboot erase cache

    fastboot flash bootloader bootloader-hammerhead-hhz20h.img
    fastboot reboot-bootloader

    fastboot flash radio radio-hammerhead-m8974a-2.0.50.2.29.img
    fastboot reboot-bootloader

    fastboot flash boot boot.img
    fastboot flash recovery recovery.img
    fastboot flash system system.img
    fastboot flash userdata userdata.img
    fastboot flash cache cache.img
    fastboot reboot-bootloader

    4. Get Android-studio from here
    twrp from here. This is a better recovery tool.
    SuperSu from here

    5. Install custom recovery
    Go to directory which contains the Andriod-studio files (on Mac)
    #which fastboot
    /Users/myuser/android-sdk/android-sdk-macosx/platform-tools/fastboot
    #cd /Users/myuser/android-sdk/android-sdk-macosx/platform-tools/fastboot
    #fastboot flash recovery twrp-3.0.2-0-hammerhead.img
    #fastboot reboot-bootloader
    Power-off the phone and enter the Fastboot mode again, switch to Recovery mode and proceed, then the custom recovery will be shown.

    6. Root the phone
    On Mac terminal:
    #adb push UPDATE-SuperSU-v2.76-20160630161323.zip /sdcard/
    Boot the phone into Fastboot mode then switch to recovery mode as before.
    Click on install, then choose SuperSu zip file and click “Install image”.
    Reboot.

    7. The phone couldn’t get connection from carrier(Sprint) after the changes above, ran the following code on the dial pad, then the problem got fixed.

    *#*#72786#*#*

  • Setup AWS API tool

    Setup AWS API tool

    Download API tool
    wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
    unzip ec2-api-tools.zip -d /usr/local/ec2

    Where is Java?
    which java
    file /usr/bin/java
    file /etc/alternatives/java
    /usr/lib/jvm/jre-1.x.0-openjdk.x86_64/
    User this path for the config

    Setup env
    vi ~/.bash_profile

    export JAVA_HOME=”/usr/lib/jvm/jre-1.x.0-openjdk.x86_64/”
    export EC2_HOME=”/usr/local/ec2/ec2-api-tools-1.7.3.0″
    export AWS_ELB_HOME=”/usr/local/ec2/ElasticLoadBalancing-1.0.35.0/”
    export PATH=$PATH:$EC2_HOME/bin:$AWS_ELB_HOME/bin
    export aws_access_key_id=”AAAAAAAAAAAAA”
    export aws_secret_access_key=”KKKKKKKKKKKKKKKKKKKKKK”
    export EC2_URL=”https://ec2.us-west-1.amazonaws.com:443″

    Bash scripts

    Change upper case to lower case

    #echo ‘TEST’|/usr/bin/tr -s ‘[:upper:]’ ‘[:lower:]’
    test

    Work with array

    IFS=$’\n’ ##here tells how to devide the output, default is space
    ##but I want to put each line into a array
    files=($(ls ./) ##put file names into an array using ()
    for (( i=0;i<${#files[@]};i++ ));do mv $files[$i] $files[$i]_OLD done

    Match pattern

    if [[ $string =~ “data” ]];do
    echo “$string contains data”
    done

    Enable status in PHP-fpm + Nginx

    It was a little bit confusing to set it up. So here’s the memo.

    vi /etc/php5/fpm/pool.d/www.conf

    pm.status_path = /status
    listen = 127.0.0.1:9000

    vi /etc/nginx/sites-available/monitor
    location ~ ^/(status|ping)$ {
    include fastcgi_params;
    #access_log off;
    allow 127.0.0.1;
    allow xx.xx.xx.xx;
    deny all;
    fastcgi_param SCRIPT_FILENAME /status;
    fastcgi_pass 127.0.0.1:9000;
    }

    Restart nginx and php-fpm processes.

    Ref: Here

    The wind rises — Movie

    As a big fan of Miyazaki Hayao animation movies, of cause I am not going to miss this newest one and seems to be the last production before his retirement.

    Not every movie theater was showing it, so we had to drive to El Segundo and watched it in the Arclight theater.

    The story is based on a real person’s biography, who designed the fighter air plane for Japanese army during WWII, mainly used for fighting with China and US. So it’s very different from other animation movies he made, which were telling fantasy stories.

    The WWII background and the tragedy ending of the love story brought the movie a quite very sad and heavy feeling. The air plane technology and the engineer were brilliant but it was used for a war that killed millions of people.

    I am not sure if the engineer himself really had this confliction in his mind or not but the producer seems want to show this feeling in his movie.

    Resize root partition of a virtual machine on VMware

    When it comes to a situation that the disk space is not enough on a virtual machine, it’s easy to extend the disk space if it’s on LVM, even the /root partition.

    This post is very helpful.

    For my own memo:
    Case:
    VM on VMware, installed with CentOS 6.x
    #fdisk -l shows
    Disk /dev/sda: 12GB ….
    /dev/sda1 2 501 512000 83 Linux
    /dev/sda2 502 12288 12069888 8e Linux LVM

    On /dev/sda2
    Disk /dev/mapper/vg_node1-lv_root: 7.5 GB
    Disk /dev/mapper/vg_node1-lv_swap: 4 GB

    Goal: Add 8G extra space to /dev/mapper/vg_node1-lv_root

    Steps:
    1. Using VMware GUI to add 8G to the virtual machine. Make sure it recognizes the new size.

    2. Memo the current cylinder start number of /dev/sda2
    /dev/sda2 502 12288 12069888 8e Linux LVM

    3. Delete partition /dev/sda2 then recreate it with the new size
    fdisk /dev/sda
    Use command “d”, then “2” to delete /dev/sda2
    Use “n” to create a new partition, partition number is “2”
    Use “t” to change partition type to 8e as “Linux LVM”
    Then “w” to save the change

    Reboot the VM

    Now the partition size is changed. I need to change the pv size and vg size.

    5. Change pv size
    pvsize /dev/sda2

    6. Change vg size
    #vgdisplay (found the free PE = 2048 )
    #lvextend /dev/mapper/vg_node1-lv_root –extents +2048

    7. Still need to increase file system size
    #resize2fs /dev/mapper/vg_node1-lv_root

    ————————————————————————-
    Another way to do it

    1. Add disk space from vmware GUI, however the following command didn’t work, so reboot
    echo “- – -” > /sys/class/scsi_host/host0/scan

    2. frisk -l shows new disk space on /dev/sda
    create a new partition on /dev/sda
    frisk /dev/sda -> n -> p -> 3 -> it will show the right start/end block number automatically, so just hit enter,
    -> t -> 8e -> w

    3. fdisk shows /dev/sda3, the new partition created.
    However it warns the kernel won’t use the new table until reboot, so reboot for the 2nd time

    4. Create a new physical volume on lvm using sda3
    pvcreate /dev/sda3

    5. find vg name from vgdisplay, find vg name is using “centos”, add sda3 to virtual group
    vgextend centos /dev/sda3

    6. pvscan shows sda3 as a member of vg “centos”
    [root@mononoke ~]# pvscan
    PV /dev/sda2 VG centos lvm2 [15.51 GiB / 0 free]
    PV /dev/sda3 VG centos lvm2 [9.00 GiB / 0 free]
    Total: 2 [24.50 GiB] / in use: 2 [24.50 GiB] / in no VG: 0 [0 ]

    7. lvdisplay shows 2 logical volumes, /dev/centos/root and /dev/centos/swap,
    lvextend /dev/centos/root /dev/sda3

    8. resize file system, since it’s using XFS on centos7,
    xfs_growfs /dev/centos/root

    Here‘s the reference

    ——————————————————-
    To check how much free space left in a physical volume, do pvdisplay, then find value of “Free PE”

    — Physical volume —
    PV Name /dev/sdb2
    VG Name test_vg
    PV Size 20.00 GiB / not usable 1.31 MiB
    Allocatable yes
    PE Size 4.00 MiB
    Total PE 5120
    Free PE 2620
    Allocated PE 2500

    Catching the tail of summer in Mammoth -3

    [singlepic id=355 w=640 h=480 float=left]
    A River flowing slowly between the golden meadow with low clouds sitting on the mountains in the background.Some black cows were eating or resting on the meadow.
    I found this is one of the most beautiful place in mammoth, the Owens river.

     
     
     
    [singlepic id=374 w=640 h=480 float=left]

    Look at how huge the cloud is! It’s hard to see this kind of cloud in LA. It might be able to hide a sky castle in it like the one in Miyazaki’s animation movie?