-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
262 lines (206 loc) · 7.4 KB
/
index.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.center-block {
display: block !important;
margin-right: auto !important;
margin-left: auto !important;
}
</style>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-140461850-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-140461850-1');
</script>
<link rel="stylesheet" href="./static/style.css">
<style>
.whole_bg {
background-image: url(https://s2.ax1x.com/2020/01/16/lvIyFJ.gif) !important;
}
</style>
<!--
Note: This is a good css too worth looking at in the future : https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-nord.min.css
-->
<meta charset="UTF-8">
<title>ID Photo Auto Generator</title>
</head>
<div class="common"></div>
<body class="whole_bg" background="https://s2.ax1x.com/2020/01/16/lvIyFJ.gif">
<link rel="stylesheet" href="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="https://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<header class="sticky row">
<div align="center" style="background:#000; color:#FFF">
<br>
<a href="#" class="logo" style="color: #FFF; text-decoration: none;">ID Photo Online Convertor</a>            
<a href="https://github.com/YuchaoZheng/Google_camp" class="logo" style="color: #FFF; text-decoration: none;">code</a>
<br>
<br>
</div>
</header>
<div class="row">
<div class="col-sm-12 col-md-10 col-md-offset-1">
<br/>
<h1 align="center">ID Photo Auto Conversion</h1>
<h1 align="right"><small>deployed by team '三个顶俩'                            </small></h1>
<br><br>
<h3 align="center">
Please upload your selfie on the box below.
</h3>
</br>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//d3js.org/d3.v5.min.js"></script>
<div class='boxitem'>
<div class="whole_bg" id="test-image-preview" style="border: 3px solid #ccc; width: 30%; height: 400px; float:left; display:flex; vertical-align: middle;justify-content: center;align-items: center;">
</div>
<div class="whole_bg" id="result_image" style="border: 3px solid #ccc; width: 30%; height: 400px; display: flex; vertical-align: middle;justify-content: center;align-items: center;">
</div>
</div>
<div class="center-block" style="width:15%" align="center">
<input type="file" id="test-image-file" name="test">
</div>
<div class="center-block" style="width:40%">
<label for="points" class="hint">whitening</label>
<input type='range' id='param1' name='input1' min="0" max="1" value="0" step="0.01">
</div>
<div class="center-block" style="width:40%">
<label for="points" class="hint"> lip brightening</label>
<input type='range' id='param2' name='input2' min="0" max="1" value="0" step="0.01">
</div>
<div class="center-block" style="width:40%">
<label for="points" class="hint">face thining</label>
<input type='range' id='param3' name='input3' min="0" max="1" value="0" step="0.01">
</div>
<div class="center-block" style="width:40%">
<label for="points" class="hint">smoothing</label>
<input type='range' id='param4' name='input4' min="0" max="1" value="0" step="0.01">
</div>
<div class="center-block" style="width:15%">
<button type="button" onclick="Upload_params()">Confirm</button>
</div>
<script>
var fileInput = document.getElementById('test-image-file');
var preview = document.getElementById('test-image-preview');
var result = document.getElementById('result_image');
preview.flag = '0';
var image = '';
// 监听change事件:
fileInput.addEventListener('change', function () {
// 检查文件是否选择:
if (!fileInput.value) {
return;
}
// 获取File引用:
var file = fileInput.files[0];
// 获取File信息:
if (file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
alert('Invalid image file.');
return;
}
preview.flag = '1';
// 读取文件:
var reader = new FileReader();
reader.onload = function(e) {
preview.innerHTML = '<img src="' + e.target.result + '" height=400>';
};
// 以DataURL的形式读取文件:
reader.readAsDataURL(file);
function img_to_backend(){
var formData = new FormData();
formData.append("img", fileInput.files[0]);
$.ajax({
url: '/initialize',
type: 'post',
data: formData,
processData: false,
contentType: false,
success: function (msg) {
alert(msg);
}
}).fail(function(XMLHttpRequest, textStatus, errorThrown) {
//alert("error");
});
}
});
function Upload_params(){
var param1 = document.getElementById("param1").value;
var param2 = document.getElementById("param2").value;
var param3 = document.getElementById("param3").value;
var param4 = document.getElementById("param4").value;
if ((param1 < 0) || (param1 > 1)){
alert("Whitening degree should be in range [0, 1]");
return;
}
if ((param2 < 0) || (param2 > 1)){
alert("lip brightening degree should be in range [0, 1]");
return;
}
if ((param3 < 0) || (param3 > 1)){
alert("face thining degree should be in range [0, 1]");
return;
}
if ((param4 < 0) || (param4 > 1)){
alert("smoothing degree should be in range [0, 1]");
return;
}
if (preview.flag == '0'){
alert("Please provide your image first.");
return;
}
function send_to_backend(param1, param2, param3, param4){
var formdata = new FormData();
var sharpen_val = 0.35
formdata.append("image", fileInput.files[0]);
formdata.append("whighten", param1);
formdata.append("lip_brighten", param2);
formdata.append("thin", param3);
formdata.append("smooth", param4);
formdata.append("sharpen", sharpen_val);
$.ajax({
url: '/predict',
type: 'POST',
data: formdata,
mimeType: "multipart/form-data",
processData: false,
contentType: false,
}).done(function (data){
var image_src = "data:image/png;base64," + data;
result.innerHTML = '<img src="' + image_src + '" height=400 />\n';
}).fail(function(XMLHttpRequest, textStatus, errorThrown) {
//alert("error");
});
}
send_to_backend(param1, param2, param3, param4);
}
</script>
<style>
.boxitem {
display: flex;
justify-content: center;
align-items: center;
vertical-align: middle;
}
.image{
vertical-align: middle;
}
.logo {
font-size: 30px;
}
.hint {
font-size: 20px !important;
}
</style>
<style type="text/css">
a:link {text-decoration:none; color: #FFF;}
a:visited {text-decoration:none; color: #FFF;}
a:hover {text-decoration:none; color: #FFF;}
a:active {text-decoration:none; color: #FFF;}
</style>
</body>
</html>