diff --git a/app.py b/app.py index 9489a79..7a7be94 100644 --- a/app.py +++ b/app.py @@ -11,7 +11,8 @@ app.config['DEBUG'] = True app.config['UPLOAD_FOLDER'] = 'uploads' app.config['FILE_EXTENSIONS'] = ['png', 'jpg', 'pdf', 'jpeg', 'gif'] -app.config['KEYWORDS'] = ['pasta', 'spaghetti', 'angel-hair pasta'] +app.config['KEYWORDS_PASTA'] = ['pasta', 'spaghetti', 'angel-hair pasta'] +app.config['KEYWORDS'] = ['Neil'] app.config['APPROVAL_PERCENTAGE'] = .6000 def allowed_file(filename): @@ -22,6 +23,11 @@ def is_pasta(data): return any(x in data.keys() for x in app.config['KEYWORDS']) \ and any(i > cutoff for i in (data[x] for x in app.config['KEYWORDS'])) +def is_significant(data): + cutoff = app.config['APPROVAL_PERCENTAGE'] + return any(x in data.keys() for x in app.config['KEYWORDS']) \ + and any(i > cutoff for i in (data[x] for x in app.config['KEYWORDS'])) + def clarifai_data(model, filename): model = clarifaiApp.models.get(model) output = model.predict_by_filename(filename=filename) @@ -42,8 +48,8 @@ def uploadFile(): safeFile = secure_filename(fileObj.filename) local_filename = os.path.join(app.config['UPLOAD_FOLDER'], safeFile) fileObj.save(local_filename) - data = clarifai_data('food-items-v1.0', local_filename) - return render_template('index.html', data=is_pasta(data)) + data = clarifai_data('Friends', local_filename) + return render_template('index.html', data=is_significant(data), imgSrc=local_filename) @app.route('/uploads/') def uploaded_file(filename): diff --git a/templates/index.html b/templates/index.html index 64eed6d..a07cdac 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,11 +16,11 @@

How To Upload a File



- + {% if data==True %} - It is Pasta + It is Neil!! {% else %} - It is not Pasta + It is not Neil :( {% endif %} diff --git a/train.py b/train.py index b6d03c8..a2066eb 100644 --- a/train.py +++ b/train.py @@ -30,12 +30,17 @@ def showAllModels(): #list of all urls = [ - 'https://images.eatthismuch.com/site_media/img/4440_laurabedo_38887c39-cc1c-430d-bd4d-2562c09df8cc.png', - 'http://img-aws.ehowcdn.com/350x235p/photos.demandstudios.com/198/37/fotolia_8334344_XS.jpg', - 'http://s.eatthis-cdn.com/media/images/ext/846505625/rice-cakes.jpg', - + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/16640621_1407871549237242_8731785688204173502_n.jpg?oh=5525a02bd34ac7f65d6bb0a54ac4e4f4&oe=59F033FA', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/14708219_1233740213334125_731178637874495198_n.jpg?oh=52105b2e075589444e0c6cfca755d975&oe=59EFCEB2', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/14291921_1252052744819124_8336105302969309541_n.jpg?oh=459016e414efc7806f3bf0fa13383688&oe=5A306660', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/14141903_1236184579739274_7991324806780006796_n.jpg?oh=1780f0e08ca0dd27d84c7ee297a6018e&oe=5A1D73E2', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/14051795_1236184316405967_2865724824847652055_n.jpg?oh=3873b418d711a461c92d9aaf85bfb6a4&oe=5A2A87EF', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/13886902_1817843611783778_1673974955086866955_n.jpg?oh=fecc4646295949d404e935b25e40e9a1&oe=5A2D8460', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-1/17201271_10210800547482891_3681294658914218944_n.jpg?oh=78e33837e1e26035e699ec0c5f8ee29e&oe=5A32CBF5', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/16729009_10210573665530984_7145416717855968866_n.jpg?oh=b407f448138211fbdcc6ac7e25f864df&oe=5A1D7F86', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/20729639_10212344408958463_6202965616116237856_n.jpg?oh=069a8070fac76c9a04d27192506f4cfb&oe=5A336D1E', + 'https://scontent.fdet1-1.fna.fbcdn.net/v/t1.0-9/14184459_10209001400505341_4583114924133526486_n.jpg?oh=936b6e0dc37033968630bb3831e53b73&oe=5A1F79F1', ] concepts = ['Neil'] modelName = 'Friends' -trainModel(urls, concepts, modelName) -showAllModels() \ No newline at end of file +trainModel(urls, concepts, modelName) \ No newline at end of file