利用已经训练好的神经网络模型, 基于微信开发平台, 实现几个有趣的图像应用.
类似前一段流行的应用Prisma,主要实现两个功能:
| ## TCP Server 数据传输规范 | |
| [TOC] | |
| -------- | |
|  | |
| 本文档主要功能是设立TCP server 和web server , TCP server 与灯杆客户端之间的数据通信规范. | |
| 1. 所有传输的json数据必须采用压缩, 即把数据合并成一行, 下面给出的例子可能是多行的, 但是发送的时候必须是一行的 | |
| 2. 每次发送的json数据的长度不能超过4096个字符, 并应尽量避免使用中文等非ascii字符, key字段中不能有特殊字符和空白字符, 如回车空格等. |
| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(data)) | |
| data_size, vocab_size = len(data), len(chars) |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.parallel | |
| class DCGAN_D(nn.Container): | |
| def __init__(self, isize, nz, nc, ndf, ngpu, n_extra_layers=0): | |
| super(DCGAN_D, self).__init__() | |
| self.ngpu = ngpu | |
| assert isize % 16 == 0, "isize has to be a multiple of 16" |
| # Enter your network definition here. | |
| # Use Shift+Enter to update the visualization. | |
| name: "VGG_ILSVRC_16_layers" | |
| layer { | |
| name: 'input-data' | |
| type: 'Python' | |
| top: 'data' | |
| top: 'im_info' | |
| top: 'gt_boxes' | |
| python_param { |
| name: "DSOD300_VOC0712_train" | |
| layer { | |
| name: "data" | |
| type: "Data" | |
| top: "data" | |
| top: "label" | |
| include { | |
| phase: TRAIN | |
| } | |
| transform_param { |
| # Enter your network definition here. | |
| # Use Shift+Enter to update the visualization | |
| name: "VGG_VOC0712Plus_SSD_300x300_train" | |
| layer { | |
| name: "data" | |
| type: "AnnotatedData" | |
| top: "data" | |
| top: "label" |