miittnnss commited on
Commit
0158987
·
1 Parent(s): 1e65589

Delete pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +0 -56
pipeline.py DELETED
@@ -1,56 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
- from torchvision import transforms
4
- from PIL import Image
5
- from huggingface_hub import PyTorchModelHubMixin
6
-
7
- class Generator(nn.Module, PyTorchModelHubMixin):
8
- def __init__(self):
9
- super(Generator, self).__init__()
10
- self.main = nn.Sequential(
11
- nn.ConvTranspose2d(100, 64 * 8, 4, 1, 0, bias=False),
12
- nn.BatchNorm2d(64 * 8),
13
- nn.ReLU(True),
14
-
15
- nn.ConvTranspose2d(64 * 8, 64 * 4, 4, 2, 1, bias=False),
16
- nn.BatchNorm2d(64 * 4),
17
- nn.ReLU(True),
18
-
19
- nn.ConvTranspose2d(64 * 4, 64 * 2, 4, 2, 1, bias=False),
20
- nn.BatchNorm2d(64 * 2),
21
- nn.ReLU(True),
22
-
23
- nn.ConvTranspose2d(64 * 2, 64, 4, 2, 1, bias=False),
24
- nn.BatchNorm2d(64),
25
- nn.ReLU(True),
26
-
27
- nn.ConvTranspose2d(64, 3, 4, 2, 1, bias=False),
28
- nn.Tanh()
29
- )
30
-
31
- def forward(self, input):
32
- return self.main(input)
33
-
34
- class PreTrainedPipeline():
35
- def __init__(self, path=""):
36
- """
37
- Initialize model
38
- """
39
- self.main = model = Generator.from_pretrained("miittnnss/testmodel")
40
-
41
- def __call__(self, inputs: str):
42
- """
43
- Args:
44
- inputs (:obj:`str`):
45
- a string containing some text
46
- Return:
47
- A :obj:`PIL.Image` with the raw image representation as PIL.
48
- """
49
- noise = torch.randn(1, 100, 1, 1)
50
- with torch.no_grad():
51
- output = self.model(noise)
52
-
53
- # Scale image
54
- img = output[0]
55
- img = (img + 1) /2
56
- return transforms.ToPILImage()(img)