Skip to content

Commit 787da06

Browse files
soteloJose Sotelovickianand
authored
Small fix to prevent issues when using a gpu. (#228)
* Small fix to prevent issues when using a gpu. * Relax the pytorch requirement to allow the 2.3.0 release --------- Co-authored-by: Jose Sotelo <jose@jdescript.com> Co-authored-by: Vicki Anand <vicki_anand@hotmail.com>
1 parent 8ee5326 commit 787da06

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

models/utils/detect_face.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@ def extract_face(img, box, image_size=160, margin=0, save_path=None):
373373
os.makedirs(os.path.dirname(save_path) + "/", exist_ok=True)
374374
save_img(face, save_path)
375375

376-
face = F.to_tensor(np.float32(face))
376+
if isinstance(face, np.ndarray) or isinstance(face, Image.Image):
377+
face = F.to_tensor(np.float32(face))
378+
elif isinstance(face, torch.Tensor):
379+
face = face.float()
380+
else:
381+
raise NotImplementedError
377382

378383
return face

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
'numpy>=1.24.0,<2.0.0',
4040
'Pillow>=10.2.0,<10.3.0',
4141
'requests>=2.0.0,<3.0.0',
42-
'torch>=2.2.0,<2.3.0',
43-
'torchvision>=0.17.0,<0.18.0',
42+
'torch>=2.2.0,<=2.3.0',
43+
'torchvision>=0.17.0,<=0.18.0',
4444
'tqdm>=4.0.0,<5.0.0',
4545
],
4646
)

0 commit comments

Comments
 (0)