Raziel1234 commited on
Commit
f66a0cd
verified
1 Parent(s): a04bf46

Update modeling_pixel.py

Browse files
Files changed (1) hide show
  1. modeling_pixel.py +8 -8
modeling_pixel.py CHANGED
@@ -1,7 +1,7 @@
1
  import torch
2
  import torch.nn as nn
3
  from transformers import PreTrainedModel
4
- from .configuration_pixel import PixelConfig
5
 
6
  class ResidualBlock(nn.Module):
7
  def __init__(self, channels):
@@ -16,21 +16,21 @@ class ResidualBlock(nn.Module):
16
  def forward(self, x):
17
  return x + self.block(x)
18
 
19
- class PixelGenerator(PreTrainedModel):
20
- config_class = PixelConfig
21
 
22
  def __init__(self, config):
23
  super().__init__(config)
24
  self.text_projection = nn.Linear(config.input_dim, 4 * 4 * 1024)
25
 
26
  self.decoder = nn.Sequential(
27
- self._upsample(1024, 512), # 4x4 -> 8x8
28
  ResidualBlock(512),
29
- self._upsample(512, 256), # 8x8 -> 16x16
30
  ResidualBlock(256),
31
- self._upsample(256, 128), # 16x16 -> 32x32
32
- self._upsample(128, 64), # 32x32 -> 64x64
33
- self._upsample(64, 32), # 64x64 -> 128x128
34
  nn.Conv2d(32, config.image_channels, kernel_size=3, padding=1),
35
  nn.Tanh()
36
  )
 
1
  import torch
2
  import torch.nn as nn
3
  from transformers import PreTrainedModel
4
+ from .configuration_pixel import TopAIImageConfig # 转讬拽讜谉 讛砖诐 讻讗谉
5
 
6
  class ResidualBlock(nn.Module):
7
  def __init__(self, channels):
 
16
  def forward(self, x):
17
  return x + self.block(x)
18
 
19
+ class TopAIImageGenerator(PreTrainedModel):
20
+ config_class = TopAIImageConfig
21
 
22
  def __init__(self, config):
23
  super().__init__(config)
24
  self.text_projection = nn.Linear(config.input_dim, 4 * 4 * 1024)
25
 
26
  self.decoder = nn.Sequential(
27
+ self._upsample(1024, 512),
28
  ResidualBlock(512),
29
+ self._upsample(512, 256),
30
  ResidualBlock(256),
31
+ self._upsample(256, 128),
32
+ self._upsample(128, 64),
33
+ self._upsample(64, 32),
34
  nn.Conv2d(32, config.image_channels, kernel_size=3, padding=1),
35
  nn.Tanh()
36
  )