Download app.py from yahaoh/exper: direct link, hf CLI and curl.
- Browser
- Download file 969 Bytes
-
https://huggingface.co/spaces/yahaoh/exper/resolve/main/app.py
- Command line
-
hf download hf://spaces/yahaoh/exper/app.py
-
curl -L -o app.py https://huggingface.co/spaces/yahaoh/exper/resolve/main/app.py
969 Bytes
| 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() | |