PixelLib icon indicating copy to clipboard operation
PixelLib copied to clipboard

Models Segmenting Nothing ,But Why ?

Open nikkisingh111333 opened this issue 3 years ago • 10 comments

Hey i m new dude here, just a simple guy following PixelLib docs correctly ,accurately...i have tried all models MaskRCNN, XceptionMaskCnn ,PascalVOC model

and almost all output are like this:

This the output of Xception segmentation version img(4)

This the output of MaskRCNN model trained on COCO img(3)

OUTPUT of handbag image on MaskRCNN COCO model: img(5)

Same out put in pascal voc model

ENVIORNMENT i m using

-Google Colab with Online GPU just these two library -!pip install imgaug -!pip install pixellib --upgrade

And heres the code ..Looks Familiar Right? import pixellib from pixellib.instance import instance_segmentation import cv2 segment_image = instance_segmentation() segment_image.load_model("/content/drive/MyDrive/ColabNotebooks/XceptionSegmentationMaskRcnn/deeplabv3_xception65_ade20k.h5") segment,output=segment_image.segmentImage("/content/sample_data/carroad.jpg",show_bboxes=True) #cv2.imshow(output) print(output) cv2.imwrite("img.jpg", output) cv2.waitKey(0)

also tested Library on VideoCapture LIVE not giving results either ..just random colors all over the image nothing else

Please tell me what i m doing wrong...am i missing Something..? @ayoolaolafenwa

nikkisingh111333 avatar Oct 24 '21 10:10 nikkisingh111333

Hello, I was following these docs here: https://pixellib.readthedocs.io/en/latest/custom_inference.html I experienced the same kind of random colors. Downgrading to tensorflow 2.5 fixed it.

Rexbas avatar Oct 24 '21 19:10 Rexbas

i dont know which version should i install tensorflow 2.5.0-GPU or WIthout gpu..please tell me? i have tried tensoflow 2.5.0-GPU throwing me this error ImportError: cannot import name 'MapVectorizationOptions' from 'tensorflow.python.data.experimental.ops.optimization_options' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/experimental/ops/optimization_options.py) what should i do? i m installing this PixelLib !pip install pixellib --upgrade

EDIT currently ,my python version is 3.7 tensorflow version:2.6.0 while downgrading tf its always throwing this error may be not compatible with python 3.7 ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/normalization/__init__.py) please help me.

nikkisingh111333 avatar Oct 25 '21 10:10 nikkisingh111333

Hello, I was following these docs here: https://pixellib.readthedocs.io/en/latest/custom_inference.html I experienced the same kind of random colors. Downgrading to tensorflow 2.5 fixed it. i dont know which version should i install tensorflow 2.5.0-GPU or WIthout gpu..please tell me? i have tried tensoflow 2.5.0-GPU throwing me this error

ImportError: cannot import name 'MapVectorizationOptions' from 'tensorflow.python.data.experimental.ops.optimization_options' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/data/experimental/ops/optimization_options.py) what should i do? i m installing this PixelLib !pip install pixellib --upgrade

EDIT currently , my python version is 3.7 tensorflow version:2.6.0 while downgrading tf to 2.5.1

Its always throwing this error may be not compatible with python 3.7 ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/normalization/__init__.py) please help me.

nikkisingh111333 avatar Oct 25 '21 12:10 nikkisingh111333

This are my versions on a PC without a Nvidia GPU:

C:\Users\User>python
Python 3.9.7 ...
...
>>> import tensorflow as tf
..
>>> print (tf.__version__)
2.5.0
>>> import torch
>>> print (torch.__version__)
1.10.0+cpu
>>> import cv2
>>> print (cv2.__version__)
4.5.4-dev
>>>
>>>

If you have no Nvidia GPU, install tensorflow: pip install tensorflow==2.5.0

The installation on a PC with a Cuda GPU is a bit more tricky.

I installed everything without conda.

wisi-testpilot avatar Oct 25 '21 17:10 wisi-testpilot

In colab i dont know how to install it all together i have tried many methods but not working .. i have installed tensorflow 2..5.0 and also installed CUDA 11.2 on GOOGLE COLAB...NOT WORKING AT ALLGETTING ERROR ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/normalization/__init__.py) while importing Tensorflow please help me in fixing this issue

nikkisingh111333 avatar Oct 26 '21 13:10 nikkisingh111333

I have no experience with colab. You can only install CUDA and Cudnn on computer with Nvidia graphics cards. First install Tensorflow without Cuda to see whether it works basically. For the installation of tensorflow on a Gaming PC with a RTX 3060 graphic card I followed basically this tutorial: https://medium.com/analytics-vidhya/tensorflow-gpu-how-to-install-tensorflow-with-nvidia-cuda-cudnn-and-gpu-support-on-windows-6158cffc1c29

wisi-testpilot avatar Oct 26 '21 15:10 wisi-testpilot

Sir i dont have GPU thats why i m using colab kindly please help me on Installing tensorflow 2.5.0 with cuda 11.2 on Colab or Forward this issue ....if you like i will appreciate that...

nikkisingh111333 avatar Oct 26 '21 18:10 nikkisingh111333

!python --version
!pip install imgaug
!pip install pixellib --upgrade
!nvidia-smi -L
#!pip install tensorflow==2.4 # uncomment to fix
import tensorflow as tf
print (tf.__version__)
!wget "https://github.com/ayoolaolafenwa/PixelLib/releases/download/1.0.0/Nature_model_resnet101.h5"
!wget "https://pixellib.readthedocs.io/en/latest/_images/butterfly.jpg"
import pixellib
from pixellib.instance import custom_segmentation
segment_image = custom_segmentation()
segment_image.inferConfig(num_classes= 2, class_names= ["BG", "butterfly", "squirrel"])
segment_image.load_model("Nature_model_resnet101.h5")
segment_image.segmentImage("butterfly.jpg", show_bboxes=True, output_image_name="sample_out.jpg")
from IPython import display
display.Image("sample_out.jpg")

If you put all the code above on colab you will reproduce the random color problem. If you uncomment the line and run again you will install tensorflow 2.4.0 (2.5.0 resulted in an error). It should work now. Don't forget to select GPU runtime type to use the GPU.

Rexbas avatar Oct 26 '21 18:10 Rexbas

Its not working either still giving me this un usual error while importing everthing else u described above. ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/normalization/__init__.py) why its giving his error?

EDIT: it worked i have removed all my NEW cuda version i have installed previosly now its segmenting and working good no prob at all..

One more thing ..will this setup works on All model or just maskRcnn.h5

nikkisingh111333 avatar Oct 27 '21 11:10 nikkisingh111333

I have same issue too , can not use colab

pedinil avatar Apr 24 '24 07:04 pedinil