now completely OpenAI CLIP compatible for training

This commit is contained in:
Phil Wang
2022-04-29 11:26:24 -07:00
parent f4a54e475e
commit 39d3659ad9
5 changed files with 187 additions and 23 deletions

View File

@@ -2,15 +2,6 @@ import copy
import torch
from torch import nn
# image related normalizations
# ddpms expect images to be in the range of -1 to 1
def normalize_img(img):
return img * 2 - 1
def unnormalize_img(normed_img):
return (normed_img + 1) * 0.5
# exponential moving average wrapper
class EMA(nn.Module):