-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.html
179 lines (148 loc) · 4.11 KB
/
testing.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<style type="text/css">
input[type=text]{
font-size: 18px;
font-family: 'Jua', sans-serif;
padding: 5px 8px;
margin-bottom: 40px;
width: 350px;
}
.boi{
text-align: center;
margin-top: 20px;
}
.Predict{
font-size: 20px;
background-color: red;
border-radius: 20px;
}
.inputfile {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
#predict{
font-size: 1.25em;
font-weight: 700;
color: white;
background-color: black;
padding: 4px;
border-radius: 20px;
display: inline-block;
}
#predict:hover{
background-color: red;
padding: 4px;
border-radius: 20px;
}
.inputfile + label {
font-size: 1.25em;
font-weight: 700;
color: white;
background-color: black;
padding: 4px;
border-radius: 20px;
display: inline-block;
}
.inputfile:focus + label,
.inputfile + label:hover {
background-color: red;
padding: 4px;
border-radius: 20px;
}
.inputfile:focus + label {
outline: 1px dotted #000;
outline: -webkit-focus-ring-color auto 5px;
}
div.polaroid {
width: 20%;
display: block;
margin-left: auto;
margin-right: auto;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-bottom: 25px;
}
div.container {
text-align: center;
padding: 10px 20px;
}
img {
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Photo Estimator</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</div>
</nav>
<div class="jumbotron">
<h1 class="display-4">Finally</h1>
<p class="lead">Now that we finished training the model ,You may Try it by submitting below the file that you wanna post and let the model its work</p>
<hr class="my-4">
<p>Have fun xD</p>
</div>
<div class="boi">
<form>
<input type="file" name="file" id="file" class="inputfile" />
<label for="file">Choose a file</label><a id="predict">Predict</a>
<div class="polaroid">
<img src="" alt="5 Terre" id="selected-img" style="width:100%;">
<div class="container">
<p>You</p>
</div>
</div>
<h2>Your Prediction :<span id="prediction"></span></h2>
</form>
</div>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script>
let base64Img;
$('#file').change(function() {
let reader = new FileReader();
reader.onload = function(e) {
let dataURL = reader.result;
$('#selected-img').attr("src", dataURL);
base64Img = dataURL.replace('data:image/jpeg;base64,','')
}
boi = reader.readAsDataURL($('#file')[0].files[0]);
$('#prediction').text("");
});
$('#predict').click(function(event){
let message = {
image : base64Img
}
console.log('ye');
console.log(message);
$.post('http://127.0.0.1:5000/predict', JSON.stringify(message), function(response){
$('#prediction').text(response.prediction.toFixed(6));
console.log(response);
});
});
</script>
</body>
</html>