comm

parent 364c99cd
This diff is collapsed.
......@@ -7,7 +7,7 @@ from urllib import request
from io import BytesIO
from keras_preprocessing import image
import urllib.request
from datetime import date
from keras.models import load_model
import csv
......@@ -24,36 +24,38 @@ wt = random.randint(380, 490)
@flask_app.route("/")
def Home():
return render_template("predi.html")
return render_template("client.html")
@flask_app.route("/classify", methods = ["POST"])
def classify():
image_path = "http://192.168.8.103/saved-photo"
print("working.1")
image_path = "https://static9.depositphotos.com/1628352/1107/i/600/depositphotos_11071200-stock-photo-cabbage.jpg"
class_names = ['banana', 'cabbage', 'cucumber', 'mango', 'orange', 'tomato']
print("working....2")
img = Image.open(BytesIO(request.urlopen(image_path).read())).resize((224, 224))
print("working....3")
# img = image.load_img(request.urlopen(image_path), target_size=(224,224,3))
x = image.img_to_array(img)
print("working....4")
x = np.expand_dims(x, axis=0)
print("working....5")
images = np.vstack([x])
print("working....6")
pred = model1.predict(images, batch_size=6)
print("working....")
label = np.argmax(pred, axis=1)
out = class_names[np.argmax(pred)]
print(out)
print("workig")
return render_template("predi.html", prediction_text_class = "The flower species is {}".format(out))
return render_template("predi.html", prediction_text_class = out)
@flask_app.route("/price", methods = ["POST"])
def price():
vegi = 'banana'
dt = '18/10/2021'
today = date.today()
dt = today.strftime("%d/%m/%Y")
image_path = "https://static9.depositphotos.com/1628352/1107/i/600/depositphotos_11071200-stock-photo-cabbage.jpg"
class_names = ['banana', 'cabbage', 'cucumber', 'mango', 'orange', 'tomato']
img = Image.open(BytesIO(request.urlopen(image_path).read())).resize((224, 224))
# img = image.load_img(request.urlopen(image_path), target_size=(224,224,3))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
images = np.vstack([x])
pred = model1.predict(images, batch_size=6)
label = np.argmax(pred, axis=1)
out = class_names[np.argmax(pred)]
with open('data/Predict_vegetable_2021_SL.csv', encoding="utf8") as f:
csv_reader = csv.DictReader(f)
......@@ -61,14 +63,14 @@ def price():
for line in csv_reader:
if line['date'] == dt and line['item'] == vegi:
if line['date'] == dt and line['item'] == out:
para = line['price']
print(line['price'])
listM = [vegi, dt, para]
return render_template("predi.html", vegita = vegi, dte = dt, pr = para)
return render_template("resultsPrice.html", vegita = out, dte = dt, price = para, weight = wt)
# return render_template("predi.html", prediction_text_class_price="The price is {}".format(para))
if __name__ == "__main__":
flask_app.run(debug=True)
\ No newline at end of file
flask_app.run(debug=False)
\ No newline at end of file
......@@ -66,4 +66,3 @@ history = model.fit(x=train_dataset,
model.save('imgClassification.h5')
joblib.dump(model, "imgClassmodel.joblib")
\ No newline at end of file
......@@ -18,14 +18,14 @@
href="https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="/public/css/style.css" />
<title>OrgiCheck</title>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg bg-dark navbar-dark py-3 fixed-top">
<div class="container">
<a href="#" class="navbar-brand">OrgiCheck</a>
<a href="/" class="navbar-brand">OrgiCheck</a>
<button
class="navbar-toggler"
......@@ -74,7 +74,7 @@
</div>
<img
class="img-fluid w-50 d-none d-sm-block"
src="public/img/gopro.png"
src="/public/img/gopro.png"
alt=""
/>
</div>
......@@ -102,29 +102,14 @@
<div class="container">
<div class="row align-items-center justify-content-between">
<div class="col-md">
<img id="stream" src="http://192.168.8.103/saved-photo" class="img-fluid" alt=""/>
<!-- <script>
const img = document.querySelector('#stream');
const WS_URL = 'ws:///192.168.8.105:8888';
const ws = new WebSocket(WS_URL);
let urlObject;
ws.onopen = () => console.log(`Connected to ${WS_URL}`);
ws.onmessage = message => {
const arrayBuffer = message.data;
if(urlObject){
URL.revokeObjectURL(urlObject);
}
urlObject = URL.createObjectURL(new Blob([arrayBuffer]));
img.src = urlObject;
}
</script> -->
<img src="https://static9.depositphotos.com/1628352/1107/i/600/depositphotos_11071200-stock-photo-cabbage.jpg" class="img-fluid" alt=""/>
</div>
<div class="col-md p-5">
<h2>Device Connection</h2>
<p>
Please connect your <span class="text-warning"> OrgiCheck&trade; Smart</span> with the same network
</p>
<a href="http://192.168.8.103" class="btn btn-light mt-3">
<a href="http://192.168.8.103/" class="btn btn-light mt-3">
<i class="bi bi-camera"></i> Retake Image
</a>
</div>
......@@ -214,19 +199,20 @@
</div>
<h3 class="card-title mb-3">Price</h3>
<form action="/">
<form action="{{ url_for('price')}}"method="post">
<input class="btn btn-primary" type="file" id="img" name="img" accept="image/*">
<br>
<br>
<button data-bs-toggle="modal"
<button type="submit" data-bs-toggle="modal"
data-bs-target="#price" class="btn btn-warning">Check with choosed image</button>
</form>
or
<br>
<button data-bs-toggle="modal"
data-bs-target="#price" class="btn btn-success">Check with captured image</button>
<form action="{{ url_for('price')}}"method="post">
<button type="submit" class="btn btn-success">Check with captured image</button>
</form>
</div>
{{ price }}
</div>
</div>
......@@ -572,13 +558,13 @@
Detected Item:
</label>
<label class="col-form-label">
Mango
{{ vegita }}
</label>
</div>
<div class="mb-3">
<label class="col-form-label">Approximate Weight:</label>
<label class="col-form-label">
500g
{{ weight }}
</label>
</div>
<div class="mb-3">
......@@ -587,7 +573,7 @@
</div>
<div class="mb-3">
<label class="col-form-label">Estimated Price:</label>
<label class="col-form-label">LKR. 40.00</label>
<label class="col-form-label">LKR. {{ price }}</label>
</div>
</form>
</div>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css"
/>
<link
href="https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="/public/css/style.css" />
<title>OrgiCheck</title>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg bg-dark navbar-dark py-3 fixed-top">
<div class="container">
<a href="/" class="navbar-brand">OrgiCheck</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navmenu"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navmenu">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a href="#cam" class="nav-link">Device Connection</a>
</li>
<li class="nav-item">
<a href="#team" class="nav-link">Team</a>
</li>
</ul>
</div>
</div>
</nav>
<br>
<br>
<br>
<br>
<!-- Boxes -->
<section id="check" class="p-5">
<div class="container">
<div class="row text-center g-4">
<div class="col-md">
<div class="card bg-dark text-light">
<div class="card-body text-center">
<div class="h1 mb-3">
<i class="bi bi-cash"></i>
</div>
<h3 class="card-title mb-3">Price</h3>
<p>{{ vegita }}</p>
<p>{{ weight }}</p>
<p> {{ price }} </p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="p-5 bg-dark text-white text-center position-relative">
<div class="container">
<p class="lead">Copyright &copy; 2021 OrgiCheck</p>
<a href="#" class="position-absolute bottom-0 end-0 p-5">
<i class="bi bi-arrow-up-circle h1"></i>
</a>
</div>
</footer>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment