Download app.py from mayayank/Medical-Image-Segmentation: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/mayayank/Medical-Image-Segmentation/resolve/main/app.py
- Command line
-
hf download hf://mayayank/Medical-Image-Segmentation/app.py
-
curl -L -o app.py https://huggingface.co/mayayank/Medical-Image-Segmentation/resolve/main/app.py
650 Bytes
| from tensorflow.keras.models import Model, load_model | |
| import gradio as gr | |
| from pathlib import Path | |
| import matplotlib.pyplot as plt | |
| current_directory_path = Path(__file__).parent.resolve() | |
| model_path = current_directory_path / "cce_dice_loss_pretrained.h5" | |
| label_map_object = {0: 'LARGE BOWEL', 1: 'SMALL BOWEL', 2: 'STOMACH', 3: 'BACKGROUND'} | |
| # Load the model | |
| model = load_model(model_path) | |
| def segment_object(image): | |
| plt.imshow(image) | |
| webcam = gr.inputs.Image(shape=(800, 600), source="upload", type='file') #upload | |
| webapp = gr.interface.Interface(fn=segment_object, inputs=webcam, outputs="plot") #, live=False | |
| webapp.launch(debug=True) |