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

Resizing image before switching channels #300

Merged
merged 1 commit into from
Apr 23, 2019

Conversation

Ignisor
Copy link
Contributor

@Ignisor Ignisor commented Apr 23, 2019

A simple fix for ImageBaseFeature _read_image_and_resize method.

Info of the initial problem:

Traceback:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/home/ignisor/dev/ludwig-human-classifier/.env/lib/python3.7/site-packages/ludwig-0.1.1-py3.7.egg/ludwig/api.py", line 946, in predict
    logging_level=logging_level,
  File "/home/ignisor/dev/ludwig-human-classifier/.env/lib/python3.7/site-packages/ludwig-0.1.1-py3.7.egg/ludwig/api.py", line 809, in _predict
    self.model_definition['preprocessing']
  File "/home/ignisor/dev/ludwig-human-classifier/.env/lib/python3.7/site-packages/ludwig-0.1.1-py3.7.egg/ludwig/data/preprocessing.py", line 164, in build_data
    preprocessing_parameters
  File "/home/ignisor/dev/ludwig-human-classifier/.env/lib/python3.7/site-packages/ludwig-0.1.1-py3.7.egg/ludwig/features/image_feature.py", line 213, in add_feature_data
    user_specified_num_channels
  File "/home/ignisor/dev/ludwig-human-classifier/.env/lib/python3.7/site-packages/ludwig-0.1.1-py3.7.egg/ludwig/features/image_feature.py", line 91, in _read_image_and_resize
    img_padded[:,:,:min_num_channels] = img[:,:,:min_num_channels]
ValueError: could not broadcast input array from shape (300,451,3) into shape (400,300,3)

Model defenition:

MODEL_DEFENITION = {
    'input_features': [
        {
            "name": "image_path",
            "type": "image",
            "encoder": "stacked_cnn",
            'preprocessing': {
                'resize_method': 'interpolate', 
                'height': 400, 
                'width': 300,
            },
        },
    ],
    "output_features": [
        {
            "name": "class",
            "type": "category",
        },
    ],
}

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2019

CLA assistant check
All committers have signed the CLA.

@w4nderlust
Copy link
Collaborator

Good catch, thank you!

@w4nderlust w4nderlust merged commit 8c62333 into ludwig-ai:master Apr 23, 2019
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

Successfully merging this pull request may close these issues.

3 participants