-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
76 lines (67 loc) · 2.25 KB
/
index.html
File metadata and controls
76 lines (67 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/ml5@0.3.1/dist/ml5.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Image Detector</title>
<p id="head">AI Eye</p>
</head>
<body id="body">
<nav id="nav">
<a href="index.html">Home</a>
</nav>
<div>
<br><br>
<center><div id="a1">FILE UPLOADER</div></center>
<br><br>
<center><canvas id="canvas" width="300%" height="300%">It's a canvas</canvas></center>
<br><br><br>
<center><form action="fileupload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value=" UPLOAD " name="submit" onclick="preload()">
</form></center>
</div>
<br><br>
<center><div id="a1">DETECTOR</div></center>
<br><br>
<div><div id="result"></div></div>
<br><br>
<center><div><button type="button" onclick="detect()"><h4>DETECT</h4></button><br><br></div></center>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(10, 10, 300, 300);
</script>
<script type="text/javascript">
var img=new Image();
img.src="files/data.png";
img.onload = function ()
{
var ctx = document.getElementById('canvas');
ctx = ctx.getContext('2d');
ctx.drawImage(img, 10, 10, img.width,img.height,10, 10, 300, 300);
$.get("delete.php", function(data, status){});
};
function detect()
{
$("#result").html("<center><h4>Result will be displayed here</h4></center>");
var classifier=ml5.imageClassifier("Mobilenet");
classifier.classify(img,getResult);
}
function getResult(error,results)
{
if(error)
{
$("#result").html(error);
}
else
{
$("#result").html("<center><h3>Label</h3>"+"<h4>"+results[0].label+"</h4>"+"<h3>Confidence</h3>"+"<h4>"+results[0].confidence+"</h4></center>");
}
}
</script>
</body>
</html>