How can the python packages be installed in uipath?

Hi @sssi

How did you solve this? May be others having the same problem can use what you used. Kindly pen it down in this thread.

def detect_face(img):

You are doing everything right here. But one heads up is converting python return types to .net types can be often clumbersome.

What I learnt from expierence is that it is easier to use json string as a return from python.

For example, your code could look like:

import json
import cv2
import os
import numpy as np
from facenet_pytorch import MTCNN

def detect_face(img):

    mtcnn = MTCNN()

    if os.path.isfile(img) != True:
        raise ValueError("Confirm that ", img, " exists")

    path = np.fromfile(img, np.uint8)
    img = cv2.imdecode(path, cv2.IMREAD_UNCHANGED)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

    boxes, probs, landmarks = mtcnn.detect(img, landmarks=True)

    if (boxes is None):
        raise Exception('Cannot detect face')
        result = { 'result': False}  
        return json.dumps(result)
    else:
        result = { 'result': True}  
        return json.dumps(result)

In UiPath you can then use the desearlize json activity (UiPath.Web.Activities) to get the value of return value result

Here is another example of using json strings and parsing it in UiPath : How to use permuation and combination in excel uipath - Help - UiPath Community Forum


Some threads for you to read about Pipe is broken error, which I have come across and some reasons for it.

1 Like