GantMan / nsfw_model

Keras model of NSFW detector
Other
1.67k stars 267 forks source link

How to disable spam? #147

Open ShamHyper opened 8 months ago

ShamHyper commented 8 months ago

Dear dev!

I would really like to know if there is an option to disable this kind of messages in the console during predict.classify():

C:\...\photo.jpg size: (224, 224)
1/1 [==============================] - 0s 33ms/step

Icecream has a kind of prints switch ic.disable() | ic.enable(). Do you have a similar function? If not, then I will bypass this spam through std, but maybe you can help me?

colindean commented 8 months ago

According to this SO post, you should be able to pass verbose=0 in the args to model.predict(), which this library passes via the predict_args arg of classify(), e.g.

predict.classify(classify(model, input_paths, predict_args={verbose: 0})

If that works for you, please confirm and close this issue!

ShamHyper commented 8 months ago

Uh... TypeError: classify() got an unexpected keyword argument 'predict_args'

My code: result = predict.classify(model_nsfw, file_path, predict_args={verbose: 0}) And "verbose" is not defined.

ShamHyper commented 8 months ago

Idk... but after reading code of predict.py, I don't understand how these arguments are passed to keras, and why in your example, after predict.classify, there is another classify in parentheses

According to this SO post, you should be able to pass verbose=0 in the args to model.predict(), which this library passes via the predict_args arg of classify(), e.g.

predict.classify(classify(model, input_paths, predict_args={verbose: 0})

If that works for you, please confirm and close this issue!

It seems that the classify() function does not accept a predict_args parameter 😣

colindean commented 8 months ago

why in your example, after predict.classify, there is another classify in parentheses

Probably a copy paste error. Take out the second function call

ShamHyper commented 8 months ago

predict.classify(model_nsfw, file_path, predict_args={verbose: 0})

This right?

colindean commented 8 months ago

Looks to be, I can't try it right now

ShamHyper commented 8 months ago

Waiting for dev's answer..