From 1becb21320b1ecfbabab610bbbfe1f9186085185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=86=AC=E7=85=9C?= <10185101162@stu.ecnu.edu.cn> Date: Wed, 30 Dec 2020 19:01:38 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=96=B0=E5=A2=9E=E9=98=9F=E5=88=97=E8=B0=83?= =?UTF-8?q?=E5=BA=A6'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.vs/style-transform-master/v16/.suo | Bin 59904 -> 60416 bytes .../style-transform-master/html/fail.html | 11 +++ .../style-transform-master/html/generate.html | 4 +- ...transform-master.njsprojAssemblyReference.cache | Bin 424 -> 424 bytes .../style-transform-master/public/js/generate.js | 1 + ...176b2f8f89ba8b530007d6986c2fa9c922a17a4758a.jpg | Bin 45846 -> 0 bytes ...176b2fb522f98d18e1c2a7fbb26857de6e644f6d096.jpg | Bin 63390 -> 0 bytes ...176b3104418353a1deca2017e116ff55024cf4e0071.jpg | Bin 63390 -> 0 bytes ...176b344f40c982f6168b63a0165c869a89be89c8537.jpg | Bin 0 -> 46212 bytes ...176b3478124094634bb8c1aceda8d75ea236a21175a.jpg | Bin 0 -> 61022 bytes ...176b348fcce3fc160596c09a98cbe47ee2a086c42bd.jpg | Bin 0 -> 61808 bytes ...176b34907171b5597171b2e24a6430897b21314cf27.jpg | Bin 0 -> 46269 bytes .../uploads/1c9986aaecb7d17aaddbeaaeb006e37f | Bin 95235 -> 0 bytes .../uploads/24140d7a8f001e552893569e61c45022 | Bin 0 -> 95235 bytes .../uploads/248baa6862e643126e7cc271f5c0db43 | Bin 0 -> 95235 bytes .../uploads/266574aed51b4b86b16df83ce27ef93d | Bin 211247 -> 0 bytes .../uploads/31cb74097c0f137cda202f97fc82c39c | Bin 0 -> 95235 bytes .../uploads/32a9eb5edee2387c3e20c301679db380 | Bin 211247 -> 0 bytes .../uploads/332d42af8f74e985fb1571620b4a860b | Bin 95235 -> 0 bytes .../uploads/34c21eb4ab6d5f21fe38e0e7c5e0bc51 | Bin 23838 -> 0 bytes .../uploads/40bf7fff77f209858c92692c1643db05 | Bin 0 -> 23838 bytes .../uploads/4a528c2b3d548f21efd498d6fcc6ee3e | Bin 0 -> 95235 bytes .../uploads/4b1e4e9c4e4fbe9de78602e683b21ba6 | Bin 95235 -> 0 bytes .../uploads/6be77319ed4f40cb3764c9d17a0e3e6d | Bin 0 -> 211247 bytes .../uploads/7b5ee265b28a6127e1655142523c6ce4 | Bin 0 -> 95235 bytes .../uploads/876ae07ab5531800fbcabcdca5e507a2 | Bin 211247 -> 0 bytes .../uploads/9529e38e01e4ade24d1939ae029ea7ba | Bin 0 -> 23838 bytes .../uploads/a0e8ff26bdf39d016052c3338fd11ab9 | Bin 0 -> 211247 bytes .../uploads/a66b7d24b2ae85efd87692b33e8e69d1 | Bin 0 -> 23838 bytes .../uploads/b68ae966a5ac0ce4ef5c59feff613a2e | Bin 0 -> 23838 bytes .../uploads/c0c0d564976eb7c53c1436be2333f31e | Bin 0 -> 95235 bytes .../uploads/caa0e5cfcb3f4597e4c0ed7790275f31 | Bin 0 -> 95235 bytes .../uploads/cc3197b0d46fdb5831763b680c3ace57 | Bin 95235 -> 0 bytes .../uploads/cdd8721916bc1b41e4de3a3c406953cd | Bin 95235 -> 0 bytes .../uploads/ce4073057a801b2ca993fb1469a15e99 | Bin 0 -> 95235 bytes .../uploads/d517817f8cfc575b5a80563ff5359cd3 | Bin 211247 -> 0 bytes .../uploads/d69579c100d6143a74359598b5277cc9 | Bin 95235 -> 0 bytes .../uploads/d6a0e417d27ad4937da8f0ce7a826fd4 | Bin 0 -> 95235 bytes .../uploads/e634459ff4fd2d759b4691375f922723 | Bin 0 -> 23838 bytes .../uploads/f08b08ca187fecef6f70582cc988d459 | Bin 23838 -> 0 bytes .../uploads/f8abae0975cdc75a23d08fdf7c22b90c | Bin 0 -> 211247 bytes .../uploads/fe5269e79229d462114741c0ffadf28a | Bin 0 -> 23838 bytes .../style-transform-master/server.js | 76 ++++++++++++++------- .../style-transform-master.njsproj | 3 + 44 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 style-transform-master/style-transform-master/html/fail.html delete mode 100644 style-transform-master/style-transform-master/public/uploads/176b2f8f89ba8b530007d6986c2fa9c922a17a4758a.jpg delete mode 100644 style-transform-master/style-transform-master/public/uploads/176b2fb522f98d18e1c2a7fbb26857de6e644f6d096.jpg delete mode 100644 style-transform-master/style-transform-master/public/uploads/176b3104418353a1deca2017e116ff55024cf4e0071.jpg create mode 100644 style-transform-master/style-transform-master/public/uploads/176b344f40c982f6168b63a0165c869a89be89c8537.jpg create mode 100644 style-transform-master/style-transform-master/public/uploads/176b3478124094634bb8c1aceda8d75ea236a21175a.jpg create mode 100644 style-transform-master/style-transform-master/public/uploads/176b348fcce3fc160596c09a98cbe47ee2a086c42bd.jpg create mode 100644 style-transform-master/style-transform-master/public/uploads/176b34907171b5597171b2e24a6430897b21314cf27.jpg delete mode 100644 style-transform-master/style-transform-master/public/uploads/1c9986aaecb7d17aaddbeaaeb006e37f create mode 100644 style-transform-master/style-transform-master/public/uploads/24140d7a8f001e552893569e61c45022 create mode 100644 style-transform-master/style-transform-master/public/uploads/248baa6862e643126e7cc271f5c0db43 delete mode 100644 style-transform-master/style-transform-master/public/uploads/266574aed51b4b86b16df83ce27ef93d create mode 100644 style-transform-master/style-transform-master/public/uploads/31cb74097c0f137cda202f97fc82c39c delete mode 100644 style-transform-master/style-transform-master/public/uploads/32a9eb5edee2387c3e20c301679db380 delete mode 100644 style-transform-master/style-transform-master/public/uploads/332d42af8f74e985fb1571620b4a860b delete mode 100644 style-transform-master/style-transform-master/public/uploads/34c21eb4ab6d5f21fe38e0e7c5e0bc51 create mode 100644 style-transform-master/style-transform-master/public/uploads/40bf7fff77f209858c92692c1643db05 create mode 100644 style-transform-master/style-transform-master/public/uploads/4a528c2b3d548f21efd498d6fcc6ee3e delete mode 100644 style-transform-master/style-transform-master/public/uploads/4b1e4e9c4e4fbe9de78602e683b21ba6 create mode 100644 style-transform-master/style-transform-master/public/uploads/6be77319ed4f40cb3764c9d17a0e3e6d create mode 100644 style-transform-master/style-transform-master/public/uploads/7b5ee265b28a6127e1655142523c6ce4 delete mode 100644 style-transform-master/style-transform-master/public/uploads/876ae07ab5531800fbcabcdca5e507a2 create mode 100644 style-transform-master/style-transform-master/public/uploads/9529e38e01e4ade24d1939ae029ea7ba create mode 100644 style-transform-master/style-transform-master/public/uploads/a0e8ff26bdf39d016052c3338fd11ab9 create mode 100644 style-transform-master/style-transform-master/public/uploads/a66b7d24b2ae85efd87692b33e8e69d1 create mode 100644 style-transform-master/style-transform-master/public/uploads/b68ae966a5ac0ce4ef5c59feff613a2e create mode 100644 style-transform-master/style-transform-master/public/uploads/c0c0d564976eb7c53c1436be2333f31e create mode 100644 style-transform-master/style-transform-master/public/uploads/caa0e5cfcb3f4597e4c0ed7790275f31 delete mode 100644 style-transform-master/style-transform-master/public/uploads/cc3197b0d46fdb5831763b680c3ace57 delete mode 100644 style-transform-master/style-transform-master/public/uploads/cdd8721916bc1b41e4de3a3c406953cd create mode 100644 style-transform-master/style-transform-master/public/uploads/ce4073057a801b2ca993fb1469a15e99 delete mode 100644 style-transform-master/style-transform-master/public/uploads/d517817f8cfc575b5a80563ff5359cd3 delete mode 100644 style-transform-master/style-transform-master/public/uploads/d69579c100d6143a74359598b5277cc9 create mode 100644 style-transform-master/style-transform-master/public/uploads/d6a0e417d27ad4937da8f0ce7a826fd4 create mode 100644 style-transform-master/style-transform-master/public/uploads/e634459ff4fd2d759b4691375f922723 delete mode 100644 style-transform-master/style-transform-master/public/uploads/f08b08ca187fecef6f70582cc988d459 create mode 100644 style-transform-master/style-transform-master/public/uploads/f8abae0975cdc75a23d08fdf7c22b90c create mode 100644 style-transform-master/style-transform-master/public/uploads/fe5269e79229d462114741c0ffadf28a diff --git a/style-transform-master/.vs/style-transform-master/v16/.suo b/style-transform-master/.vs/style-transform-master/v16/.suo index 05d30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e`Nv#{;LaX68ufjh$q zz`yPA+-@P?hAy@96>Ffum3Fl!r=;kTQejhh6`ajip<*BL!yO&$;XfI8OBq~gR*TWi zuTNWC-_xwGmV?rDHqo};#tt~l9QuO)vf9dZO7Cx6)Lkapx_A!8*OhT^%D~ZBgRAv} ze;x4$gP`?K))^;Hz#(ia&4!UqE&5+Alx%K#s3DED@bW+aB$sOgl2Ua>_i^f>iB^dY z0VnSKNypULdFObzx(e@NX4$iN6Klq6svdn{;T*X1+gKPWkA_+- z(kx5BUHL?0);0!>opx|oXS%{5#fF9ZZ?XYs>g;w)!&nBc^4H?k{ihi8ZJmpUrgwM| z@ZCXz-6nYmG}*xO=!t`HMZOrlk4n`0cvqXv>#G|6gQ@yXolayiM|B+|7~KjLvVStD z?C*h|p+)d&j~3qRO$BvYH~rQj!fuV{)RtAUVyXPfjxB>eCFlMtwoblH8o6-y z&+~((O$Z+h#mke>-$7#ke18h+bdxbXkPLmG%FRr|bC&u#3oh66&_?DrF=b@1vA@q{ zNRQjB?zd*{fghG}--`YRtk*sUYBF2_5sy>AbkeHnkljZmoEeITcL&0Q>Gd(0;vMua zLprSOe?#I*?0GATh0&8xN^~)zcY|rtIYh1tfT}bME#LX1;dE;H)Z5AZ!hEE`FgPZ7tTaO8Ml-$GY23ww;=t!? z@h&y?4s+FW;Ll^p;?fJ}8CQTY|3Egb{3+qM4%k2#EGSP@P2R@b&x`RS9sGT?3!fN~ t82G~=_vmi;;Pdvuqj*6QwkC@0=XZO-_<=>J#2>GkuDfW08f`U5_HPg_AqoHh diff --git a/style-transform-master/style-transform-master/html/fail.html b/style-transform-master/style-transform-master/html/fail.html new file mode 100644 index 0000000..0de3692 --- /dev/null +++ b/style-transform-master/style-transform-master/html/fail.html @@ -0,0 +1,11 @@ + + + + + + Fail + + + + + \ No newline at end of file diff --git a/style-transform-master/style-transform-master/html/generate.html b/style-transform-master/style-transform-master/html/generate.html index 576dd63..dfc1624 100644 --- a/style-transform-master/style-transform-master/html/generate.html +++ b/style-transform-master/style-transform-master/html/generate.html @@ -34,7 +34,9 @@

WAITING

- 正在为您绘画,请稍等……
已完成% + 正在为您绘画,请稍等……
+ 您的前方还有个作画任务,请耐心等待。
+ 已完成%。

diff --git a/style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache b/style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache index a3ab5aa226422b05e325b8b5b3f13de3d7a47b5f..80efde49189f7ab2e740a2ee31b32145574ed6f5 100644 GIT binary patch delta 13 UcmZ3%yn=ayKO>{i{S { @@ -80,11 +71,45 @@ server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 }, progress[taskID].status = -1; } console.log(taskID + " done!"); + totalTask += 1; + + if (queue.length == 0) { + isIdle = true; + } else { + let nextTaskID = queue.shift(); + run_child(nextTaskID); + } }); +} + +server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 }, { name: 'style_image', maxCount: 1 }]), function (req, res) { + let max_epoch = req.body.max_epoch; + let md5 = crypto.createHash('md5'); + + console.log(req.files); + console.log("Epoch = " + max_epoch); + + if (!req.files.content_image || !req.files.style_image) { + progress[taskID] = {percentage: 0, max_epoch: 0, status: -2}; + } + + let taskID = Date.now().toString(16) + md5.update(req.files.content_image[0].filename + req.files.style_image[0].filename).digest('hex'); + + relationfile[taskID] = {content: req.files.content_image[0].filename, style: req.files.style_image[0].filename}; + progress[taskID] = {percentage: 0, max_epoch: parseInt(max_epoch), status: 0, wait: totalTask + queue.length + 1}; + + if (isIdle) { + isIdle = false; + progress[taskID].wait -= 1; + run_child(taskID); + } else { + queue.push(taskID); + } + let $ = cheerio.load(fs.readFileSync("./html/generate.html")); - $('script[name="go"]').html(`setInterval(function() {getProgress("${taskID}");}, 1000);`); + $('script[name="go"]').html(`getProgress("${taskID}"); setInterval(function() {getProgress("${taskID}");}, 1000);`); res.writeHead(200, { 'Content-type': 'text/html' }); res.end($.html()); @@ -108,12 +133,17 @@ server.get('/success', function (req, res) { }); server.get('/fail', function (req, res) { - + res.writeHead(200, { 'Content-type': 'text/html' }); + res.end(fs.readFileSync("./html/fail.html")); }); server.get('/progress', function (req, res) { - if(req.query.taskID) { - res.json(progress[req.query.taskID]); + if(req.query.taskID && progress[req.query.taskID]) { + let result_obj = {}; + result_obj.percentage = progress[req.query.taskID].percentage; + result_obj.wait = progress[req.query.taskID].wait - totalTask; + result_obj.status = progress[req.query.taskID].status; + res.json(result_obj); } }); diff --git a/style-transform-master/style-transform-master/style-transform-master.njsproj b/style-transform-master/style-transform-master/style-transform-master.njsproj index cb777b7..5dfde67 100644 --- a/style-transform-master/style-transform-master/style-transform-master.njsproj +++ b/style-transform-master/style-transform-master/style-transform-master.njsproj @@ -28,6 +28,9 @@ true + + Code +