Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,24 +4,24 @@ import cv2
|
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
|
| 26 |
def process_image(image, user_height_cm):
|
| 27 |
# Convert Gradio image input to OpenCV format
|
|
|
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
import gradio as gr
|
| 7 |
+
from detectron2.detectron2.engine import DefaultPredictor
|
| 8 |
+
from detectron2.detectron2.config import get_cfg
|
| 9 |
+
from detectron2 import model_zoo
|
| 10 |
+
import torch_utils
|
| 11 |
+
import dnnlib
|
| 12 |
+
# Create output directory if it doesn't exist
|
| 13 |
+
output_dir = "key/"
|
| 14 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 15 |
+
output_file = os.path.join(output_dir, "keypoints.json")
|
| 16 |
+
|
| 17 |
+
# Load pre-trained Keypoint R-CNN model
|
| 18 |
+
cfg = get_cfg()
|
| 19 |
+
cfg.merge_from_file(model_zoo.get_config_file("COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml"))
|
| 20 |
+
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml")
|
| 21 |
+
cfg.MODEL.DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 22 |
+
|
| 23 |
+
# Load the predictor
|
| 24 |
+
predictor = DefaultPredictor(cfg)
|
| 25 |
|
| 26 |
def process_image(image, user_height_cm):
|
| 27 |
# Convert Gradio image input to OpenCV format
|