question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NameError: name 'get_prepocessing' is not defined

See original GitHub issue

I can’t run the sample code from https://segmentation-models.readthedocs.io/en/latest/tutorial.html, the error information is just like the title. I only alter the path of input like this,

x_train, y_train, x_val, y_val = load_data("/Volumes/NT/code/data/dataset/train/src",
                                            "/Volumes/NT/code/data/dataset/train/label",
                                            "/Volumes/NT/code/data/dataset/test/src",
                                            "/Volumes/NT/code/data/dataset/test/label")

the whole error is this: UserWarning: Current ResNext models are deprecated, use keras.applications ResNeXt models warnings.warn('Current ResNext models are deprecated, ’ Traceback (most recent call last): File “/Users/zhangsanhuo/Desktop/code/test.py”, line 7, in <module> preprocess_input = get_prepocessing(BACKBONE) NameError: name ‘get_prepocessing’ is not defined waiting for your reply,thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Diyagocommented, Apr 13, 2019

You can start with smth like this:

import os
import numpy as np
from skimage.io import imread
from skimage import transform
from cv2 import resize
from keras.preprocessing.image import load_img

data_dir = './data_objects'

def load_data(root_dir):
    data = []

    for stage in ['train']:
        directory = os.path.join(root_dir,  'images')
        file_names = [filename.replace('jpg' , 'png') for filename in os.listdir(directory)]
        fps = [os.path.join(directory, filename) for filename in os.listdir(directory)]
        for content in ['images', 'segmentation']:
            # construct path to each image
            directory = os.path.join(root_dir,  content)
            
            if content != 'images':
                fps = [os.path.join(directory, filename) for filename in file_names]
                
            # read images
            images = [imread(filepath)/255 for filepath in fps]
 
            # if images have different sizes you have to resize them before:
            resized_images = [resize(image, (256, 256)) for image in images]
            
            # stack to one np.array 
            np_images = np.stack(resized_images, axis=0)
            
            data.append(np_images)
            
    return data
x_train, y_train  = load_data(data_dir)
0reactions
zthreefirescommented, Apr 13, 2019

You can start with smth like this:

import os
import numpy as np
from skimage.io import imread
from skimage import transform
from cv2 import resize
from keras.preprocessing.image import load_img

data_dir = './data_objects'

def load_data(root_dir):
    data = []

    for stage in ['train']:
        directory = os.path.join(root_dir,  'images')
        file_names = [filename.replace('jpg' , 'png') for filename in os.listdir(directory)]
        fps = [os.path.join(directory, filename) for filename in os.listdir(directory)]
        for content in ['images', 'segmentation']:
            # construct path to each image
            directory = os.path.join(root_dir,  content)
            
            if content != 'images':
                fps = [os.path.join(directory, filename) for filename in file_names]
                
            # read images
            images = [imread(filepath)/255 for filepath in fps]
 
            # if images have different sizes you have to resize them before:
            resized_images = [resize(image, (256, 256)) for image in images]
            
            # stack to one np.array 
            np_images = np.stack(resized_images, axis=0)
            
            data.append(np_images)
            
    return data
x_train, y_train  = load_data(data_dir)

thank you very much!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

preprocessing error trying to use OneHot Encoder Python
Call OneHotEncoder without preprocessing before the name. So just do ohe = OneHotEncoder() . The problem is in your import, what you have...
Read more >
sklearn.preprocessing.LabelEncoder transform wrong output
Python 3.4 Windows 7 Metadata-Version: 2.0 Name: scikit-learn Version: 0.16.1 Trying to use labelEncoder() to label mulltiple classes.
Read more >
Sklearn is not defined - Insurance pricing game
I am trying to use capabilities from sklearn during data preprocessing and I get “NameError: name 'sklearn' is not defined” when I run...
Read more >
sklearn.preprocessing.LabelEncoder
Encode target labels with value between 0 and n_classes-1. This transformer should be used to encode target values, i.e. y , and not...
Read more >
The name 'StandardScaler' is not defined - Intellipaat
StandardScaler is the method under sklearn.preprocessing. You need to import the StandardScaler like this: from sklearn.preprocessing import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found