2017年12月31日星期日

DeepXplore Env Setup on macOS Sierra 10.12

A brief guide to run the code of DeepXplore:

1. Install Python

2. install virtualenv

3. In virtual env:
  • Install TensorFlow
  • install keras
  • activate keras for virtualenv to generate the keras.json file
  • set keras backend to be tensorflow
  • install Pillow
  • install h5py
  • install opencv-python
  • install Mimicus
4. download or clone the DeepXplore project from GitHub, and the Drebin data

5. Run below commands under each dataset directory:
  • MINIST: python gen_diff.py blackout 1 0.1 10 20 50 0
  • ImageNet: python gen_diff.py occl 1 0.1 10 20 50 0
  • Driving: python gen_diff.py light 1 0.1 10 20 50 0
  • PDF: python gen_diff.py 2 0.1 10 20 50 0
  • Drebin: python gen_diff.py 1 0.5 20 50 0
6. remember to check github's issues section for project updates.



some Fedora commands:
# yum install python-virtualenv
# virtualenv --python /usr/bin/python2.7 env (this will create a dir called env under your virtualenv environment, fedora default is ~)
# . env/bin/activate (activate the created env)
## to activate keras and get the keras.json file
$ python (this will activate keras)
>>> import keras
>>> quit()
## sme packages might be missing when install mimicus
# yum install freetype-devel
# python -m pip install pkgconfig






2017年12月30日星期六

Run J2EE with AWS EC2 & RDS

Process of setting up a web app running with Wildfly and PostgreSQL using AWS EC2 & RDS.

1. create an AWS account, and login (all AWS service uses below  are applicable to free-tier users)
  • select your country & region to make sure the billing is correct

2. setup an EC2 instance
  • Instance Type: t2.micro
  • OS: Centos 7
  • Subnet: choose anyone in the dropdown list, but remember to pick the same one when setting up the subsequent RDS instance
  • Storage/Disk: select Magnetic or SSD, check the option of "Delete on Termination" to avoid extra charges
  • Security Group: allow minimum rules for access, port numbers needed: 22, 8080, 5432
  • Key Pair: download and change permission to 400
  • Connection: using ssh with key auth

3. setup the RDS instance
  • Instance Type: PostgreSQL (enable free-tier use only)
  • Storage: 20GB by default
  • DB instance identifier
  • Master user name (username of a postgres db user)
  • Availability: public
  • Zone/Subnet: same as EC2 instance's
  • Security Group: allow access of IPs that needs connection to this DB, eg. current IP, EC2's IP/Subnets(eg. 172.31.0.0/16), port 5432
  • Database Name
  • finish the setup
  • edit the instance properties -> Parameter Group -> New -> put a group name -> changing the property of "max_prepared_transactions" to the value of 300
  • connect to the RDS instance using ssh to test the db, command: psql --host=[your RDS instance's DNS] --dbname=[your database's name] --user=[your database's user]
  • you may need to reboot the RDS instance to apply any immediate changes

4. Configure the EC2 instance, install software
  • connect to EC2 using ssh & key pair using the centos user
  • switch to root user
  • change the instance timezone to reflect your region
  • install Java 8, setup $JAVA_HOME
  • install Apache Maven, setup mvn variables
  • install Wildfly 11
  • install git and folk the destined repository

5. Configure the git repository, and run it with Wildfly as a J2EE Project
  • change the start_webapp.sh to let Wildfly's variables inside reflect your instance's configurations, mainly $JBOSS_HOME
  • change Wildfly's standablone.xml for a datasource setting reflecting your RDS instance's, this includes the RDS's instance DNS, DB name, DB connection user name and password
  • change  the start_webapp.sh add -b 0.0.0.0 to allow public access to Wildfly server
  • start Wildfly server using start_webapp.sh, and visit your project's home page through browser on port 8080

6. Stop the EC2 instance & RDS instance,
  • you may also delete these in case further charges apply, remember to check your billing dash board for fees & credits incurred.