Pages

Tuesday, August 11, 2020

Enabling SSH Access to WSL2 from DIfferent Computer

WSL2 is such a blessing to Windows. As much as I really love Linux, in some laptops, Linux simply aren't supported well. It's no Linux fault, though... Many hardware vendors simply don't provide Linux drivers for their hardware, making the experience on Linux being sub-par when compared to its Windows counterpart. As an example, I own an ROG ASUS Laptop, GL503 that I use for entertainment purposes. Linux didn't work properly out of the box on this laptop whose 120hz screen requires it to run on NVIDIA GPU all the time. Luckily, WSL2 comes to the rescue! From being an entertainment-only machine, I can finally use this laptop to do some development work! What a convenient!

Okay, that's enough chit-chatting.. This time, for a development purposes, I need to SSH from a different machine, into the WSL2 instance running on my Windows machine. This turns out to be a bit tricky. So here's how you do it:

1. Instal openssh server on WSL2: `sudo apt install openssh-server`

2. Modify openssh server configuration

```

# 1. Update port from 22 to something else, i.e. 8828. The reason is because port 22 already reserved by Windows
# 2. Uncomment and change ListenAddress to 0.0.0.0
# 3. Uncomment and change PasswordAuthentication to yes
sudo vim /etc/ssh/sshd_config

# Generate host keys
sudo ssh-keygen -A

# Restart openssh server
sudo service ssh restart

# Note WSL2 ipaddress
ifconfig

```

  • Now, try to SSH into the WSL from Windows (of the same computer), using the WSL2 ip address from before. You can do that using Putty or terminal. If it fails, use -vvv flag to see why it fails. Make sure this works before proceeding to the next step
  • Now, forward connection from Windows' ip address into WSL ip address by running command like this: `netsh interface portproxy add v4tov4 listenport=8828 listenaddress=0.0.0.0 connectport=8828 connectaddress=172.27.136.236` 
  • Then try to SSH into the WSL machine again, but this time use Windows ip address. Only proceed if this was successful
  • Now, you would think it's over right? Not quite... Last step is to change Windows firewall setting to allow SSH to port 8828 from outside [1]
    • Navigate to Control Panel, System and Security and Windows Firewall.
    • Select Advanced settings and highlight Inbound Rules in the left pane.
    • Right click Inbound Rules and select New Rule.
    • Add the port you need to open and click Next.
    • Add the protocol (TCP or UDP) and the port number into the next window and click Next.
    • Select Allow the connection in the next window and hit Next.
    • Select the network type as you see fit and click Next.
    • Name the rule something meaningful and click Finish
  • That's it!


Hope this is helpful and could save you some time!


Reference:
1. Changing firewall setting on Windows

Monday, April 20, 2020

Perceptual Loss / VGG Loss Function - Is this the Magic Behind Magic Pony Technology Hundred-Millions Acqusition?

MagicPony is a deep-learning startup that got acquired by Twitter back in 2016. There wasn't much written about what they did in order to be valued at $150 millions, except that they have something to do with better video compression technology. From poking around online and looking at the Zehan Wang's -- MagicPony's CTO -- background, it seems Deep Learning-based Super Resolution is at the heart of their technology. This seems to be further confirmed by the paper published after the acquisition happened: Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network.

 Deep learning-based Super Resolution is not a novel technique. There have been several papers published on them that I read back in 2013. But there were several challenges, such as the slowness of algorithm FPS and that the result isn't much better than a conventional bicubic interpolation. What MagicPony seemed to have been able to achieve is a way to do it faster and much better.

The paper published by MagicPony describes a GAN-based technique to do Super Resolution. One of the most interesting aspects of the paper is on how they use Perceptual Loss / VGG Loss in order to compute the lost function between original high-res image vs. the deep learning-upscaled image. On the paper they mention it as one of the key factors to get significantly better result. So what it's? It's one of the convolution layers taken from VGG-16 model pre-trained on ImageNet dataset. There was another paper that dissects, and tries to understand the different layers on VGG-16 model by trying to visualize each of the layers. They found out that a particular layer can be leveraged for a better way to perceptually compare two images (i.e. versus using naive pixel-based MSE loss function)

I can help to wonder about the following:
1. Would a more traditional CNN-based Super Resolution technique (i.e SRCNN) yields as good as a result by simply swapping its loss function with VGG loss function?