Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
-
from controlnet_aux.
|
| 4 |
-
from controlnet_aux.depth_anything import DepthAnythingDetector
|
| 5 |
|
| 6 |
-
# Load models
|
| 7 |
openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
|
| 8 |
depth = DepthAnythingDetector.from_pretrained("depth-anything/Depth-Anything-V2")
|
| 9 |
|
| 10 |
def process(image: Image.Image):
|
| 11 |
image = image.convert("RGB")
|
| 12 |
-
|
| 13 |
-
# Run both detectors
|
| 14 |
result_openpose = openpose(image)
|
| 15 |
result_depth = depth(image)
|
| 16 |
|
| 17 |
-
# Ensure results are PIL images
|
| 18 |
if not isinstance(result_openpose, Image.Image):
|
| 19 |
result_openpose = Image.fromarray(result_openpose)
|
| 20 |
if not isinstance(result_depth, Image.Image):
|
|
@@ -22,16 +19,15 @@ def process(image: Image.Image):
|
|
| 22 |
|
| 23 |
return result_openpose, result_depth
|
| 24 |
|
| 25 |
-
# Gradio UI
|
| 26 |
demo = gr.Interface(
|
| 27 |
fn=process,
|
| 28 |
inputs=gr.Image(type="pil", label="Upload an image"),
|
| 29 |
outputs=[
|
| 30 |
gr.Image(type="pil", label="OpenPose Result"),
|
| 31 |
-
gr.Image(type="pil", label="Depth Result")
|
| 32 |
],
|
| 33 |
title="ControlNet Aux Demo",
|
| 34 |
-
description="Upload an image
|
| 35 |
)
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
+
from controlnet_aux.openpose import OpenposeDetector
|
| 4 |
+
from controlnet_aux.depth_anything import DepthAnythingDetector
|
| 5 |
|
| 6 |
+
# Load models
|
| 7 |
openpose = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
|
| 8 |
depth = DepthAnythingDetector.from_pretrained("depth-anything/Depth-Anything-V2")
|
| 9 |
|
| 10 |
def process(image: Image.Image):
|
| 11 |
image = image.convert("RGB")
|
|
|
|
|
|
|
| 12 |
result_openpose = openpose(image)
|
| 13 |
result_depth = depth(image)
|
| 14 |
|
|
|
|
| 15 |
if not isinstance(result_openpose, Image.Image):
|
| 16 |
result_openpose = Image.fromarray(result_openpose)
|
| 17 |
if not isinstance(result_depth, Image.Image):
|
|
|
|
| 19 |
|
| 20 |
return result_openpose, result_depth
|
| 21 |
|
|
|
|
| 22 |
demo = gr.Interface(
|
| 23 |
fn=process,
|
| 24 |
inputs=gr.Image(type="pil", label="Upload an image"),
|
| 25 |
outputs=[
|
| 26 |
gr.Image(type="pil", label="OpenPose Result"),
|
| 27 |
+
gr.Image(type="pil", label="Depth Result"),
|
| 28 |
],
|
| 29 |
title="ControlNet Aux Demo",
|
| 30 |
+
description="Upload an image and run both OpenPose and Depth Anything."
|
| 31 |
)
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|