Permalink
Browse files

First commit.

  • Loading branch information...
eliot.andres
eliot.andres committed Sep 28, 2017
0 parents commit f4999bd2ad109b2321ada8265b338fe4bf3aed89
Showing with 911 additions and 0 deletions.
  1. +21 −0 LICENSE
  2. +41 −0 README.md
  3. +20 −0 app.js
  4. BIN image/favicon.png
  5. +85 −0 index.html
  6. +24 −0 models.yaml
  7. +85 −0 models/vgg.py
  8. +15 −0 scripts/fetchData.sh
  9. +5 −0 style.css
  10. +562 −0 vendors/angular-tablesort.js
  11. +1 −0 vendors/js-yaml.min.js
  12. +52 −0 vendors/tablesort.css
21 LICENSE
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Eliot ANDRES
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,41 @@
# Kaggle Past Solutions
A searchable and sortable compilation of [Kaggle](https://www.kaggle.com/) past solutions. [Website](http://ndres.me/kaggle-past-solutions/)
## About
If you are facing a data science problem or just want to learn, there is a good chance that you can find inspiration here !
## Contributing
Many competitions are missing links to their solutions, evaluation and type.
To contribute:
- Fork the repo
- Edit the **competitions.json** file (you can even edit it with Github's editor)
- Make a pull request
For each competition missing the data, please add the following fields:
"types": [],
"evaluation": "",
"solutions": [
{
"label": "",
"url": ""
}
]
Evaluation should contain the name of the evaluation metric and its abreviation (if applicable).
The solutions should be links to the Kaggle forum (if possible) or blog posts.
For instance, you might add:
"types": ["Image Detection", "Classification"],
"evaluation": "Multi-class logarithmic loss (logloss)",
"solutions": [
{
"label": "#1 Solution",
"url": "https://www.kaggle.com/c/state-farm-distracted-driver-detection/forums/t/22906/a-brief-summary"
},
{
"label": "#3 Solution",
"url": "https://www.kaggle.com/c/state-farm-distracted-driver-detection/forums/t/22631/3-br-power-solution"
}
]
20 app.js
@@ -0,0 +1,20 @@
var app = angular.module('app', ['tableSort']);
app
.controller('MainController', function MainController($scope, $http) {
$scope.models = [];
$http({
method: 'GET',
url: 'models.yaml'
}).then(function successCallback(response) {
$scope.models = jsyaml.load(response.data).models; // response data
}, function errorCallback(error) {
console.error(error);
});
})
.filter('parseCurrency', function () {
return function (input) {
return input.replace('$', '').replace(/,/g, '');
};
});
BIN +4.97 KB image/favicon.png
Binary file not shown.
@@ -0,0 +1,85 @@
<!doctype html>
<html ng-app="app">
<head>
<title>Pre-trained deep learning models - pretrained.ml</title>
<meta charset="UTF-8">
<link href="image/favicon.png" rel="shortcut icon" type="image/x-icon" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="vendors/tablesort.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body ng-controller="MainController">
<a href="https://github.com/EliotAndres/kaggle-past-solutions">
<img style="position: absolute; top: 0; right: 0; border: 0;"
src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png">
</a>
<div class="container" role="main">
<div class="jumbotron">
<h1>State Of The Art Machine Learning</h1>
<h4>Sortable and searchable compilation of pre-trained deep learning models. With demos.</h4>
<p>Pretrained models are deep learning model weights that you can download and use without training</p>
<p></p>
<p>
<iframe
src="https://ghbtns.com/github-btn.html?user=EliotAndres&repo=kaggle-past-solutions&type=star&count=true"
frameborder="0"
scrolling="0"
width="170px"
height="20px">
</iframe>
<iframe
src="https://ghbtns.com/github-btn.html?user=EliotAndres&repo=kaggle-past-solutions&type=fork&count=true"
frameborder="0"
scrolling="0"
width="170px"
height="20px">
</iframe>
</p>
<h6>If you find a mistake please report it <a target="_blank" href="https://github.com/EliotAndres/pretrained.ml/issues">here</a></h6>
</div>
<form class="form-inline">
<div class="form-group">
<input ng-model="search.$" class="form-control" id="search" placeholder="Search">
</div>
</form>
<div class="row" style="overflow: scroll">
<table class="table" ts-wrapper>
<thead>
<tr>
<th>Type</th>
<th ts-criteria="competitionTitle | lowercase">Name</th>
<th ts-criteria="type">Type</th>
<th ts-criteria="size | parseFloat" style="min-width: 100px;">Size</th>
<th ts-criteria="links" style="min-width: 100px;">Reference</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="model in models | filter:search:strict" ts-repeat>
<td>
<img ng-src="https://raw.githubusercontent.com/likedan/Awesome-CoreML-Models/master/images/coreml.png" alt="Logo" width="100"/>
</td>
<td>
<h4><a target="_blank" ng-href="https://www.kaggle.com{{competition.competitionUrl}}">{{model.name}}</a></h4>
<p>{{model.description}}</p>
</td>
<td>{{model.type}}</td>
<td>{{model.size}} MB</td>
<td><a target="_blank" ng-href="{{model.reference}}">Reference</a> //
<a target="_blank" ng-href="{{model.demo}}">Demo</a></td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /container -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="vendors/angular-tablesort.js"></script>
<script src="vendors/js-yaml.min.js"></script>
<script src="app.js"></script>
</body>
</html>
@@ -0,0 +1,24 @@
models:
-
name: VGG16
description: Classic object recognition model
type: Object Recognition
size: 528
reference: https://arxiv.org/abs/1409.1556
-
name: Inception V3
description: Classic object recognition model
type: Object Recognition
size: 92
reference: https://arxiv.org/abs/1512.00567
-
name: Mobile Net
description: Suited for mobile devices
type: Object Recognition
size: 17
reference: https://arxiv.org/pdf/1704.04861.pdf
@@ -0,0 +1,85 @@
# For VGG16
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input as preprocess_input_vgg,\
decode_predictions as decode_predictions_vgg
# For MobileNet
from keras.applications.mobilenet import MobileNet
from keras.applications.vgg16 import preprocess_input as preprocess_input_mobilenet,\
decode_predictions as decode_predictions_mobilenet
from keras.preprocessing import image
import numpy as np
from flask import Flask, request, redirect, url_for, abort
import cv2
from PIL import Image
import json
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
ERROR_NO_IMAGE = 'Please provide an image'
app = Flask(__name__)
logger.info('Loading vgg16')
vgg16_model = VGG16(weights='imagenet')
logger.info('Loading mobilenet')
mobilenet_model = MobileNet(weights='imagenet')
#def handle_image(model, request):
@app.route('/vgg16', methods=['POST'])
def vgg():
if 'file' not in request.files:
abort(400, ERROR_NO_IMAGE)
return
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
abort(400, ERROR_NO_IMAGE)
img = Image.open(file)
img = img.resize((224, 224))
print(img.size)
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input_vgg(x)
features = vgg16_model.predict(x)
predictions = decode_predictions_vgg(features)[0]
clean_predictions = [{'score': str(k), 'class': j} for (i, j, k) in predictions]
return json.dumps(clean_predictions)
@app.route('/mobilenet', methods=['POST'])
def mobilenet():
if 'file' not in request.files:
abort(400, ERROR_NO_IMAGE)
return
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
abort(400, ERROR_NO_IMAGE)
img = Image.open(file)
img = img.resize((224, 224))
print(img.size)
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input_mobilenet(x)
features = mobilenet_model.predict(x)
predictions = decode_predictions_mobilenet(features)[0]
clean_predictions = [{'score': str(k), 'class': j} for (i, j, k) in predictions]
return json.dumps(clean_predictions)
app.run(debug=False, host='0.0.0.0', port=8091)
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
maxpage=13
for ((i=0; i<maxpage; i++))
do
curl "https://www.kaggle.com/competitions.json?sortBy=deadline&group=all&segment=allCategories&page=${i}" -o "file-${i}.json"
done
jq '.competitions[]' file-* | jq -s . > competitions.json
for ((i=0; i<maxpage; i++))
do
rm "./file-${i}.json"
done
@@ -0,0 +1,5 @@
.jumbotron {
background: linear-gradient(-150deg, rgb(49, 255, 182), #51B3EC) fixed;
color: white;
margin-top: 20px;
}
Oops, something went wrong.

0 comments on commit f4999bd

Please sign in to comment.