'Getting cannot import name error when importing NudeClassifier from nudenet

I am getting an error when running the following code -

from nudenet import NudeClassifier


def nudenetclf(df):
    classifier = NudeClassifier()
    for index in df.shape[0]:
        img_lst = df["images"].iloc[index]

        clf = classifier(img_lst)
        count = 0

        for key in list(clf.keys()):
            val = clf[key]
            if val["safe"] < val["unsafe"]:
                count += 1

        if count > 0:
            print(df["url"].iloc[index])

On running above code I get an error - ImportError: cannot import name 'NudeClassifier'

How can I solve this?



Solution 1:[1]

You are using NudeClassifier without importing it. so,

Import NudeClassifier like this:

from nudenet import NudeClassifier

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mehrdad Pedramfar