Browse Source

'更新generate页面及其后端代码,更新算法代码,改善交互方法'

master
刘冬煜 4 years ago
parent
commit
8fa0a91783
15 changed files with 98 additions and 9 deletions
  1. BIN
      style-transform-master/.vs/style-transform-master/v16/.suo
  2. BIN
      style-transform-master/style-transform-master/__pycache__/style_transfer.cpython-37.pyc
  3. BIN
      style-transform-master/style-transform-master/__pycache__/utils.cpython-37.pyc
  4. BIN
      style-transform-master/style-transform-master/__pycache__/vgg19.cpython-37.pyc
  5. +55
    -0
      style-transform-master/style-transform-master/log.txt
  6. BIN
      style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache
  7. +3
    -0
      style-transform-master/style-transform-master/public/js/generate.js
  8. +1
    -0
      style-transform-master/style-transform-master/run_main.py
  9. BIN
      style-transform-master/style-transform-master/sample/content.jpg
  10. BIN
      style-transform-master/style-transform-master/sample/style.jpg
  11. +35
    -8
      style-transform-master/style-transform-master/server.js
  12. +4
    -1
      style-transform-master/style-transform-master/style_transfer.py
  13. BIN
      style-transform-master/style-transform-master/uploads/176ad444b5f5c0a88a6ae3a097a6378420bde09ba2f.jpg
  14. BIN
      style-transform-master/style-transform-master/uploads/3bfb7ded24712cf0b36ad149fea96495
  15. BIN
      style-transform-master/style-transform-master/uploads/d33dff37d2afa89c6e2d6fe02ab30629

BIN
style-transform-master/.vs/style-transform-master/v16/.suo View File


BIN
style-transform-master/style-transform-master/__pycache__/style_transfer.cpython-37.pyc View File


BIN
style-transform-master/style-transform-master/__pycache__/utils.cpython-37.pyc View File


BIN
style-transform-master/style-transform-master/__pycache__/vgg19.cpython-37.pyc View File


+ 55
- 0
style-transform-master/style-transform-master/log.txt View File

@ -0,0 +1,55 @@
2020-12-29 14:36:30.283768: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
WARNING:tensorflow:From run_main.py:132: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.
WARNING:tensorflow:From run_main.py:132: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.
2020-12-29 14:36:36.888456: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-12-29 14:36:36.892814: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-12-29 14:36:37.709410: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:
name: GeForce MX250 major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:01:00.0
2020-12-29 14:36:37.710155: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
2020-12-29 14:36:37.722270: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll
2020-12-29 14:36:37.737230: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll
2020-12-29 14:36:37.740592: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll
2020-12-29 14:36:37.759094: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll
2020-12-29 14:36:37.766716: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll
2020-12-29 14:36:37.813905: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-12-29 14:36:37.814732: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
2020-12-29 14:36:39.718835: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-12-29 14:36:39.719383: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0
2020-12-29 14:36:39.719713: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N
2020-12-29 14:36:39.720511: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1356 MB memory) -> physical GPU (device: 0, name: GeForce MX250, pci bus id: 0000:01:00.0, compute capability: 6.1)
WARNING:tensorflow:From C:\作业\云计算\大作业\style-transform-master\style-transform-master\style-transform-master\style_transfer.py:37: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
WARNING:tensorflow:From C:\作业\云计算\大作业\style-transform-master\style-transform-master\style-transform-master\vgg19.py:59: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
WARNING:tensorflow:From C:\作业\云计算\大作业\style-transform-master\style-transform-master\style-transform-master\vgg19.py:17: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
* https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.
WARNING:tensorflow:From C:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\math_grad.py:1375: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
WARNING:tensorflow:From C:\作业\云计算\大作业\style-transform-master\style-transform-master\style-transform-master\style_transfer.py:119: The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead.
2020-12-29 14:36:49.216170: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll
2020-12-29 14:36:49.433049: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-12-29 14:36:50.179655: W tensorflow/stream_executor/cuda/redzone_allocator.cc:312] Internal: Invoking ptxas not supported on Windows
Relying on driver to perform ptx compilation. This message will be only logged once.
2020-12-29 14:36:50.315636: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.78GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:50.481255: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.78GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:50.483997: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.78GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:50.666630: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 448.00MiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.192897: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.39GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.198264: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.39GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.199605: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.39GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.637253: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.28GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.640887: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.28GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-12-29 14:36:51.643025: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.28GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.

BIN
style-transform-master/style-transform-master/obj/Debug/style-transform-master.njsprojAssemblyReference.cache View File


+ 3
- 0
style-transform-master/style-transform-master/public/js/generate.js View File

@ -5,5 +5,8 @@ function getProgress(taskID) {
dataType: 'json'
}).done(function(data) {
$('#progress').html(data.percentage);
if(data.status == 1) {
window.location.replace('./success');
}
});
}

+ 1
- 0
style-transform-master/style-transform-master/run_main.py View File

@ -160,3 +160,4 @@ def main():
if __name__ == '__main__':
main()
print('#')

BIN
style-transform-master/style-transform-master/sample/content.jpg View File

Before After
Width: 680  |  Height: 510  |  Size: 93 KiB

BIN
style-transform-master/style-transform-master/sample/style.jpg View File

Before After
Width: 300  |  Height: 312  |  Size: 23 KiB

+ 35
- 8
style-transform-master/style-transform-master/server.js View File

@ -36,17 +36,42 @@ server.post('/generate', upload.fields([{ name: 'content_image', maxCount: 1 },
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 ${req.files.content_image[0].filename} --style ${req.files.style_image[0].filename} --output ${taskID}.jpg --num_iter ${max_epoch}`);
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(`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};
progress[taskID] = {percentage: 0, max_epoch: parseInt(max_epoch), status: 0};
child.stdout.on("data", function (data) {
progress[taskID] = data;
console.log(taskID + ": " + data);
let args = data.split(' ');
let signal = args[0];
if (signal != '$') {
return;
}
let iter = parseInt(args[1]);
let totalLoss = parseFloat(args[2]);
let ContentLoss = parseFloat(args[3]);
let StyleLoss = parseFloat(args[4]);
let percentage = iter * 100 / progress[taskID].max_epoch;
if (percentage > 100) {
percentage = 100;
}
progress[taskID].percentage = percentage;
progress[taskID].iter = iter;
progress[taskID].totalLoss = totalLoss;
progress[taskID].ContentLoss = ContentLoss;
progress[taskID].StyleLoss = StyleLoss;
//console.log(taskID + ": " + args);
});
child.on("close", (code) => {
progress[taskID].status = 1;
});
let $ = cheerio.load(fs.readFileSync("./html/generate.html"));
$('script[name="go"]').html(`setInterval(function() {getProgress("${taskID}");}, 5000);`);
$('script[name="go"]').html(`setInterval(function() {getProgress("${taskID}");}, 2000);`);
res.writeHead(200, { 'Content-type': 'text/html' });
res.end($.html());
@ -55,15 +80,17 @@ 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"));
res.end();
//let $ = cheerio.load(fs.readFileSync("./html/success.html"));
res.end($.html);
//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]);
//console.log(progress[req.query.taskID]);
}
});

+ 4
- 1
style-transform-master/style-transform-master/style_transfer.py View File

@ -1,6 +1,7 @@
import tensorflow as tf
import numpy as np
import collections
import sys
class StyleTransfer:
@ -108,7 +109,9 @@ class StyleTransfer:
_iter = 0
def callback(tl, cl, sl):
global _iter
print('iter : %4d, ' % _iter, 'L_total : %g, L_content : %g, L_style : %g' % (tl, cl, sl))
#print('%d, L_total: %g, L_content: %g, L_style: %g' % (_iter, tl, cl, sl))
print('$', _iter, tl, cl, sl)
sys.stdout.flush()
_iter += 1
optimizer = tf.contrib.opt.ScipyOptimizerInterface(self.L_total, method='L-BFGS-B', options={'maxiter': self.num_iter})

BIN
style-transform-master/style-transform-master/uploads/176ad444b5f5c0a88a6ae3a097a6378420bde09ba2f.jpg View File

Before After
Width: 512  |  Height: 384  |  Size: 45 KiB

BIN
style-transform-master/style-transform-master/uploads/3bfb7ded24712cf0b36ad149fea96495 View File

Before After
Width: 300  |  Height: 312  |  Size: 23 KiB

BIN
style-transform-master/style-transform-master/uploads/d33dff37d2afa89c6e2d6fe02ab30629 View File

Before After
Width: 680  |  Height: 510  |  Size: 93 KiB

Loading…
Cancel
Save