osanseviero HF staff commited on
Commit
0fb3f0b
1 Parent(s): 71a8430

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +4 -2
pipeline.py CHANGED
@@ -2,6 +2,7 @@ import torch
2
  import torch.nn as nn
3
  from huggingface_hub import PyTorchModelHubMixin
4
  from PIL import Image
 
5
 
6
  class Generator(nn.Module, PyTorchModelHubMixin):
7
  def __init__(self, num_channels=3, latent_dim=100, hidden_size=64):
@@ -56,5 +57,6 @@ class PreTrainedPipeline():
56
  output = self.model(noise)
57
 
58
  # Scale image
59
- img = Image.fromarray(output)
60
- return img
 
 
2
  import torch.nn as nn
3
  from huggingface_hub import PyTorchModelHubMixin
4
  from PIL import Image
5
+ from torchvision import transforms
6
 
7
  class Generator(nn.Module, PyTorchModelHubMixin):
8
  def __init__(self, num_channels=3, latent_dim=100, hidden_size=64):
 
57
  output = self.model(noise)
58
 
59
  # Scale image
60
+ img = output[0]
61
+ img = (img + 1) /2
62
+ return transforms.ToPILImage()(img)