Code Monkey home page Code Monkey logo

unet-rgb's Introduction

unet-rgb

Keras(TF backend) implementation of unet for RGB pictures.


Overview

Requirement

  • OpenCV
  • Python 2.7
  • Tensorflow-gpu
  • Keras

Data

You can download all data here:https://pan.baidu.com/s/1WqmR-9jodyyUnLRCK6pcVw password: 533h

CamVid Data:https://github.com/preddy5/segnet/tree/master/CamVid

Howtouse

  • extract downloaded data to corresponding directories
  • run python data.py to generate 3 .npy files or you can download them to npydata
  • run python unet.py to train, you can change hyperparameters on your own situation
  • run python test2mask2pic.py to get test results(pictures)

Results

After training about 30 epochs, loss goes to about 0.005.The results seems OK! But the edges look a bit rough. I think that is Unet's own limitation.

img/0test.jpg

img/0label.jpg

Camvid

  • run python data_camvid.py
  • run python unet_camvid.py
  • run python predict_camvid.py

After 50 epochs training, loss goes to about 4e-04 and acc is 0.9644.

img/1test.png img/1label.png

About

Unet is mostly used in medical areas. I used this model for semantic segmentation of satellite remote sensing images in real work and the result is not bad. I think one of the reason is that it's a coarse-grained task like medical image analysis. Of course, enough labeled images are necessary.

Reference

https://github.com/zhixuhao/unet

unet-rgb's People

Contributors

shawda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unet-rgb's Issues

Camvid training annotations

OK, I have finally run your scripts well, but I'm still confused about the training annotations, why is that trainannots are all black and grey images, I have tried to print out the values, but only 1 and nothing.
How do I train my own datasets, with rgb image how to convert its mask, thank you.

training and testing on rectangular images

Hello ShawDa,

Thanks for sharing your code! I've been playing around with UNet in Python. I've been wondering how you manage to train and test on images that aren't perfect squares? If I send in a not-square input image, I'll get a squashed square output. Of course, resizing it doesn't help much...

Any insight you have to share is appreciated. Thanks!

Implementation for satellite imagery?

This is not really an issue, but more of a request :) You write you made an implementation of unet-rgb for satellite imagery. Is this a repository you'd consider sharing?

about save_img in unet_camvid.py

Scikit-image (skimage) has a method called color.label2rgb which converts to an array of labels to a colored image. So you don't have to implement the coloring algorithm yourself.

Can't get correct result with custom dataset

Hi,
I tried your code with the original carvana images, and it works. Then I prepare a custom dataset which has the same format as the carvana dataset, however, the training can't be converged. Can I send the dataset to you for testing?
Thanks!

No such file or directory: './npydata/imgs_train.npy'

请问我用自己的数据集运行data.py
报的这个错误是什么意思呢
Creating training images...
D:\anaconda\envs\tensorflow\lib\site-packages\keras_preprocessing\image\utils.py:107: UserWarning: grayscale is deprecated. Please use color_mode = "grayscale"
warnings.warn('grayscale is deprecated. Please use '
Done: 0/900 images
Done: 100/900 images
Done: 200/900 images
Done: 300/900 images
Done: 400/900 images
Done: 500/900 images
Done: 600/900 images
Done: 700/900 images
Done: 800/900 images
Traceback (most recent call last):
File "D:/Paper_project/unet-rgb-master/data.py", line 93, in
mydata.create_train_data()
File "D:/Paper_project/unet-rgb-master/data.py", line 41, in create_train_data
np.save(self.npy_path + '/imgs_train.npy', imgdatas)
File "<array_function internals>", line 6, in save
File "D:\anaconda\envs\tensorflow\lib\site-packages\numpy\lib\npyio.py", line 524, in save
file_ctx = open(file, "wb")
FileNotFoundError: [Errno 2] No such file or directory: './npydata/imgs_train.npy'
loading done

Process finished with exit code 1

Making pre processing ?

Hi,

Great post and nicely coded. Your coding is very clear.

If we apply pre processing like k-means before semantic segmentation would it help to segment better ?

TypeError: 'module' object is not callable

Traceback (most recent call last):
File "unet.py", line 137, in
model = myunet.get_unet()
File "unet.py", line 59, in get_unet
merge6 = merge([drop4, up6], mode='concat', concat_axis=3)
TypeError: 'module' object is not callable
can anyone help?

Batch Size

Hello,

Firstly thank you very much for your project. I have a problem about large dataset. I have 10 thousand images and masks.
I can create .npy files. When I run unet.py files with 10 thousand images I get error Memory Usage Exceeds. When I decrease the number of dataset (max 600 images) no any error. I think batch size don't work in model.fit. Do you have any advice or solution?

Best regards.

如何通过直接读图来进行训练?

我按照博主给的代码训练模型,发生了MemoryError,可能是我的数据集比较大加上电脑内存不够,所以我现在想通过直接读取图片的方法来训练模型。请问博主能给一些处理数据的建议吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.