This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create dataset of labels and predictions for the model from https://github.com/idealo/image-quality-assessment/ | |
# Use tensorflow >= 1.10.0 to load this model. I had weird errors. | |
from os import path | |
import numpy as np | |
import pandas as pd | |
import cv2 | |
from keras.preprocessing.image import load_img | |
from keras.preprocessing.image import img_to_array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Author: Victor Dibia | |
## Load hand tracking model, spin up web socket and web application. | |
from utils import detector_utils as detector_utils | |
from utils import object_id_utils as id_utils | |
import cv2 | |
import tensorflow as tf | |
import multiprocessing | |
from multiprocessing import Queue, Pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Author: Victor Dibia | |
## Load hand tracking model, spin up web socket and web application. | |
from utils import detector_utils as detector_utils | |
from utils import object_id_utils as id_utils | |
import cv2 | |
import tensorflow as tf | |
import multiprocessing | |
from multiprocessing import Queue, Pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My answer here: https://stackoverflow.com/questions/52793096/reload-and-zoom-image/52818151#52818151 | |
from PIL import ImageTk, Image | |
from scipy.ndimage import rotate | |
from scipy.misc import imresize | |
import numpy as np | |
import time | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create flask app to be run by tornado process | |
# process-specific globals | |
import global_vars | |
from flask import Flask, request, Response, json, abort, jsonify | |
# oridnary (non-flask) json if needed | |
import json as json2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple example of Q-learning inability to go in loops | |
# Though it is strictly forbibben by the code (line 101), | |
# but you can comment out that logic and see that algorithm just becomes less stable | |
# The reason is that loop is impossible in this setup, | |
# as only a single Q-value exists for each position on the map | |
import numpy as np | |
np.random.seed(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Which color is normally a cat?;Black | |
How tall was the longest man on earth?;272 cm | |
Is the earth round?;Yes | |
Which color is normally a cat?;Black | |
How tall was the longest man on earth?;272 cm | |
Is the earth round?;Yes | |
Which color is normally a cat?;Black | |
How tall was the longest man on earth?;272 cm | |
Is the earth round?;Yes | |
Which color is normally a cat?;Black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Layer-wise training neural network with second order (Newton). | |
# New layer is added on each iteration and optimized with Newton Method. | |
# And example of Tensorflow eager execution | |
# Combines gradiets, hessian, and call to Optimizer | |
# Might contain logical errors though, so think yourself when adapting this code | |
# Newton's method in Tensorflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Newton's method in Tensorflow | |
# WARNING! This code is memory and computationally intensive, better run it on GPU | |
# having bigger dimensionality increases computing time significantly | |
# Original dataset is passable on GTX 1050 GPU, but if you have time/memory problems, uncomment PCA compression | |
# Also, you can probably remove line 159 (hessian fixing) if you use PCA | |
# 'Vanilla' N.m. intended to work when loss function to be optimized is convex. | |
# One-layer linear network without activation is convex. | |
# If activation function is monotonic, the error surface associated with a single-layer model is convex. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Newton's method in Tensorflow | |
# 'Vanilla' N.m. intended to work when loss function to be optimized is convex. | |
# One-layer linear network without activation is convex. | |
# If activation function is monotonic, the error surface associated with a single-layer model is convex. | |
# In other cases, Hessian will have negative eigenvalues in saddle points and other non-convex places of the surface | |
# To fix that, you can try different methods. One of those approaches is to do eigendecomposition of H and invert negative eigenvalues, | |
# making H "pushing out" in those directions, as described in this paper: Identifying and attacking the saddle point problem in high-dimensional non-convex optimization (https://papers.nips.cc/paper/5486-identifying-and-attacking-the-saddle-point-problem-in-high-dimensional-non-convex-optimization.pdf) |
NewerOlder