Open KazuhideMimura opened 1 year ago
HI @KazuhideMimura , I tried to train the model for 4 classes, its giving ValueError: Error when checking target: expected fc360 to have shape (4,) but got array with shape (360,). do we need to change any files other than utils.py
Hi @HAsarvesh , thank you for the repo. Would you provide me with a detailed error log? I'd like to know where the error occurred.
Hi @KazuhideMimura , thanks for the reply. error is fixed, I just gave the value for parameter nb_classes in RotNetDataGenerator class as 4. But after training the model, while testing I'm not getting the proper output i.e., the images are as it is, they are not rotating. I'm using custom data and I'm giving the raw images, do I need to manipulate the images before training?
You don't need add special treatment to the original image. I think the possibilities are:
nb_classes
is not designatedFor example, if you run a function display example
...
display_examples(
model,
test_filenames,
num_images=num_images,
size=(224, 224),
crop_center=True,
crop_largest_rect=True,
preprocess_func=preprocess_input,
nb_classes=4, # designate nb_class
)
Please note that nb_class will be set at 360 unless designated. This is because I didn't want to disturb the original concept.
Thanks for the clarification, I'll train it again and check.
Here?
predictions = model.predict_generator(
RotNetDataGenerator(
image_paths,
input_shape=(224, 224, 3),
batch_size=64,
one_hot=True,
preprocess_func=preprocess_input,
rotate=False,
crop_largest_rect=True,
crop_center=True,
nb_classes = model.layers[-1].units, # added. Not sure it works, but statement is required to obtain model's class number.
),
val_samples=len(image_paths)
)
Thanks @KazuhideMimura, I'll try this.
Hi, thank you for sharing nice programs.
The following changes to
utils.py
will allow training with fewer classes. Rotating with 4 classes may be especially useful for training with small data. There seems to be something wrong in visualization (functiondisplay_example
), but I was able to train four classes.(omitted)
@class RotNetDataGenerator
(omitted)
(omitted)