Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
skyprince999 authored Jun 10, 2019
1 parent b8533ed commit 4cec7d6
Show file tree
Hide file tree
Showing 14 changed files with 9,484 additions and 0 deletions.
3,170 changes: 3,170 additions & 0 deletions H2o Implementation v0.ipynb

Large diffs are not rendered by default.

1,220 changes: 1,220 additions & 0 deletions Image Morphological Snake v1.ipynb

Large diffs are not rendered by default.

432 changes: 432 additions & 0 deletions Image Morphological Snake v3.ipynb

Large diffs are not rendered by default.

444 changes: 444 additions & 0 deletions OpenCV - even more CS transforms & histograms v4.ipynb

Large diffs are not rendered by default.

396 changes: 396 additions & 0 deletions OpenCV - more colorspace transformations v3.ipynb

Large diffs are not rendered by default.

756 changes: 756 additions & 0 deletions OpenCV - using Watershed Transformations v1.ipynb

Large diffs are not rendered by default.

344 changes: 344 additions & 0 deletions OpenCV - using colorspace transformations v2.ipynb

Large diffs are not rendered by default.

431 changes: 431 additions & 0 deletions SigTuple Hack - LinearSVC built on pre-processing pipeline v1.1.ipynb

Large diffs are not rendered by default.

697 changes: 697 additions & 0 deletions SigTuple Hack - pipeline for preprocessing v1.ipynb

Large diffs are not rendered by default.

320 changes: 320 additions & 0 deletions Sklearn - prediction pipeline v2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"##################################################################################\n",
"## This uses the model created in sklearn v1, to predict the mask for the \n",
"## given image\n",
"##################################################################################\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import os \n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"np.random.seed(1337) # for reproducibility\n",
"\n",
"from sklearn import svm, metrics \n",
"from sklearn.externals import joblib\n",
"\n",
"import scipy.misc\n",
"from scipy.misc import imread\n",
"import matplotlib.pyplot as plt\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"## Load the model\n",
"#lin_clf = joblib.load('linearSVC_v1.pkl')\n",
"lin_clf = joblib.load('grid_linearSVC_v0.pkl')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['017532875DDF.jpg',\n",
" '029E137BB177.jpg',\n",
" '029E137BB179.jpg',\n",
" '072CBBB64F88.jpg',\n",
" '072CBBB64F89.jpg',\n",
" '0BC2C60F3BA0.jpg',\n",
" '1468054105.jpg',\n",
" '1468054163.jpg',\n",
" '1468054267.jpg',\n",
" '1468054306.jpg',\n",
" '1468061314.jpg',\n",
" '1468061317.jpg',\n",
" '1468061347.jpg',\n",
" '1468061368.jpg',\n",
" '1468061411.jpg',\n",
" '16B1C9836EB0.jpg',\n",
" '264882623008.jpg',\n",
" '2D6D41F5B4A1.jpg',\n",
" '308A1C309EF5.jpg',\n",
" '31A25DC60455.jpg',\n",
" '31A25DC60456.jpg',\n",
" '34DBA85D4F7A.jpg',\n",
" '34DBA85D4F7E.jpg',\n",
" '469CE8C373A0.jpg',\n",
" '469CE8C373AC.jpg',\n",
" '5274941329CC.jpg',\n",
" '5274941329CF.jpg',\n",
" '52B380E6A3F1.jpg',\n",
" '52B380E6A3F2.jpg',\n",
" '549C148B2D40.jpg',\n",
" '549C148B2D4E.jpg',\n",
" '558DF2AD8A5F.jpg',\n",
" '5ABD740F7441.jpg',\n",
" '5ABD740F744D.jpg',\n",
" '5C75353DF081.jpg',\n",
" '5C75353DF082.jpg',\n",
" '682E28C9537E.jpg',\n",
" '7D00B08A7B2D.jpg',\n",
" '85639DF5DF72.jpg',\n",
" '85639DF5DF7C.jpg',\n",
" '8A87C3794B59.jpg',\n",
" 'BB6EB0F294D8.jpg',\n",
" 'BB6EB0F294DA.jpg',\n",
" 'C11E6107F913.jpg',\n",
" 'C3AC084EA711.jpg',\n",
" 'C4D8C497AB5C.jpg',\n",
" 'CD406B9D61C4.jpg',\n",
" 'CD406B9D61CE.jpg',\n",
" 'D0F6DE661D63.jpg',\n",
" 'D0F6DE661D64.jpg',\n",
" 'D0F6DE661D65.jpg',\n",
" 'D28CDF85BDA3.jpg',\n",
" 'D91DD06F9B3D.jpg',\n",
" 'D91DD06F9B3E.jpg',\n",
" 'DFC9150DB405.jpg',\n",
" 'E04FFD273493.jpg',\n",
" 'E04FFD273499.jpg',\n",
" 'E3084BAFECCD.jpg',\n",
" 'E89EFB01CEB9.jpg',\n",
" 'EB2EFD28E53E.jpg',\n",
" 'F1BFEA74B33D.jpg']"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## Read the test files\n",
"ip_files = []\n",
"test_files = os.listdir('E:\\\\SigTuple_Hack\\\\Test_Data\\\\')\n",
"ip_files += [f for f in test_files if f.endswith('.jpg') and 'mask' not in f]\n",
"\n",
"#ip_files"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"E:\\SigTuple_Hack\\Test_Data\\017532875DDF.jpg\n"
]
}
],
"source": [
"img_file = ip_files[0]\n",
"input_file = 'E:\\\\SigTuple_Hack\\\\Test_Data\\\\' + img_file\n",
"mask_file = 'E:\\\\SigTuple_Hack\\\\Test_Data\\\\Mask\\\\' + img_file[:-4] + '-mask.jpg'\n",
"print input_file\n",
" \n",
"# Load the image & flatten 3d to 2d .\n",
"imgcolor = imread(input_file)/255.0\n",
"imgshape = imgcolor.shape\n",
"imgdf = pd.DataFrame(imgcolor.transpose(2,0,1).reshape(3,-1).transpose(1,0))\n",
"imgdf.columns = ['Red', 'Green', 'Blue']\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Create mask, using LinearSVC model\n",
"mask = lin_clf.predict(imgdf)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
" \n",
"imgmask = mask.reshape(imgshape[0], imgshape[1])\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
" \n",
"# Save file\n",
"scipy.misc.imsave(mask_file, imgmask)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"E:\\SigTuple_Hack\\Test_Data\\017532875DDF.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\029E137BB177.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\029E137BB179.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\072CBBB64F88.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\072CBBB64F89.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\0BC2C60F3BA0.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468054105.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468054163.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468054267.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468054306.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468061314.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468061317.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468061347.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468061368.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\1468061411.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\16B1C9836EB0.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\264882623008.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\2D6D41F5B4A1.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\308A1C309EF5.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\31A25DC60455.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\31A25DC60456.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\34DBA85D4F7A.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\34DBA85D4F7E.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\469CE8C373A0.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\469CE8C373AC.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5274941329CC.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5274941329CF.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\52B380E6A3F1.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\52B380E6A3F2.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\549C148B2D40.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\549C148B2D4E.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\558DF2AD8A5F.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5ABD740F7441.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5ABD740F744D.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5C75353DF081.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\5C75353DF082.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\682E28C9537E.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\7D00B08A7B2D.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\85639DF5DF72.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\85639DF5DF7C.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\8A87C3794B59.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\BB6EB0F294D8.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\BB6EB0F294DA.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\C11E6107F913.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\C3AC084EA711.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\C4D8C497AB5C.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\CD406B9D61C4.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\CD406B9D61CE.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D0F6DE661D63.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D0F6DE661D64.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D0F6DE661D65.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D28CDF85BDA3.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D91DD06F9B3D.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\D91DD06F9B3E.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\DFC9150DB405.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\E04FFD273493.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\E04FFD273499.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\E3084BAFECCD.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\E89EFB01CEB9.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\EB2EFD28E53E.jpg\n",
"E:\\SigTuple_Hack\\Test_Data\\F1BFEA74B33D.jpg\n"
]
}
],
"source": [
"for img_file in ip_files:\n",
" input_file = 'E:\\\\SigTuple_Hack\\\\Test_Data\\\\' + img_file\n",
" mask_file = 'E:\\\\SigTuple_Hack\\\\Test_Data\\\\Mask\\\\' + img_file[:-4] + '-mask.jpg'\n",
" print input_file\n",
" \n",
" # Load the image & flatten 3d to 2d .\n",
" imgcolor = imread(input_file)/255.0\n",
" imgshape = imgcolor.shape\n",
" imgdf = pd.DataFrame(imgcolor.transpose(2,0,1).reshape(3,-1).transpose(1,0))\n",
" imgdf.columns = ['Red', 'Green', 'Blue']\n",
" \n",
" # Create mask, using LinearSVC model\n",
" mask = lin_clf.predict(imgdf)\n",
" \n",
" imgmask = mask.reshape(imgshape[0], imgshape[1])\n",
" \n",
" # Save file\n",
" scipy.misc.imsave(mask_file, imgmask)\n",
" \n",
" "
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading

0 comments on commit 4cec7d6

Please sign in to comment.