Update modeling_pixel.py
Browse files- 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
|
| 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
|
| 20 |
-
config_class =
|
| 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 |
)
|
|
|
|
| 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 |
)
|