-
大小: 1.31MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-10-04
- 语言: Python
- 标签:
资源简介
ST-GAN: 用于图像合成的空间变换生成对抗网络 (CVPR 2018)
代码片段和文件信息
import numpy as np
import tensorflow as tf
import ostime
import warp
# load data
def load(opttest=False):
path = “dataset“
if test:
images = np.load(“{0}/image_test.npy“.format(path))
hasGlasses = np.load(“{0}/attribute_test.npy“.format(path))[:15]
else:
images = np.load(“{0}/image_train.npy“.format(path))
hasGlasses = np.load(“{0}/attribute_train.npy“.format(path))[:15]
images_0 = images[~hasGlasses]
images_1 = images[hasGlasses]
glasses = np.load(“{0}/glasses.npy“.format(path))
D = {
“image0“: images_0
“image1“: images_1
“glasses“: glasses
}
return D
# make training batch
def makeBatch(optdataPH):
N0 = len(data[“image0“])
N1 = len(data[“image1“])
NG = len(data[“glasses“])
randIdx0 = np.random.randint(N0size=[opt.batchSize])
randIdx1 = np.random.randint(N1size=[opt.batchSize])
randIdxG = np.random.randint(NGsize=[opt.batchSize])
# put data in placeholders
[imageBGfakeDataimageRealDataimageFGfake] = PH
batch = {
imageBGfakeData: data[“image0“][randIdx0]/255.0
imageRealData: data[“image1“][randIdx1]/255.0
imageFGfake: data[“glasses“][randIdxG]/255.0
}
return batch
# make test batch
def makeBatchEval(opttestImageglassesPH):
idxG = np.arange(opt.batchSize)
# put data in placeholders
[imageBGimageFG] = PH
batch = {
imageBG: np.tile(testImage[opt.batchSize111])
imageFG: glasses[idxG]/255.0
}
return batch
# generate perturbed image
def perturbBG(optimageData):
rot = opt.pertBG*tf.random_normal([opt.batchSize])
tx = opt.pertBG*tf.random_normal([opt.batchSize])
ty = opt.pertBG*tf.random_normal([opt.batchSize])
O = tf.zeros([opt.batchSize])
pPertBG = tf.stack([txrotOOty-rotOO]axis=1) if opt.warpType==“homography“ else \
tf.stack([Orottx-rotOty]axis=1) if opt.warpType==“affine“ else None
pPertBGmtrx = warp.vec2mtrx(optpPertBG)
image = warp.transformCropImage(optimageDatapPertBGmtrx)
return image
history = [None0True]
# update history and group fake samples
def updateHistory(optnewFake):
if history[0] is None:
history[0] = np.ones([opt.histQsizeopt.Hopt.W3]dtype=np.float32)
history[0][:opt.batchSize] = newFake
history[1] = opt.batchSize
return newFake
else:
randIdx = np.random.permutation(opt.batchSize)
storeIdx = randIdx[:opt.histSize]
useIdx = randIdx[opt.histSize:]
# group fake samples
higrowing = history[1]history[2]
extractIdx = np.random.permutation(hi if growing else opt.histQsize)[:opt.histSize]
groupFake = np.concatenate([history[0][extractIdx]newFake[useIdx]]axis=0)
hinew = hi+opt.batchSize-opt.histSize
history[0][hi:hinew] = newFake[storeIdx]
history[1] = hinew
if hinew==opt.histQsize:
history[1] = 0
history[2] = False
return groupFake
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-10 19:31 spatial-transformer-GAN-master\
文件 170 2019-04-10 19:31 spatial-transformer-GAN-master\.editorconfig
文件 1157 2019-04-10 19:31 spatial-transformer-GAN-master\.gitignore
文件 1071 2019-04-10 19:31 spatial-transformer-GAN-master\LICENSE
文件 3945 2019-04-10 19:31 spatial-transformer-GAN-master\README.md
文件 1265720 2019-04-10 19:31 spatial-transformer-GAN-master\cover.png
目录 0 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\
文件 2746 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\data.py
目录 0 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\dataset\
文件 32011 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\dataset\example_test.png
文件 829536 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\dataset\glasses.npy
文件 2352 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\eval_STGAN.py
文件 4177 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\graph.py
文件 5263 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\options.py
文件 1195 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\preprocess_celebA.py
文件 100 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\test.sh
文件 144 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\train.sh
文件 5615 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\train_Donly.py
文件 7863 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\train_STGAN.py
文件 1788 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\util.py
文件 6108 2019-04-10 19:31 spatial-transformer-GAN-master\glasses\warp.py
目录 0 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\
文件 6009 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\data.py
文件 2352 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\eval_STGAN.py
文件 4179 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\graph.py
文件 4580 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\options.py
文件 4685 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\pretrain_homo.py
目录 0 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\render\
文件 0 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\render\README.md
文件 63 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\test.sh
文件 167 2019-04-10 19:31 spatial-transformer-GAN-master\indoor\train.sh
............此处省略3个文件信息
相关资源
- 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非成
- Python-VoiceactivitydetectionVAD语音端点检测
- Python-TensorFlow实现的人脸性别年龄识别
- Python-waifu2x利用卷积神经网络放大图片
- Python-TheElementsofStatisticalLearningESL的中
- Python-基于Tensorflow和Keras实现端到端的
评论
共有 条评论