diff --git a/style-transform-master/.vs/style-transform-master/v16/.suo b/style-transform-master/.vs/style-transform-master/v16/.suo index 5ae9a8f..6bb858f 100644 Binary files a/style-transform-master/.vs/style-transform-master/v16/.suo and b/style-transform-master/.vs/style-transform-master/v16/.suo differ diff --git a/style-transform-master/style-transform-master/html/index.html b/style-transform-master/style-transform-master/html/index.html index 8632016..e20c9e7 100644 --- a/style-transform-master/style-transform-master/html/index.html +++ b/style-transform-master/style-transform-master/html/index.html @@ -1,4 +1,4 @@ - + @@ -25,10 +25,10 @@ + + + + @@ -160,7 +160,8 @@

START HERE

-

We love feedback. Fill out +

+ We love feedback. Fill out the form below and we'll get back to you as soon as possible. in minus distinctio dolores ipsam.

@@ -176,24 +177,25 @@

请选择内容图片:

- + + accept="image/gif,image/jpeg, image/png, image/jpg" />

请选择风格图片:

- + + accept="image/gif,image/jpeg, image/png, image/jpg" />
- +
-

+
+
@@ -248,6 +250,7 @@
+ diff --git a/style-transform-master/style-transform-master/html/success.html b/style-transform-master/style-transform-master/html/success.html new file mode 100644 index 0000000..e685a37 --- /dev/null +++ b/style-transform-master/style-transform-master/html/success.html @@ -0,0 +1,141 @@ + + + + + + Result + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+

RESULT

+ +
+ + +
+
+ + +
+ + + + +
+ +
+ +
+
+
+
    +
  • + +
  • +
+
+
+
+
+ + +
+ +
+
+
+
    +
  • + +
  • +
+
+
+
+
+ + +
+ +
+
+
+
    +
  • + +
  • +
+
+
+
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 ab32277..a8ec8df 100644 Binary files a/style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache and b/style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache differ diff --git a/style-transform-master/style-transform-master/public/js/generate.js b/style-transform-master/style-transform-master/public/js/generate.js index 5b218f3..ad3d254 100644 --- a/style-transform-master/style-transform-master/public/js/generate.js +++ b/style-transform-master/style-transform-master/public/js/generate.js @@ -4,9 +4,11 @@ function getProgress(taskID) { type: 'GET', dataType: 'json' }).done(function(data) { - $('#progress').html(data.percentage); + $('#progress').html(data.percentage + "%"); if(data.status == 1) { - window.location.replace('./success'); + window.location.replace('./success?taskID='+taskID); + } else if (data.status != 0) { + window.location.replace('./fail?taskID='+taskID); } }); } \ No newline at end of file diff --git a/style-transform-master/style-transform-master/uploads/3bfb7ded24712cf0b36ad149fea96495 b/style-transform-master/style-transform-master/public/uploads/13c6cc67a90e6649af5357db0257fb21 similarity index 100% rename from style-transform-master/style-transform-master/uploads/3bfb7ded24712cf0b36ad149fea96495 rename to style-transform-master/style-transform-master/public/uploads/13c6cc67a90e6649af5357db0257fb21 diff --git a/style-transform-master/style-transform-master/public/uploads/176b11a906dab60546f934a1c601a29d3bcd365097a.jpg b/style-transform-master/style-transform-master/public/uploads/176b11a906dab60546f934a1c601a29d3bcd365097a.jpg new file mode 100644 index 0000000..9ab5817 Binary files /dev/null and b/style-transform-master/style-transform-master/public/uploads/176b11a906dab60546f934a1c601a29d3bcd365097a.jpg differ diff --git a/style-transform-master/style-transform-master/uploads/176ad444b5f5c0a88a6ae3a097a6378420bde09ba2f.jpg b/style-transform-master/style-transform-master/public/uploads/176b12417a2cef04215ab4ee05a398c8042675703a4.jpg similarity index 100% rename from style-transform-master/style-transform-master/uploads/176ad444b5f5c0a88a6ae3a097a6378420bde09ba2f.jpg rename to style-transform-master/style-transform-master/public/uploads/176b12417a2cef04215ab4ee05a398c8042675703a4.jpg diff --git a/style-transform-master/style-transform-master/uploads/d33dff37d2afa89c6e2d6fe02ab30629 b/style-transform-master/style-transform-master/public/uploads/2e407fd9b3b3fdc4d7ad5a13412cd8db similarity index 100% rename from style-transform-master/style-transform-master/uploads/d33dff37d2afa89c6e2d6fe02ab30629 rename to style-transform-master/style-transform-master/public/uploads/2e407fd9b3b3fdc4d7ad5a13412cd8db diff --git a/style-transform-master/style-transform-master/public/uploads/3ed849750c8f69c94a258ac4693effd4 b/style-transform-master/style-transform-master/public/uploads/3ed849750c8f69c94a258ac4693effd4 new file mode 100644 index 0000000..e9fce34 Binary files /dev/null and b/style-transform-master/style-transform-master/public/uploads/3ed849750c8f69c94a258ac4693effd4 differ diff --git a/style-transform-master/style-transform-master/public/uploads/42865e3c51f5f0dffd452d6c6edace0c b/style-transform-master/style-transform-master/public/uploads/42865e3c51f5f0dffd452d6c6edace0c new file mode 100644 index 0000000..dd27b85 Binary files /dev/null and b/style-transform-master/style-transform-master/public/uploads/42865e3c51f5f0dffd452d6c6edace0c differ diff --git a/style-transform-master/style-transform-master/run_main.py b/style-transform-master/style-transform-master/run_main.py index 312af24..cb41857 100644 --- a/style-transform-master/style-transform-master/run_main.py +++ b/style-transform-master/style-transform-master/run_main.py @@ -160,4 +160,3 @@ def main(): if __name__ == '__main__': main() - print('#') diff --git a/style-transform-master/style-transform-master/server.js b/style-transform-master/style-transform-master/server.js index ce92236..adbc591 100644 --- a/style-transform-master/style-transform-master/server.js +++ b/style-transform-master/style-transform-master/server.js @@ -23,20 +23,28 @@ server.get('/', function (req, res) { res.end(fs.readFileSync("./html/index.html")) }); -var upload = multer({ dest: 'uploads/' }); +var upload = multer({ dest: 'public/uploads/' }); var progress = {}; +var relationfile = {}; 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(max_epoch); + 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'); - - let child = exec(`python run_main.py --content ./uploads/${req.files.content_image[0].filename} --style ./uploads/${req.files.style_image[0].filename} --output ./uploads/${taskID}.jpg --num_iter ${max_epoch}`); + console.log(taskID + " start!"); + + relationfile[taskID] = {content: req.files.content_image[0].filename, style: req.files.style_image[0].filename}; + + let child = exec(`python run_main.py --content ./public/uploads/${req.files.content_image[0].filename} --style ./public/uploads/${req.files.style_image[0].filename} --output ./public/uploads/${taskID}.jpg --num_iter ${max_epoch}`); //console.log(`python run_main.py --content ./uploads/${req.files.content_image[0].filename} --style ./uploads/${req.files.style_image[0].filename} --output ./uploads/${taskID}.jpg --num_iter ${max_epoch}`); progress[taskID] = {percentage: 0, max_epoch: parseInt(max_epoch), status: 0}; @@ -66,7 +74,12 @@ server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 }, }); child.on("close", (code) => { - progress[taskID].status = 1; + if (code == 0) { + progress[taskID].status = 1; + } else { + progress[taskID].status = -1; + } + console.log(taskID + " done!"); }); let $ = cheerio.load(fs.readFileSync("./html/generate.html")); @@ -79,18 +92,24 @@ server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 }, server.get('/success', function (req, res) { let taskID = req.query.taskID; + + let $ = cheerio.load(fs.readFileSync("./html/success.html")); + + $('img[name="content"]').attr("src", `uploads/${relationfile[taskID].content}`); + $('img[name="style"]').attr("src", `uploads/${relationfile[taskID].style}`); + $('img[name="output"]').attr("src", `uploads/${taskID}.jpg`); - res.end(); + res.writeHead(200, { 'Content-type': 'text/html' }); + res.end($.html()); +}); - //let $ = cheerio.load(fs.readFileSync("./html/success.html")); +server.get('/fail', function (req, res) { - //res.end($.html); }); server.get('/progress', function (req, res) { if(req.query.taskID) { res.json(progress[req.query.taskID]); - //console.log(progress[req.query.taskID]); } }); 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 0519241..b7ab7f5 100644 --- a/style-transform-master/style-transform-master/style-transform-master.njsproj +++ b/style-transform-master/style-transform-master/style-transform-master.njsproj @@ -28,9 +28,168 @@ true + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +