Comments (7)
Well it's an ugly implementation actually... The ignoring_last_label is used for many segmentation datasets like PASCAL VOC or Cityscapes, since they have a 255 label denoting the edge of objects or unknown part that should be ignored. I change 255 to nb_classes in data generator so that it becomes the last label, and then I ignore it in the loss function.
For your case, I think you can simply use a softmax or sigmoid loss (maybe you want to wrap a tensorflow loss instead of directly using the losses from keras, i'm not sure).
(modify: softmax of sigmoid => softmax or sigmoid)
from keras-fcn.
Thank you for your response^^.
I save img&label generated by SegDataGenerator
I find that the label_cval,
set 255. The label'.png' has white background around. So maybe it ignore this label? I'm not sure ....
Also my label'1' area is too small compared with '0'. I'm wondering if it is possible to multiply different weights to different label then calculate loss, changing some parts of the loss function.
from keras-fcn.
Yes by default ignore_label and label_cval are both 255 and it will be ignored.
You can pass a class_weight to fit_generator, note that considering the ignored label, there is actually nb_classes+1 classes. But some paper reports that for segmentation you don't need to deal with the unbalanced samples and it can still get good results, so maybe you can just try not using class_weights first.
from keras-fcn.
Hi @aurora95,
I have a quick question regarding your loss function too I was hoping you could help me out with:
I have my training data: 155x240x4 and my labels: 155x240 (a segmented image), am I still able to use your loss function? I'm unsure because of the following line in your loss function:
- y_true = K.one_hot(tf.to_int32(K.flatten(y_true)), K.int_shape(y_pred)[-1]+1)
where u create a one_hot matrix from your y_train.
EDIT: grammar and phrasing
EDIT2: I'm trying to modify your loss function as I do not wish to remove the last label, I'm running the code but I'm assuming it is this part which removes the label:
-
unpacked = tf.unstack(y_true, axis=-1)
-
y_true = tf.stack(unpacked[:-1], axis=-1)
from keras-fcn.
@Ssica Yes you should be able to use the loss, and yes it's the code that removes the last label
from keras-fcn.
Hi @aurora95
use your loss and accurate funcion, we can fit the model.
But when I want to use the model to predict, the output has nb_classes maps, what should I do?
should I add softmax activation layer then use the argmax?
I'm sorry to bother you ,but I hope that you can give me some short codes to show how to make the (21,w,d) into (1, w, d) martix and whether we need softmax, because i had some issues when I try to implement it. Thanks a lot.
from keras-fcn.
@godissaw You can directly use argmax, since argmax(y) would yield the same result with argmax(softmax(y))
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.