Skip to content

Is it possible to convert the private-detector model to a CoreML model? #13

Description

@ChouJay

Dear Bumble tech,
I've been attempting to convert the private-detector's saved_model into a CoreML model. However, after the conversion, it seems unable to successfully identify NSFW images. I suspect there might be an issue during the conversion process. Could you guide me on how to correctly convert a saved_model.pb into a CoreML .mlPackage? Thanks a lot!
Here's my code:

import coremltools as ct
mlmodel_from_tf = ct.convert(model="/Path/To/private_detector/saved_model",
                           inputs=[ct.ImageType(shape=(1,480,480,3))],
                           source="tensorflow",
                           compute_precision=ct.precision.FLOAT32)

Results of testing the CoreML model:

from PIL import Image
img = Image.open('/Path/To/Desktop/dick3.png')
img = img.resize((480,480)) 
if img.mode != 'RGB':
    img = img.convert('RGB')
out_dict = mlmodel_from_tf.predict({"model_input_images": img})
print(out_dict) 
# {'Identity': array([[0.00386974, 0.9961302 ]], dtype=float32)}
# I believe the first element of the array represents the "confidence level that the content is NSFW." or I'm misunderstanding something?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions