Skip to content

Instantly share code, notes, and snippets.

View yavuzKomecoglu's full-sized avatar
:atom:
Research

Yavuz Kömeçoğlu yavuzKomecoglu

:atom:
Research
View GitHub Profile
@yavuzKomecoglu
yavuzKomecoglu / split-train-test-val.py
Last active September 14, 2021 08:16
Split Data Into Training, Test And Validation Sets
import argparse
import errno
import os
import random
import shutil
def createFolder(path):
try:
os.makedirs(path)
$('#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,
<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>
if __name__ == "__main__":
print("START FLASK")
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
@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
model = ResNet50(weights="imagenet")
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
<!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">
@yavuzKomecoglu
yavuzKomecoglu / ai-image-recognition-web-1.py
Last active May 10, 2018 21:20
ai-image-recognition-web-1
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return "Merhaba Flask ;)"
if __name__ == "__main__":
app.run()