Skip to content

Commit 6abdc70

Browse files
authored
Merge pull request #142 from intel/update-branch
Update gitignore to only ignore root data folder (#381)
2 parents 0afce27 + 7280add commit 6abdc70

File tree

12 files changed

+118
-1
lines changed

12 files changed

+118
-1
lines changed

usecases/ai/digital-avatar/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ backend/wav2lip/wav2lip/temp
1111
assets/*
1212
weights/*
1313
backend/liveportrait/templates
14-
data/
14+
/data/*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .image import get_image
2+
from .pickle_object import get_object
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import cv2
2+
import os
3+
import os.path as osp
4+
from pathlib import Path
5+
6+
class ImageCache:
7+
data = {}
8+
9+
def get_image(name, to_rgb=False):
10+
key = (name, to_rgb)
11+
if key in ImageCache.data:
12+
return ImageCache.data[key]
13+
images_dir = osp.join(Path(__file__).parent.absolute(), 'images')
14+
ext_names = ['.jpg', '.png', '.jpeg']
15+
image_file = None
16+
for ext_name in ext_names:
17+
_image_file = osp.join(images_dir, "%s%s"%(name, ext_name))
18+
if osp.exists(_image_file):
19+
image_file = _image_file
20+
break
21+
assert image_file is not None, '%s not found'%name
22+
img = cv2.imread(image_file)
23+
if to_rgb:
24+
img = img[:,:,::-1]
25+
ImageCache.data[key] = img
26+
return img
27+
11.8 KB
Loading
20.8 KB
Loading
43.7 KB
Loading
5.97 KB
Loading
77.1 KB
Loading
126 KB
Loading

0 commit comments

Comments
 (0)