Giter VIP home page Giter VIP logo

imageyes's Introduction

ImageYes

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.

Software Dependencies

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/

Webscraper

Experiment Results

Video Classifier

video_classifier.py
Takes in a video stream, classifies each frame, and creates a new video with classification captions.

Built-In Webcam

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

External Webcam

python video_classifier.py 1 model.h5 out.mp4 False

Video File

python video_classifier.py video.mp4 model.h5 out.mp4 False

Video Downloader

Video Classifier by URL

Video Classifier Web Application

Provides form to enter a URL to a video and returns that video with classification captions.

Execution

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.

Other Useful Resources

Installing PyCharm Community Edition by PPA

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

Installing Atom

Add the PPA

sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update

Install Atom

sudo apt-get install atom

Adding swap space

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  

Removing swap space

sudo swapoff /var/swap.1
sudo rm /var/swap.1

Allowing Keras to Predict in Parallel/Multithreaded

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 Notes

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

Resources

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

imageyes's People

Contributors

kuronite avatar simonfong6 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.