miittnnss commited on
Commit
27bd635
·
1 Parent(s): c596729

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +25 -1
pipeline.py CHANGED
@@ -29,4 +29,28 @@ class Generator(nn.Module, PyTorchModelHubMixin):
29
  )
30
 
31
  def forward(self, input):
32
- return self.main(input)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.model = 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)