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)