3v324v23 commited on
Commit
5181494
·
1 Parent(s): 3304105
Files changed (2) hide show
  1. app.py +10 -15
  2. requirements.txt +0 -3
app.py CHANGED
@@ -29,8 +29,8 @@ def get_openpose_detector():
29
  def get_dwpose_detector():
30
  """Get or create DWPose detector."""
31
  if "dwpose" not in _model_cache:
32
- from easy_dwpose import DWposeDetector
33
- _model_cache["dwpose"] = DWposeDetector(device=DEVICE)
34
  return _model_cache["dwpose"]
35
 
36
 
@@ -85,22 +85,17 @@ def process_with_dwpose(
85
  """Process image using DWPose detector."""
86
  detector = get_dwpose_detector()
87
 
88
- # Resize image to detect_resolution while maintaining aspect ratio
89
- orig_w, orig_h = image.size
90
- scale = detect_resolution / max(orig_w, orig_h)
91
- new_w, new_h = int(orig_w * scale), int(orig_h * scale)
92
- resized_image = image.resize((new_w, new_h), Image.Resampling.LANCZOS)
93
-
94
  result = detector(
95
- resized_image,
96
- output_type="pil",
97
- include_hands=detect_hand,
98
- include_face=detect_face
 
 
 
99
  )
100
 
101
- # Resize back to original size
102
- result = result.resize((orig_w, orig_h), Image.Resampling.LANCZOS)
103
-
104
  return result, None
105
 
106
 
 
29
  def get_dwpose_detector():
30
  """Get or create DWPose detector."""
31
  if "dwpose" not in _model_cache:
32
+ from controlnet_aux import DWposeDetector
33
+ _model_cache["dwpose"] = DWposeDetector.from_pretrained("yolox_l.onnx", "dw-ll_ucoco_384.onnx")
34
  return _model_cache["dwpose"]
35
 
36
 
 
85
  """Process image using DWPose detector."""
86
  detector = get_dwpose_detector()
87
 
88
+ # controlnet-aux DWposeDetector API
 
 
 
 
 
89
  result = detector(
90
+ image,
91
+ detect_resolution=detect_resolution,
92
+ image_resolution=detect_resolution,
93
+ include_hand=detect_hand,
94
+ include_face=detect_face,
95
+ include_body=True,
96
+ output_type="pil"
97
  )
98
 
 
 
 
99
  return result, None
100
 
101
 
requirements.txt CHANGED
@@ -1,10 +1,7 @@
1
  gradio>=4.0.0
2
  controlnet-aux>=0.0.9
3
- onnxruntime>=1.16.0
4
- easy-dwpose --no-deps
5
  torch
6
  torchvision
7
  Pillow
8
  numpy
9
  opencv-python-headless
10
- huggingface_hub
 
1
  gradio>=4.0.0
2
  controlnet-aux>=0.0.9
 
 
3
  torch
4
  torchvision
5
  Pillow
6
  numpy
7
  opencv-python-headless