Commit c6f352a7 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '39-remove-multiprosessing' into 'master'

Resolve "Remove multiprosessing"

Closes #39

See merge request !42
parents 0dc4059d 5aca26ff
......@@ -3,11 +3,9 @@ import time
import numpy as np
from pathlib import Path
from skimage.util import img_as_ubyte
from multiprocessing import Process
from multiprocessing import Manager
def run_prediction_dlc(config: str,image: np.ndarray,shuffle: int =1,
trainingsetindex: int =0,gputouse: int =None,return_dict: list = None):
trainingsetindex: int =0,gputouse: int =None):
from deeplabcutcore.pose_estimation_tensorflow.nnet import predict
from deeplabcutcore.pose_estimation_tensorflow.config import load_config
from tensorflow.python.framework.ops import reset_default_graph
......@@ -107,38 +105,6 @@ def run_prediction_dlc(config: str,image: np.ndarray,shuffle: int =1,
# device.reset()
# tf.Graph.reset_default_graph()
# return PredictedData[0], nframes, nx, ny
def get_prediction_dlc(config,image,shuffle=1,
Output: Predictions of the salamander.
config : string
Full path of the config.yaml file as a string.
shuffle: int, optional
An integer specifying the shuffle index of the training dataset used for training the network. The default is 1.
trainingsetindex: int, optional
Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml).
gputouse: int, optional. Natural number indicating the number of your GPU (see number in nvidia-smi). If you do not have a GPU put None.
return_dict = Manager().list()
# return_dict = multiprocessing.Value("d", [], lock=False)
args = (config, image, shuffle,
trainingsetindex, gputouse, return_dict)
p = Process(target=run_prediction_dlc, args=args)
return return_dict[0], return_dict[1], return_dict[2], return_dict[3]
return PredictedData[0], nframes, nx, ny
......@@ -67,7 +67,7 @@ def straighten(image):
factor = MAX_DEEPLABCUT_IMAGE_SIZE / larger_dim
cropped_image = cv2.resize(cropped_image, None, fx=factor, fy=factor, interpolation=cv2.INTER_CUBIC)
prediction, _, x, y = psa.get_prediction_dlc(config=abs_path_dlc_config, image=cropped_image, gputouse=GPUID)
prediction, _, x, y = psa.run_prediction_dlc(config=abs_path_dlc_config, image=cropped_image, gputouse=GPUID)
# points is an array of coordinates to use to straighten the image:
# We use the prediction from deeplabcut for the points. There are two things to take note of.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment