Autopilot icon indicating copy to clipboard operation
Autopilot copied to clipboard

ValueError: too many values to unpack (expected 2) on LoadData_V2.py

Open santoshlite opened this issue 3 years ago • 0 comments

Hello,

I have a problem when I run this code.

from future import division import cv2 import os import numpy as np import scipy import pickle import matplotlib.pyplot as plt from itertools import islice

LIMIT = None

DATA_FOLDER = 'driving_dataset' TRAIN_FILE = os.path.join(DATA_FOLDER, 'data.txt')

def preprocess(img): resized = cv2.resize((cv2.cvtColor(img, cv2.COLOR_RGB2HSV))[:, :, 1], (100, 100)) return resized

def return_data():

X = []
y = []
features = []

with open(TRAIN_FILE) as fp:
    for line in islice(fp, LIMIT):
        path, angle = line.strip().split()
        full_path = os.path.join(DATA_FOLDER, path)
        X.append(full_path)
        # using angles from -pi to pi to avoid rescaling the atan in the network
        y.append(float(angle) * scipy.pi / 180)

for i in range(len(X)):
    img = plt.imread(X[i])
    features.append(preprocess(img))

features = np.array(features).astype('float32')
labels = np.array(y).astype('float32')

with open("features", "wb") as f:
    pickle.dump(features, f, protocol=4)
with open("labels", "wb") as f:
    pickle.dump(labels, f, protocol=4)

return_data()

The error is : Traceback (most recent call last): File "LoadData_V2.py", line 45, in <module> return_data() File "LoadData_V2.py", line 27, in return_data path, angle = line.strip().split() ValueError: too many values to unpack (expected 2)

Can you help me, please?

Cordially,

Santosh

santoshlite avatar Jan 26 '21 21:01 santoshlite