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
import argparse | |
import errno | |
import os | |
import random | |
import shutil | |
def createFolder(path): | |
try: | |
os.makedirs(path) |
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
$('#upload-file-btn').click(function () { | |
$('.loader').show(); | |
$("#results").html(''); | |
var form_data = new FormData($('#upload-file')[0]); | |
$.ajax({ | |
type: 'POST', | |
url: '/predict', | |
data: form_data, | |
contentType: false, | |
cache: false, |
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
<form id="upload-file" method="post" enctype="multipart/form-data"> | |
<div class="form-group"> | |
<label for="InputFile">Resim Dosyası:</label> | |
<input name="image" type="file" class="form-control-file" id="InputFile" aria-describedby="fileHelp"> | |
<small id="fileHelp" class="form-text text-muted">Tanımak istediğiniz resmi bilgisayarınızdan seçiniz</small> | |
</div> | |
<button id="upload-file-btn" type="button" class="btn btn-primary">Gönder</button> | |
</form> |
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
if __name__ == "__main__": | |
print("START FLASK") | |
port = int(os.environ.get('PORT', 5000)) | |
app.run(host='0.0.0.0', port=port) |
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
@app.route("/predict", methods=["POST"]) | |
def predict(): | |
# initialize the data dictionary that will be returned from the | |
# view | |
data = {"success": False} | |
# ensure an image was properly uploaded to our endpoint | |
if request.method == "POST" and request.files['image']: | |
imagefile = request.files["image"].read() | |
image = Image.open(io.BytesIO(imagefile)) | |
# preprocess the image and prepare it for classification |
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
model = ResNet50(weights="imagenet") |
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
from keras.applications import ResNet50 | |
from keras.preprocessing.image import img_to_array | |
from keras.applications import imagenet_utils | |
from PIL import Image | |
import numpy as np | |
from flask import Flask, render_template, request, jsonify, send_from_directory | |
import io | |
import werkzeug | |
import datetime | |
import os |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> | |
<title>Merhaba Flask! Html demosu.</title> | |
</head> | |
<body> | |
<div class="container"> |
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
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def main(): | |
return "Merhaba Flask ;)" | |
if __name__ == "__main__": | |
app.run() |
NewerOlder