import gradio as gr | |
import cv2 | |
def predict_fn(img_path): | |
#Read and tranform input image | |
# preds=model.predict(img_path).json() | |
og_img=cv2.imread(img_path) | |
# img=binary_cv2(og_img,preds) | |
# outputs = kp_predictor(img) # format is documented at https://detectron2.readthedocs.io/tutorials/models.html#model-output-format | |
# print("outputs==".format(outputs["instances"].to("cpu"))) | |
# p=np.asarray(outputs["instances"].to("cpu").pred_keypoints, dtype='float32')[0].reshape(-1) | |
# pairss=convert_to_pairs(p) | |
# segm=segm_imf(preds,og_img) | |
# output=visualize(segm,pairss) | |
return og_img | |
inputs_image = [ | |
gr.components.Image(type="filepath", label="Upload an XRay Image of the Pelvis"), | |
] | |
outputs_image = [ | |
gr.components.Image(type="numpy", label="Output Image") | |
] | |
gr.Interface( | |
predict_fn, | |
inputs=inputs_image, | |
outputs=outputs_image, | |
title="Coordinates of the Landmarks", | |
_api_mode=True | |
).launch() | |