-
大小: 6.45MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-11-18
- 语言: Python
- 标签:
资源简介
汉字的神经风格转移(Neural Style Transfer)实现
代码片段和文件信息
# -*- coding: utf-8 -*-
import numpy as np
def read_font_data(font unit_scale):
F = np.load(font)
if unit_scale:
return F / 255.
return F
class FontDataProvider(object):
def __init__(self font start end):
self.start = start
self.end = end
self.data = np.copy(font[start: end])
self.cursor = 0
self.length = self.end - self.start
def get_data(self):
return self.data
def next_batch(self batch_size):
if self.cursor >= self.length:
self.cursor = 0
batch_start = self.cursor
batch_end = self.cursor + batch_size
self.cursor += batch_size
return self.data[batch_start: batch_end]
class FontDataManager(object):
def __init__(self src target total split_point unit_scale=True shuffle=False):
src_data = read_font_data(src unit_scale)
target_data = read_font_data(target unit_scale)
if shuffle:
perm = np.arange(src_data.shape[0])
np.random.shuffle(perm)
src_data = src_data[perm]
target_data = target_data[perm]
self.train_source = FontDataProvider(src_data 0 split_point)
self.validation_source = FontDataProvider(src_data split_point total)
self.train_target = FontDataProvider(target_data 0 split_point)
self.validation_target = FontDataProvider(target_data split_point total)
def next_train_batch(self batch_size):
if self.train_source.cursor >= self.train_source.length:
# random shuffle the training examples
# otherwise the model‘s performance fluctuate periodically
perm = np.arange(self.train_source.length)
np.random.shuffle(perm)
self.train_source.data = self.train_source.data[perm]
self.train_target.data = self.train_target.data[perm]
return self.train_source.next_batch(batch_size) self.train_target.next_batch(batch_size)
def get_validation(self):
return self.validation_source.get_data() \
self.validation_target.get_data()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-07 08:29 Rewrite-master\
文件 28 2017-04-07 08:29 Rewrite-master\.gitignore
文件 35140 2017-04-07 08:29 Rewrite-master\LICENSE
文件 14305 2017-04-07 08:29 Rewrite-master\README.md
目录 0 2017-04-07 08:29 Rewrite-master\charsets\
文件 106446 2017-04-07 08:29 Rewrite-master\charsets\gbk.txt
文件 11976 2017-04-07 08:29 Rewrite-master\charsets\top_3000_simplified.txt
文件 11976 2017-04-07 08:29 Rewrite-master\charsets\top_3000_traditional.txt
文件 2128 2017-04-07 08:29 Rewrite-master\dataset.py
目录 0 2017-04-07 08:29 Rewrite-master\images\
文件 26916 2017-04-07 08:29 Rewrite-master\images\architecture.png
文件 1486293 2017-04-07 08:29 Rewrite-master\images\bigger_test.png
文件 20260 2017-04-07 08:29 Rewrite-master\images\box_for_ideas.png
文件 47517 2017-04-07 08:29 Rewrite-master\images\different_training_size.png
文件 2887427 2017-04-07 08:29 Rewrite-master\images\mixed_font.gif
文件 93045 2017-04-07 08:29 Rewrite-master\images\predicted_vs_ground_truth.png
文件 2406995 2017-04-07 08:29 Rewrite-master\images\single_font_progress.gif
文件 28320 2017-04-07 08:29 Rewrite-master\images\structure.png
文件 3605 2017-04-07 08:29 Rewrite-master\preprocess.py
文件 54 2017-04-07 08:29 Rewrite-master\requirements.txt
文件 15763 2017-04-07 08:29 Rewrite-master\rewrite.py
文件 901 2017-04-07 08:29 Rewrite-master\utils.py
相关资源
- Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-STGAN用于图像合成的空间变换生
- Python-利用GAN进行图片填充
- Python-基于50W携程出行攻略的顺承事件
- Python-在TensorFlow中实现实现图像卷积网
- Python-60DaysRLChallenge中文版强化学习6
- Python-一个非常简单的BiLSTMCRF模型用于
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- Python-我是小诗姬全唐诗作为训练数据
- Python-用于物体跟踪的全卷积连体网络
- Python-数学建模竞赛中所使用的相关算
- Python-MonoDepthPyTorchPyTorch无监督单目深
- Python-用Tensorflowjs实现的可回收非可回
- Python-利用TensorFlow中的深度学习进行图
- Python-TensorFlow快速入门与实战课件与参
- Python-FCN完全卷积网络中最简单最容易
- Python-匈牙利算法卡尔曼滤波器多目标
- Python-mathAI一个拍照做题程序输入一张
- Python-Tensorflow实现SpatialAsDeepSpatialCNN
- Python-图像分类目标检测姿态估计分割
- Python-用python3opencv3做的中国车牌识别
- Python-各种对抗神经网络GAN大合集
- Python-Intel开源增强学习框架Coach
- Python-CENet用于2D医学图像分割的上下文
- Python-基于深度神经网络和蒙特卡罗树
- Python-SPNLearningAffinityviaSpatialPropagatio
- Python-效果超赞的图片自动增强GANs非成
评论
共有 条评论