-
大小: 1.31MB文件类型: .zip金币: 2下载: 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-DeepMoji模型的pyTorch实现
- Python-使用DeepFakes实现YouTube视频自动换
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- Python-自然场景文本检测PSENet的一个
- Python-在特征金字塔网络FPN的Pytorch实现
- Python-PyTorch实时多人姿态估计项目的实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-心脏核磁共振MRI图像分割
- Python-基于YOLOv3的行人检测
- Python-RLSeq2Seq用于SequencetoSequence模型的
- Python-PyTorch对卷积CRF的参考实现
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
- Python-UNet用于医学图像分割的嵌套UN
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-Keras实现Inceptionv4InceptionResnetv1和
- Python-pytorch中文手册
- Python-FastSCNN的PyTorch实现快速语义分割
- Python-滑动窗口高分辨率显微镜图像分
- Python-使用MovieLens数据集训练的电影推
- Python-机器学习驱动的Web应用程序防火
- Python-subpixel利用Tensorflow的一个子像素
-
Python-汉字的神经风格转移Neuralst
y - Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-利用GAN进行图片填充
评论
共有 条评论