Skip to content

Instantly share code, notes, and snippets.

@foolishflyfox
foolishflyfox / disp_multiple_images.py
Last active December 20, 2018 11:33 — forked from soply/disp_multiple_images.py
Plot multiple images with matplotlib in a single figure. Titles can be given optionally as second argument.
import matplotlib.pyplot as plt
import numpy as np
import PIL
def show_images(images, rows = 1, titles = None):
"""Display a list of images in a single figure with matplotlib.
Parameters
---------
images: List of np.arrays compatible with plt.imshow.
@foolishflyfox
foolishflyfox / CodeSnippet.md
Last active April 4, 2019 08:37
Gist Classify
@foolishflyfox
foolishflyfox / argparse_demo.py
Last active December 27, 2018 14:05
Demo of argparse usage
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(
description='Some description about this script',
formatter_class=argparse.ArgumentDefaultsHelpFormatter, # show default value
)
# add required option. Note: required option can't with default parameter
parser.add_argument('info', type=str, help="required option")
@foolishflyfox
foolishflyfox / cv_framework_detailed.py
Last active December 24, 2018 07:40
Pytorch Computer Vision Framework (Detailed)
import torch
import torchvision
import torch.utils.data
from torch.backends import cudnn
from torchvision import transforms
# some hyperparameters setting
use_gpu = True
train_batch_size = 64
val_batch_size = 64
@foolishflyfox
foolishflyfox / git_notebook.md
Last active December 26, 2018 09:28
The usage of git, just as a notebook of progit BOOK

Ignoring Files

# ignore files whose suffix is .o or .a
*.[oa]

# you can negate a pattern by starting it with an exclation point(!)
!hello.o
@foolishflyfox
foolishflyfox / cv_framework_simplified.py
Last active December 24, 2018 07:41
Pytorch Computer Vision Framework (Simplified)
import torch
import torchvision
import torch.utils.data
from torchvision import transforms
from torch.backends import cudnn
# some hyperparameters setting
use_gpu = True
train_batch_size = 64
val_batch_size = 64
@foolishflyfox
foolishflyfox / jobs_control.md
Last active December 24, 2018 04:41
jobs control tools in linux

Commands:

  • ./tst.py &: run in background
  • nohup ./tst.py &: don't print output in stdout, and set the parent process as #0 process.nohup means No hangup signal.
  • setsid ./tst.py &: print output in stdout, set the parent process as #1 process.
  • disown %1: change the parent process of a background process
  • hot key ctrl+z: suspend foreground process
  • bg %1: trun foreground job #1 to background, equal to kill -CONT -pid_value
  • bg: trun all foreground job to background
  • fg %1: trun background job to foreground
@foolishflyfox
foolishflyfox / jupyter_animation.py
Last active December 1, 2022 08:08
Display sequence images or dynamic function as an animation in jupyter notebook
import matplotlib.pyplot as plt
from matplotlib import animation
from IPython.display import display, HTML
import numpy as np
def plot_sequence_images(image_array):
''' Display images sequence as an animation in jupyter notebook
Args:
image_array(numpy.ndarray): image_array.shape equal to (num_images, height, width, num_channels)
@foolishflyfox
foolishflyfox / nfs_config.md
Created December 25, 2018 07:24
Edit files of a directory in remote server with NFS

Server Operations

Install nfs server

$ sudo apt-get update
$ sudo apt-get install -y nfs-kernel-server

Config nfs

@foolishflyfox
foolishflyfox / ss.md
Last active February 6, 2019 15:04
ShadowSocks 服务的安装与加速
  1. 安装服务:
wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
chmod +x shadowsocks.sh
./shadowsocks.sh 2>&1 | tee shadowsocks.log
  1. 加速1