Giter Site home page Giter Site logo

catchzeng / tensorflow-unet-labelme Goto Github PK

View Code? Open in Web Editor NEW
25.0 1.0 1.0 2.43 MB

Build U-NET with TensorFlow 2 and train a dataset annotated with labelme

Home Page: https://makeoptim.com/en/deep-learning/yiai-unet

Makefile 0.02% Python 0.59% Jupyter Notebook 99.40%
unet unet-keras unet-segmentation unet-image-segmentation tensorflow tensorflow2 labelme

tensorflow-unet-labelme's Introduction

tensorflow-unet-labelme

The easiest way to train a U-NET Image Segmentation model using TensorFlow and labelme

Build U-Net with TensorFlow 2 and train a dataset annotated with labelme.

Installation

If you are using macOS, you need to execute the following command before installation.

❯ brew install pyqt

Execute the following command to install the unet environment.

❯ conda create -n unet -y python=3.9 && conda activate unet && pip install -r requirements.txt

Datasets

Annotate images

Annotate images with labelme.

Generate VOC format dataset

Save the labeled training data to datasets/train, and create a new datasets/labels.txt, the content is the classification names, see https://github.com/wkentaro/labelme/tree/main/examples/semantic_segmentation

Execute the following command to generate the voc dataset.

❯ make voc

Note: If you want to regenerate and overwrite the old one, you can execute the following command.

❯ make re-voc

Training

Train and predict with unet.ipynb

tensorflow-unet-labelme's People

Contributors

catchzeng 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

Watchers

 avatar

Forkers

stjordanis

tensorflow-unet-labelme's Issues

Colors on predicted map

Hey. On your README there is picture of predicted mask - objects with different labels has different colors but when I execute code, all colors are the same. How to fix that?

Some questions about code

Thanks a lot for sharing the code and it's really useful for me.
I have two questions about the code.

  1. In function cvtColor (if len(np.shape(image)) == 3 and np.shape(image)[-2] == 3) should we change np.shape(image)[-2] == 3 to np.shape(image)[-1] == 3? I don't quite understand the meaning here.
  2. I have run code with my own dataset and it has pretty good performance, however there was an overfitting. Is Earlystop a good way to avoid overfitting?

Looking forward to your answer. Thanks

UnknownError: Graph execution error: 2 root error(s) found. (0) UNKNOWN: FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Voc data/Train_new7/JPEGImages/I.jpg' Traceback (most recent call last):

Hey I am getting this error while Training. Can you please help.. Thanks:)
Screenshot 2022-11-21 at 1 25 33 AM

Epoch 1/100
3/9 [=========>....................] - ETA: 0s - loss: 0.4171 - accuracy: 0.8279/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:29: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:44: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:57: DeprecationWarning: FLIP_LEFT_RIGHT is deprecated and will be removed in Pillow 10 (2023-07-01). Use Transpose.FLIP_LEFT_RIGHT instead.
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:58: DeprecationWarning: FLIP_LEFT_RIGHT is deprecated and will be removed in Pillow 10 (2023-07-01). Use Transpose.FLIP_LEFT_RIGHT instead.

UnknownError Traceback (most recent call last)
in
15 validation_steps=VALIDATION_STEPS,
16 validation_data=val_batches,
---> 17 callbacks=[displayCallback, checkpointCallback])
18
19 model.save('logs/the-last-model.h5', overwrite=True)

1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
53 ctx.ensure_initialized()
54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:

UnknownError: Graph execution error:

2 root error(s) found.
(0) UNKNOWN: FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Voc data/Train_new7/JPEGImages/I.jpg'
Traceback (most recent call last):

File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/script_ops.py", line 271, in call
ret = func(*args)

File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py", line 642, in wrapper
return func(*args, **kwargs)

File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/ops/dataset_ops.py", line 1004, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))

File "/usr/local/lib/python3.7/dist-packages/keras/engine/data_adapter.py", line 830, in wrapped_generator
for data in generator_fn():

File "/usr/local/lib/python3.7/dist-packages/keras/engine/data_adapter.py", line 956, in generator_fn
yield x[i]

File "", line 25, in getitem
name +'.jpg'))

File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 3068, in open
fp = builtins.open(filename, "rb")

FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Voc data/Train_new7/JPEGImages/I.jpg'

 [[{{node PyFunc}}]]
 [[IteratorGetNext]]

(1) CANCELLED: Function was cancelled before it was started
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_18667]

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.