Spaces:
Running
on
Zero
Running
on
Zero
Update demo.py
Browse files
demo.py
CHANGED
@@ -18,7 +18,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
18 |
trust_remote_code=True,
|
19 |
torch_dtype=torch.float16,
|
20 |
device_map={"": "cuda"},
|
21 |
-
revision="
|
22 |
)
|
23 |
|
24 |
|
@@ -103,6 +103,8 @@ def process_image(input_image):
|
|
103 |
|
104 |
# Get image encoding
|
105 |
enc_image = model.encode_image(pil_image)
|
|
|
|
|
106 |
|
107 |
# Detect faces
|
108 |
faces = model.detect(enc_image, "face")["objects"]
|
@@ -115,7 +117,10 @@ def process_image(input_image):
|
|
115 |
gaze_points = []
|
116 |
|
117 |
for face in faces:
|
118 |
-
gaze = model.detect_gaze(
|
|
|
|
|
|
|
119 |
|
120 |
if gaze is None:
|
121 |
continue
|
|
|
18 |
trust_remote_code=True,
|
19 |
torch_dtype=torch.float16,
|
20 |
device_map={"": "cuda"},
|
21 |
+
revision="56a3adeae60809e4269c544cde376feb20637ee0"
|
22 |
)
|
23 |
|
24 |
|
|
|
103 |
|
104 |
# Get image encoding
|
105 |
enc_image = model.encode_image(pil_image)
|
106 |
+
flipped_pil = image.copy().transpose(method=Image.FLIP_LEFT_RIGHT)
|
107 |
+
flip_enc_image = self.encode_image(flipped_pil)
|
108 |
|
109 |
# Detect faces
|
110 |
faces = model.detect(enc_image, "face")["objects"]
|
|
|
117 |
gaze_points = []
|
118 |
|
119 |
for face in faces:
|
120 |
+
gaze = model.detect_gaze(enc_image, face=face, unstable_settings={
|
121 |
+
"prioritize_accuracy": True,
|
122 |
+
"flip_enc_image": flip_enc_image
|
123 |
+
})["gaze"]
|
124 |
|
125 |
if gaze is None:
|
126 |
continue
|