Skip to content

Instantly share code, notes, and snippets.

View chaonan99's full-sized avatar
🎯
Focusing

Haonan Chen chaonan99

🎯
Focusing
View GitHub Profile
@chaonan99
chaonan99 / .zshrc
Created December 15, 2021 06:53
My setup
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/root/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@chaonan99
chaonan99 / pytorch_problem.py
Last active March 30, 2020 17:22
A pytorch multiprocessing problem
import os
import torch
class Dataset(torch.utils.data.Dataset):
arg = {'batch_size': 1}
def __init__(self, arg):
print('__init__')
self.arg.update(arg)
@chaonan99
chaonan99 / exp_tf_record.py
Created May 23, 2019 01:33
Experiment with tf record file provided by onsets and frames.
import os
import tensorflow as tf
from magenta.models.onsets_frames_transcription import configs
from magenta.models.onsets_frames_transcription import constants
from magenta.models.onsets_frames_transcription import data
from magenta.models.onsets_frames_transcription import split_audio_and_label_data
from magenta.models.onsets_frames_transcription import train_util
from magenta.music import midi_io

vaff annotation

The annotation of vaff follows Umich Affordance Matrix and annotate 1~5 score indicating the confidence of an concept being the keyrole of a predicate.

To annotate, give each predicate-concept pair a 1~5 score, where 5 being most confident to say the action can happen on the object. For example, for the first pair (add, air), ask yourself "Can you add air (to something)?". (Notice that this is aiming for a cooking scenario, and eventually we want to let the robot to conduct the action on the object. But don't restrict your imagination on this. Use your common sense in first place!)

Here are some suggestions for success in this task:

  • Use Google Sheet or MS Excel for the annotation task.
  • Predicate-wise annotation, e.g., fist annotate all (add, *) pairs, then move on to arrange action
  • After annotating each predicate, swap the object column with annotated column.
@chaonan99
chaonan99 / baxter_screen_publisher.py
Created April 15, 2018 00:28
publish screenshot to Baxter head display
"""Baxter screenshot publisher
Author: chaonan99
Date: 2018/04/14
"""
from Xlib import display, X
from PIL import Image as PILI ## Because of name confliction
import numpy as np
import cv2
import argparse
@chaonan99
chaonan99 / addup_number_publisher.py
Created March 22, 2018 00:16
A ROS publisher publishing increasing int number
#!/usr/bin/python2
import rospy
from std_msgs.msg import String
pub = rospy.Publisher('addup_number', String, queue_size=10)
rospy.init_node('repub_test_pub', anonymous=True)
r = rospy.Rate(1)
i = 0
while not rospy.is_shutdown():
@chaonan99
chaonan99 / ros_message_republish.py
Created March 21, 2018 23:11
A snippet used to republish ROS topic in a different rate
#!/usr/bin/python2
import rospy
import rostopic
import argparse
import threading
global g_msg
g_msg = None
def argument_parse():
@chaonan99
chaonan99 / tmux.md
Created February 17, 2017 02:19 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@chaonan99
chaonan99 / string_structurize.py
Created October 21, 2016 06:33
Organize a list of string in a structured way (dictionary, list structure)
"""
Organize a list of string in a structured way (very slow)
:Author: chaonan99
:Date: 2016/10/21
"""
import re
import numpy as np
class StructureDir(object):
""" StructureDir
@chaonan99
chaonan99 / Default.sublime-keymap
Last active September 24, 2016 01:50
My Sublime key map defination
[
// Delete a line
{ "keys": ["ctrl+alt+shift+d"], "command":"run_macro_file", "args": {"file":"Packages/Default/Delete Line.sublime-macro"} },
// ctrl+gb find all
{ "keys": ["ctrl+g", "ctrl+b"],"command": "find_all_under" },
{ "keys": ["alt+up"], "command":"swap_line_up" },
{ "keys": ["alt+down"], "command":"swap_line_down" },
{ "keys": ["alt+/","alt+/"], "command":"insert_best_completion" },
// For markdown preview package. Preview .md in browser.
{ "keys": ["alt+m"], "command": "markdown_preview", "args":{"target": "browser", "parser": "markdown"}},