File size: 1,023 Bytes
75ea7e6
d77453d
ab657c0
 
75ea7e6
ab657c0
 
 
 
75ea7e6
ab657c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()