File size: 1,037 Bytes
ce444b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pytorch_inf import run_pytorch_inference
from huggingface_hub import hf_hub_download
import os
import dotenv
import pandas as pd
dotenv.load_dotenv()
hf_tk = os.getenv('HF_AT')

raw_model_v1_4 = hf_hub_download(repo_id="dev-deg/ambulant_pt_v1.4.0_noproc", filename="best_final_noproc.pt",use_auth_token=hf_tk)
latest_conf_matrix = hf_hub_download(repo_id="dev-deg/ambulant_pt_v1.4.0_noproc", filename="confusion_matrix_normalized.png",use_auth_token=hf_tk)
latest_labels = hf_hub_download(repo_id="dev-deg/ambulant_pt_v1.4.0_noproc", filename="labels.jpg",use_auth_token=hf_tk)

def run_inference(input_image, depth, csv):
    if csv and csv != "":
        from io import StringIO
        species_data = pd.read_csv(StringIO(csv))
        print("Using pasted data")
    else:
        species_data = pd.read_csv('habitat_classification.csv')
        print("Using default data")


    if input_image is None:
        return None, None, None, None, None, None
    return run_pytorch_inference(input_image, raw_model_v1_4, species_data)