huggingface / huggingface/controlnet_aux

name 'mp_face_mesh' is not defined

Open
#77 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
497
Forks
104
PR merge metrics
No merged PRs in 30d

Description

Hey Patrick,
i installed mediapipe, controlnet_aux but still getting error:
```
from diffusers.utils import load_image
from controlnet_aux.processor import Processor
import torch

image = load_image( "https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/examples/sketch/human.png" )

image.save("human.png")

```
```
Loading base model ()...Done.
Removing last two layers (global_pool & classifier).
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[11], line 22
20 for processor_id in processor_id_list:
21 processor = Processor(processor_id)
---> 22 processed_image = processor(image, to_pil= True )
24 processed_image.save(f"{processor_id}.png")

File /usr/local/lib/python3.10/dist-packages/controlnet_aux/processor.py:141, in Processor.__call__(self, image, to_pil)
138 if isinstance(image, bytes):
139 image = Image.open(io.BytesIO(image)).convert("RGB")
--> 141 processed_image = self.processor(image, **self.params)
143 if to_pil:
144 return processed_image

File /usr/local/lib/python3.10/dist-packages/controlnet_aux/mediapipe_face/__init__.py:42, in MediapipeFaceDetector.__call__(self, input_image, max_faces, min_confidence, output_type, detect_resolution, image_resolution, **kwargs)
39 input_image = HWC3(input_image)
40 input_image = resize_image(input_image, detect_resolution)
---> 42 detected_map = generate_annotation(input_image, max_faces, min_confidence)
43 detected_map = HWC3(detected_map)
45 img = resize_image(input_image, image_resolution)

File /usr/local/lib/python3.10/dist-packages/controlnet_aux/mediapipe_face/mediapipe_face_common.py:106, in generate_annotation(img_rgb, max_faces, min_confidence)
96 def generate_annotation(
97 img_rgb,
98 max_faces: int,
99 min_confidence: float
100 ):
101 """
102 Find up to 'max_faces' inside the provided input image.
103 If min_face_size_pixels is provided and nonzero it will be used to filter faces that occupy less than this many
104 pixels in the image.
105 """
--> 106 with mp_face_mesh.FaceMesh(
107 static_image_mode=True,
108 max_num_faces=max_faces,
109 refine_landmarks=True,
110 min_detection_confidence=min_confidence,
111 ) as facemesh:
112 img_height, img_width, img_channels = img_rgb.shape
113 assert(img_channels == 3)

NameError: name 'mp_face_mesh' is not defined

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.