osanseviero
commited on
Commit
·
e225449
1
Parent(s):
b201cc3
Update pipeline.py
Browse files- pipeline.py +6 -1
pipeline.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import torch
|
2 |
import nltk
|
|
|
3 |
|
4 |
from torchvision import transforms
|
5 |
from pytorch_pretrained_biggan import BigGAN, one_hot_from_names, truncated_noise_sample
|
@@ -34,4 +35,8 @@ class PreTrainedPipeline():
|
|
34 |
with torch.no_grad():
|
35 |
output = self.model(noise_vector, class_vector, self.truncation)
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import torch
|
2 |
import nltk
|
3 |
+
import io
|
4 |
|
5 |
from torchvision import transforms
|
6 |
from pytorch_pretrained_biggan import BigGAN, one_hot_from_names, truncated_noise_sample
|
|
|
35 |
with torch.no_grad():
|
36 |
output = self.model(noise_vector, class_vector, self.truncation)
|
37 |
|
38 |
+
img = transforms.ToPILImage()(output[0])
|
39 |
+
buf = io.BytesIO()
|
40 |
+
img.save(buf, format="JPEG")
|
41 |
+
|
42 |
+
return buf.getvalue()return transforms.ToPILImage()(output[0]).tobytes().decode('utf-8')
|