Skip to content

Instantly share code, notes, and snippets.

@margaretmz
margaretmz / Android Studio lauch Project View by default
Last active March 19, 2017 22:40
How to stop Android Studio from opening projects in "Android View" by default?
// Go to Android Studio -> Help -> Edit Custom Properties
// Click "Yes" at the prompt ".../idea.properties does not exist, Create?"
// In the idea.properties file, enter
studio.projectview=true
// Save and restart Android Studio and all projects will be opened in Project View by default
// Find SHA1 of Debug keystore, on Mac located at ~/.android/debug.keystore
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v -storepass android
@margaretmz
margaretmz / conda commands
Last active April 24, 2019 21:04
Commands for conda on Mac.
Anaconda consists a list of packages including Conda.
Conda is a commanda line package and environment manager.
Note the Conda commands below are for Mac:
# Help
[command ] -- help
# Verify conda is installed
conda info
@margaretmz
margaretmz / set up adb on Mac
Last active November 17, 2020 19:19
How to set up adb environment variable on Mac
// Step 1. Open or create the .bash_file
// Open .bash_file
$ -a TextEdit ~/.bash_profile
// create the file if it doesn’t exist:
$ touch ~/.bash_profile
// Step 2. Add path to adb tool (note your path maybe different)
export PATH=$PATH:/Users/Margaret/Library/Android/sdk/platform-tools/
// Step 3. Make the new path in effect
@margaretmz
margaretmz / selfie2anime-kaggle-api.py
Last active July 13, 2020 04:25
selfie2anime-kaggle-api
os.environ['KAGGLE_USERNAME'] = "" # TODO: enter your Kaggle user name here
os.environ['KAGGLE_KEY'] = "" # TODO: enter your Kaggle key here
@margaretmz
margaretmz / selfie2anime-download-model.py
Last active July 13, 2020 04:31
selfie2anime-download-model
$ kaggle datasets download -d t04glovern/ugatit-selfie2anime-pretrained
$ unzip -qq /content/ugatit-selfie2anime-pretrained.zip
@margaretmz
margaretmz / selfie2anime-instantiate-model.py
Last active July 13, 2020 04:31
selfie2anime-instantiate-model
with tf.Graph().as_default(), tf.Session() as sess:
gan = UGATIT(sess, data)
gan.build_model()
load_checkpoint(sess, ckpt_path)
@margaretmz
margaretmz / selfie2anime-load-checkpoint.py
Last active July 13, 2020 04:31
selfie2anime-load-checkpoint
def load_checkpoint(sess, ckpt_path):
model_saver = tf.train.Saver(tf.global_variables())
checkpoint = os.path.expanduser(checkpoint)
if tf.gfile.IsDirectory(checkpoint):
checkpoint = tf.train.latest_checkpoint(checkpoint)
tf.logging.info('loading latest checkpoint file: {}'.format(checkpoint))
model_saver.restore(sess, checkpoint)
@margaretmz
margaretmz / selfie2anime-save-model.py
Last active July 13, 2020 04:31
selfie2anime-save-model
tf.saved_model.simple_save(
sess,
saved_model_dir,
inputs={gan.test_domain_A.name: gan.test_domain_A},
outputs={gan.test_fake_B.name: gan.test_fake_B}
)
@margaretmz
margaretmz / selfie2anime-load-savedmodel.py
Last active July 13, 2020 04:32
selfie2anime-load-savedmodel
model = tf.saved_model.load(saved_model_path)
concrete_func = model.signatures[ tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY]