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

bug in predict.py script #11

Open
Laetij opened this issue Nov 14, 2019 · 0 comments
Open

bug in predict.py script #11

Laetij opened this issue Nov 14, 2019 · 0 comments

Comments

@Laetij
Copy link

Laetij commented Nov 14, 2019

Predict function doesn't work in command line but well in the web app interface

You should replace :

Open and read the image to predict.

with tf.gfile.Open(path, 'rb') as f:
    try:
        image = Image.open(f).convert('RGB')
    except (tf.errors.OutOfRangeError, OSError) as e:
        click.echo()
        click.echo('Error while processing {}: {}'.format(path, e))
        return

by :

Open and read the image to predict.

with tf.gfile.Open(path, 'rb') as f:
    try:
        image = Image.open(f).convert('RGB')
        img = np.asarray(image)
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        b = cv2.distanceTransform(img, distanceType=cv2.DIST_L2, maskSize=5)
        g = cv2.distanceTransform(img, distanceType=cv2.DIST_L1, maskSize=5)
        r = cv2.distanceTransform(img, distanceType=cv2.DIST_C, maskSize=5)

        # merge the transformed channels back to an image
        transformed_image = cv2.merge((b, g, r))
    except (tf.errors.OutOfRangeError, OSError) as e:
        click.echo()
        click.echo('Error while processing {}: {}'.format(path, e))
        return

to be able to use tabulo predict in command line

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