import gradio as gr import subprocess import os import numpy as np os.environ['data_raw'] = 'data_raw/' os.environ['nnUNet_raw_data_base'] = 'nnUNet_raw_data_base/' os.environ['nnUNet_preprocessed'] = 'nnUNet_preprocessed/' os.environ['RESULTS_FOLDER'] = 'calvingfronts/' def run_front_detection(input_img): input_img.save('data_raw/test.png') subprocess.run( ['python3', 'nnunet/dataset_conversion/Task500_Glacier_inference.py', '-data_percentage', '100', '-base', os.environ['data_raw']]) cmd = [ 'python3', 'nnunet/inference/predict_simple.py', '-i', os.path.join('$nnUNet_raw_data_base', 'nnUNet_raw_data/Task500_Glacier_zonefronts/imagesTs/'), '-o', os.path.join('$RESULTS_FOLDER', 'fold_0'), '-t', '500','-m','2d','-f','0','-p', 'nnUNetPlansv2.1', '-tr','nnUNetTrainerV2', '-model_folder_name', '$model' ] #subprocess.run(cmd) #TODO remove files demo = gr.Interface(run_front_detection, gr.Image(type='pil'), "image") demo.launch()