vikhyatk commited on
Commit
c362437
·
verified ·
1 Parent(s): 3e0b66d

Update demo.py

Browse files
Files changed (1) hide show
  1. demo.py +7 -2
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="6357578ba3bf29aad59900d22751102d175f4976"
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(pil_image, face=face)["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