Comments (6)
@ahundt thank you.
It is working fine after vectorizing binarylab for loop.
It was taking 40% of batch generation time.
Thanks again.
from keras-fcn.
@hilal-t Happy to hear it, what did the improved version look like?
I'll close this since it seems your problem is solved.
from keras-fcn.
@hilal-t If you set everything correctly it shouldn't be very slow since your input size is not considerably larger than the original one. Can you provide more information, for instance, your codes? And how much time exactly does the generator take to process one batch?
from keras-fcn.
Thank you for your reply
the following is what I have added
target_size = (224,224)
dataset = 'test_dataset'
train_file_path = 'data/Seg/train.txt'
val_file_path = 'data/Seg/val.txt'
data_dir = 'data/Seg/train_imgs/'
label_dir = 'data/Seg/label/'
data_suffix='.jpg'
label_suffix='.png'
classes = 2
class_weight = None
data_suffix='.jpg'
label_suffix='.png'
input_shape=(224,224,3)
batchnorm_momentum=0.9
ignore_label = None
label_cval = 0
loss_shape = (target_size[0] * target_size[1] , classes,)
model_name = 'unet'
batch_size =64
batchnorm_momentum = 0.95
epochs = 250
lr_base = 0.01 * (float(batch_size) / 16)
lr_power = 0.9
model=get_unet()
model.compile(optimizer='sgd', loss='categorical_crossentropy',metrics=['accuracy'])
train_datagen = SegDataGenerator(zoom_range=0.,
zoom_maintain_shape=True,
crop_mode='none',
crop_size=None,
rotation_range=0.,
shear_range=0,
horizontal_flip=False,
channel_shift_range=0.,
rescale=1/255.,
fill_mode='constant',
label_cval=0)
val_datagen = SegDataGenerator()
train_generator= train_datagen.flow_from_directory(
file_path=train_file_path,
data_dir=data_dir, data_suffix=data_suffix,
label_dir=label_dir, label_suffix=label_suffix,
classes=classes,
target_size=target_size, color_mode='rgb',
batch_size=batch_size, shuffle=True,
loss_shape=loss_shape,
ignore_label=ignore_label,
# save_to_dir='Images/'
)
history = model.fit_generator(
generator=train_generator,
steps_per_epoch=get_file_len(train_file_path),
epochs=epochs,
callbacks=callbacks,
workers=4,
class_weight=class_weight
)
`
I have added the following to the SegDataGenerator
def binarylab(labels, size=224, nb_class=2):
y = np.zeros((size,size,nb_class))
for i in range(size):
for j in range(size):
if labels[i,j]==0 :
y[i,j,0]=1
else:
y[i,j,1]=1
return y
if self.ignore_label:
y[np.where(y == self.ignore_label)] = self.classes
y = binarylab (y, 224, 2)
if self.loss_shape is not None:
y = np.reshape(y, self.loss_shape)
batch_x[i] = x
batch_y[i] = y
this is example of the output
2691/38621 [=>............................] - ETA: 134460s - loss: 0.6930 - acc: 0.5071
from keras-fcn.
Try using a profiling tool on both your disk and the python code to see the source of the problem and post the results. Then we can determine how to fix it.
Also are you on an HDD or SSD?
from keras-fcn.
Also you will definitely need to vectorize that binary lab for loop consult google/stack overflow for details
from keras-fcn.
Related Issues (20)
- AttributeError: 'SegDirectoryIterator' object has no attribute 'next' HOT 14
- error when run "python data_pascal_voc.py pascal_voc_setup" HOT 2
- sparse_categorical_crossentropy vs binary_crossentropy_with_logits
- in resize_images_bilinear(X, height_factor, width_factor, target_height, target_width, data_format) TypeError: unsupported operand type(s) for *: 'NoneType' and 'int' HOT 4
- models.py HOT 2
- AttributeError: 'SegDirectoryIterator' object has no attribute 'next' HOT 4
- Comparison of models
- Dataset & start HOT 1
- Strange results from inference.py HOT 1
- reorganized for easier use
- checkpoint_weights.hdf5 ??? HOT 17
- could not read remote repository HOT 1
- I want to use my windows10 Ipython to run my datasets, but it shows an error : UnboundLocalError: local variable 'lr' referenced before assignment HOT 4
- Hello, I also have this problem, I want to train my data set, but the picture of my data set is jpg, the label is png, can I use this data set for training, if I can, I need the program What changes have been made, thank you HOT 1
- Unable to run 'train.py', the program ends directly
- Regarding the upsampling layer HOT 2
- ModuleNotFoundError: No module named 'tf_image_segmentation' HOT 3
- NameError: name 'transform_matrix_offset_center' is not defined HOT 2
- weights
- Inference gives black output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-fcn.