Comparison of using transfer learning on the Caltech 256 dataset and on an unclean dataset scraped from the web.This is for COGS 118B final project.
Install keras, tensorflow, h5py for model inferencing Install flask for web server component
pip install keras tensorflow h5py flask youtube_dl
Installing OpenCV
wget https://raw.githubusercontent.com/milq/milq/master/scripts/bash/install-opencv.sh
sudo bash install-opencv.sh
Symbolicallyy link the OpenCV library to python libraries (Unsure why this works, but needed to do this before creating a virtualenv and using OpenCV. OpenCV will work outside a virtualenv without this.)
sudo ln -s /usr/local/lib/python2.7/dist-packages/cv2.so /usr/lib/python2.7/
video_classifier.py
Takes in a video stream, classifies each frame, and creates a new video with classification captions.
Running using built-in webcam without showing the video while processing. If you want to see video while it's classifying you can set the last argument to True.
python video_classifier.py 0 model.h5 out.mp4 False
python video_classifier.py 1 model.h5 out.mp4 False
python video_classifier.py video.mp4 model.h5 out.mp4 False
Provides form to enter a URL to a video and returns that video with classification captions.
python server.py
Head to http://localhost:5000/ and enter a video URL such as this one, https://www.youtube.com/watch?v=lTTajzrSkCw . After submitting, it will take some time to process. Eventually, you will see the video specified with classification labels.
https://itsfoss.com/install-pycharm-ubuntu/
Add the PPA
sudo add-apt-repository ppa:mystic-mirage/pycharm
sudo apt-get update
Install Pycharm Community Edition
sudo apt-get install pycharm-community
Add the PPA
sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update
Install Atom
sudo apt-get install atom
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
sudo swapoff /var/swap.1
sudo rm /var/swap.1
Build the predict function before you start multithreading. (Unsure why building it inside the thread breaks it.) Fix found here.
model._make_predict_function() # Have to initialize before threading
Runtime 27 secs for 11 sec video on Laptop at 2.45 runtime secs/video secs
Runtime 85 secs for 18 sec video on Laptop at 4.72 runtime secs/video secs
Caltech 256 Dataset
Google Image Webscraper
Converting AVI to MP4 in Python
subprocess.call
Keras and Flask Bug Solution
Cannot run flask as threaded=True
or else it will break the Keras predict method. Unsure why(Solution found below.)
Keras Threaded Predict Bug Solved
Pycharm Installation
OpenCV Install
Swapspace for Keras Installation
10 Ways to Host Web Applications
Installing Atom
POSSIBLE OpenCV on Lambda
POSSIBLE Keras on Lambda