YOLO: results = model.predict(frame)

Can you help me?

:slight_smile:

How do I implement the results for “person” or “laptop”?

names = [“person”, “laptop”]

model.set_classes(names, model.get_text_pe(names))

results = model.predict(frame)

I want to have something like:

if results = “person” then do …

Bill

1 Like

Hey there, @Bill293536,

You can absolutely make code like that, but exactly how will depend on what the output of model.predict(frame) is. I tried having a look through the Yolo code in github and it appears to simply be a list of lists.

If you made code like the following:

for result in results:
    for item in result:
        print(item)

It will print out every part of the list returned by result.

Then, you just find the part of the list that includes the label of ‘person’, or whatever it would be.

Then you reference that part as result[a][b].

And you can take that value and put it into a simple:

if results[x][y] == 'person':
    print("Hello World")
1 Like

Jane,

:slight_smile:

Bill

2 Likes