由文本生成人臉圖像——T2F
T2F 結合了最近的兩個架構 StackGAN 和 ProGAN,用於從文本描述中合成面部,該項目使用 Face2Text 數據集,每個數據集包含 400 個圖像和文字說明。 數據包含在 data / LFW / Face2Text / face2text_v0.1 目錄下的存儲庫中。
Github 鏈接:
https://github.com/akanimax/T2F
一些樣例
結構
LSTM 網路能夠將文本描述編碼為摘要向量,圖中所示的嵌入(psy_t)通過調節增強塊(單個線性層)以獲得 GAN 作為輸入的潛在向量的文本部分(使用類似重新參數化技術的VAE)。潛在向量的第二部分是隨機高斯雜訊。這樣產生的潛在矢量被饋送到GAN的發生器部分,而嵌入被饋送到鑒別器的最後一層用於條件分布匹配。 GAN 的訓練完全按照 ProGAN 論文的說明進行,即在增加的空間解析度下逐層訓練。使用淡入技術引入新層以避免破壞先前的學習。
運行代碼
代碼存在於 implementation/ 子目錄中,該實現已經用 PyTorch 完成。因此,為了運行此代碼,請安裝 PyTorch 0.4.0。
代碼結構
configs:包含訓練網路的配置文件。 (你可以使用任何一個,或者創建你自己的)
data_processing:包含數據處理和載入模塊的包
networks:包含網路實現
processed_annotations:目錄存儲運行process_text_annotations.py腳本的輸出
process_text_annotations.py:處理標題並將輸出存儲在processed_annotations /目錄中。
train_network.py:用於運行網路訓練的腳本
樣本配置
# All paths to different required data objects
images_dir:"../data/LFW/lfw"
processed_text_file:"processed_annotations/processed_text.pkl"
log_dir:"training_runs/11/losses/"
sample_dir:"training_runs/11/generated_samples/"
save_dir:"training_runs/11/saved_models/"
# Hyperparameters for the Model
captions_length:100
img_dims:
-64
-64
# LSTM hyperparameters
embedding_size:128
hidden_size:256
num_layers:3# number of LSTM cells in the encoder network
# Conditioning Augmentation hyperparameters
ca_out_size:178
# Pro GAN hyperparameters
depth:5
latent_size:256
learning_rate:0.001
beta_1:
beta_2:
eps:0.00000001
drift:0.001
n_critic:1
# Training hyperparameters:
epochs:
-160
-80
-40
-20
-10
# % of epochs for fading in the new layer
fade_in_percentage:
-85
-85
-85
-85
-85
batch_sizes:
-16
-16
-16
-16
-16
num_workers:3
feedback_factor:7# number of logs generated per epoch
checkpoint_factor:2# save the models after these many epochs
use_matching_aware_discriminator:True# use the matching aware discriminator
使用 requirements.txt 安裝該項目所有的依賴。
$workon [your virtual environment]
$pip install -r requirements.txt
樣例運行:
$mkdir training_runs
$mkdir training_runs/generated_samples training_runs/losses training_runs/saved_models
$train_network.py --config=configs/11.comf
深度解析LSTM神經網路的設計原理
※王強:站在人工智慧與金融 IT 最頂端的人
※美圖邀你挑戰短視頻分類極限,26 萬獎金池等你瓜分
TAG:AI研習社 |