Closed eric333316152 closed 5 years ago
You are definitely passing wrong data into your network. Could you share your code or you can manually take look your batches by yourself?
Hi @eric333316152 As far as I know, CIFAR is classification dataset, not segmentation, so you have to use another kind of network architectures.
@Diyago @qubvel I think u guys are right ....... CIFAR 10 data is inappropriate for this problem. I am just a AI beginner. So, could you please let me know where I can get data set for segmentation?
@qubvel @Diyago ah before, can u please see my code? I used data set in other github, which is here : https://github.com/divamgupta/image-segmentation-keras
And here is my code.
from segmentation_models import Unet
model = Unet()
model = Unet('resnet34', encoder_weights='imagenet')
model = Unet('resnet34', classes=51, activation='softmax')
model = Unet('resnet34', input_shape=(None, None, 3), encoder_weights='imagenet') -> until here, just import your code
import cv2 import numpy as np
ann_img = np.zeros((30,30,3)).astype('uint8') ann_img[ 3 , 4 ] = 1 # this would set the label of pixel 3,4 as 1
cv2.imwrite( "ann_1.png" ,ann_img ) -> code for preparing for trained code, But I DONT know how to apply to total dataset
model = Unet('resnet34', input_shape=(416, 608, 3), encoder_weights='imagenet')
from keras.preprocessing.image import ImageDataGenerator, load_img from keras.utils import to_categorical from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt import random import matplotlib.pyplot as plt import random sample = random.choice(x_train) image = load_img("/content/gdrive/My Drive/dataset1/dataset1/images_prepped_train/"+sample) plt.imshow(image) -> just mounting for google-drive of dataset, and checking image
from segmentation_models import Unet from segmentation_models.backbones import get_preprocessing from segmentation_models.losses import bce_jaccard_loss from segmentation_models.metrics import iou_score
BACKBONE = 'resnet34' preprocess_input = get_preprocessing(BACKBONE)
x_train = preprocess_input(x_train) x_test = preprocess_input(x_test)
model = Unet(BACKBONE, encoder_weights='imagenet') model.compile('Adam', loss=bce_jaccard_loss, metrics=[iou_score])
fit_generator
here: https://keras.io/models/sequential/#fit_generatormodel.fit( x=x_train, y=y_train, batch_size=32, epochs=10, validation_data=(x_test, y_test), )
And I got this error : AttributeError: 'str' object has no attribute 'ndim'
At first, at the other github, they said I have to preprocess the data for training using this code:
import cv2 import numpy as np
ann_img = np.zeros((30,30,3)).astype('uint8') ann_img[ 3 , 4 ] = 1 # this would set the label of pixel 3,4 as 1
cv2.imwrite( "ann_1.png" ,ann_img ) -> But I dont know how to apply to in my total code
Please help me !!!
Take some courses, you have to improve your python skills at least.
Every time you create a new model by defining
model = ...
And all previous models are discarded. You have to take kwargs that suit to your case and define model just once, in README there are three different independent examples (one for each particular case).
Thank you for your sharing. I think it is really effective API. But I got a problem When I apply to the CIFAR 10 images, I got this error. How I can fix it?
Train on 50000 samples, validate on 10000 samples Epoch 1/10 49984/50000 [============================>.] - ETA: 0s - loss: -55.6413 - iou_score: 4.4150
InvalidArgumentError Traceback (most recent call last)