-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeadnet.py
41 lines (31 loc) · 1.09 KB
/
beadnet.py
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
30
31
32
33
34
35
36
37
38
39
40
41
import json
import numpy as np
import random
import torch
from pathlib import Path
from src.beadnet_gui import run_gui
def run_beadnet():
""" Run the particle detection tool BeadNet """
random.seed()
np.random.seed()
# Get default settings for the omero login
with open(Path(__file__).parent/'settings.json') as f:
settings = json.load(f)
# Set device for using CPU or GPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
if str(device) == 'cuda':
torch.backends.cudnn.benchmark = True
use_gpu = True
num_gpus = torch.cuda.device_count()
else:
use_gpu = False
num_gpus = 0
run_gui(model_path=Path(__file__).parent/'models',
training_data_path=Path(__file__).parent/'training_dataset',
eval_results_path=Path(__file__).parent/'evaluation',
inference_results_path=Path(__file__).parent/'results',
gpu=use_gpu,
multi_gpu=True if num_gpus > 1 else False,
omero_settings=settings)
if __name__ == "__main__":
run_beadnet()