Merge pull request #28 from interfect/torch-logical-cores

Use all logical cores in Torch mode
This commit is contained in:
kuprel 2022-06-28 22:57:02 -04:00 committed by GitHub
commit 0fe3e2d2b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,10 @@
import numpy
import os
from typing import Dict
from torch import LongTensor, FloatTensor
import torch
torch.set_grad_enabled(False)
torch.set_num_threads(os.cpu_count())
from .models.vqgan_detokenizer import VQGanDetokenizer
from .models.dalle_bart_encoder_torch import DalleBartEncoderTorch
@ -114,4 +116,3 @@ def detokenize_torch(image_tokens: LongTensor, is_torch: bool) -> numpy.ndarray:
image = detokenizer.forward(image_tokens).to(torch.uint8)
del detokenizer, params
return image.to('cpu').detach().numpy()