Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

244 - 299 problem #152

Open
NasaKHw opened this issue Feb 5, 2024 · 1 comment
Open

244 - 299 problem #152

NasaKHw opened this issue Feb 5, 2024 · 1 comment

Comments

@NasaKHw
Copy link

NasaKHw commented Feb 5, 2024

Hello

ValueError: Input 0 of layer "model_1" is incompatible with the layer: expected shape=(None, 299, 299, 3), found shape=(None, 224, 224, 3)

im sure that my images are 299 299
i also tried :

from nsfw_detector import predict
model = predict.load_model('models/nsfw.299x299.h5')
predict.classify(model, 'test/frames/', 299)

or

from nsfw_detector import predict
model = predict.load_model('models/nsfw.299x299.h5')

Predict single image

predict.classify(model, 'test/frames/output_0045.jpg', 299)

output :
:38] TF-TRT Warning: Could not find TensorRT
test/frames/output_0045.jpg size: (299, 299)
1/1 [==============================] - 2s 2s/step
[root@server-194-5-205-78 nsfw_model]#

but it did not print the result and only printed images name and , 299 thats all
any trick to solve it ?

@NasaKHw NasaKHw changed the title Instaĺl and tutorial of starting for beginers 244 - 299 problem Feb 5, 2024
@NasaKHw
Copy link
Author

NasaKHw commented Feb 6, 2024

u should write it like this and save it to outputfile to work
but i dont know why is it considering a bird as sexy!!!

from nsfw_detector import predict

Load the model

model = predict.load_model('models/nsfw.299x299.h5')

Classify images and store the results

results = predict.classify(model, 'output_frames299', 299)

Define the path to the output text file

output_file = 'output_results.txt'

Open the file in write mode and write the results

with open(output_file, 'w') as f:
for image_path, result in results.items():
f.write(f"Image: {image_path}\n")
for category, probability in result.items():
f.write(f"{category}: {probability}\n")
f.write("\n")

print(f"Output written to {output_file}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant