简体   繁体   中英

How can I return an integer value from this function Multi

How can I return an value from a function when an object is created

Call:

gpuid = Vgg16Worker(Process,Queue)

Class:

class Vgg16Worker(Process):
    def __init__(self, gpuid, queue):
        Process.__init__(self, name='ModelProcessor')
        self._gpuid = gpuid
        self._queue = queue

        print('Queue initialisiert')
        return(self._gpuid)

Error:

__init__() should return None, not 'type'

Maybe you should create a function in your class to get the value.

class Vgg16Worker(Process):
    def __init__(self, gpuid, queue):
        Process.__init__(self, name='ModelProcessor')
        self._gpuid = gpuid
        self._queue = queue

        print('Queue initialisiert')

    def getGPUID(self):
        return self._gpuid

gpuid = Vgg16Worker(Process,Queue)
gpuid.getGPUID()

I have still one question I have a class for prediction:

def predict(self, xnet,frame):

    out = xnet.predict(np.expand_dims(frame, axis=0))[0]
    return np.argmax(out)

When the class is executed, the return value contains a value

nothing arrives in the main process?

Call:

ippreds = Vgg16Worker.predict(gpuid,model,ipframe)

What have I done wrong?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM