Coder Social home page Coder Social logo

learnmachine's People

Contributors

mixmixmix avatar

Watchers

 avatar  avatar  avatar

learnmachine's Issues

In rare case of libpng mismatch OpenCV imread() silently fails to load images

There is sometimes a mismatch between libraries used by different OpenCV versions on your computer.
For instance I originally had 4.1.0 and the following code for loading image works fine:

import cv2
print(cv2.__version__)
a = cv2.imread('./assets/simple_blobs/bloby_478.png')
print(type(a))
4.1.0
numpy.ndarray

However, when I created a new virtual environment with conda-forge::opencv=4.1.2 the png image won't load. The same code produces

4.1.2
NoneType

Without raising any errors.

However when running the same code in REPL we can see the warning that explains everything:
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37

Different versions of opencv are built with different versions of png libraries but they are somehow forced to use the same version, or are outright broken.

That causes first cell in Task B to fail with the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-147208002c1c> in <module>
     16 image_size = 64  # in pixels
     17 number_of_classes = 2 #2-6 - normal blobs. 7-11 more difficult
---> 18 problem = generateBlobsData(imageDir, number_of_classes, number_of_samples, image_size, noiseSize=20)

~/repos/learnmachine/tasks/utils/practice_data.py in generateBlobsData(imageDir, noClasses, trainSamples, imSize, noiseSize, colour)
    106         #add noise
    107         if noiseSize>0:
--> 108             row,col,ch= blob_image.shape
    109             gauss = np.random.normal(0,noiseSize,(row,col,ch))
    110             gauss = gauss.reshape(row,col,ch)

AttributeError: 'NoneType' object has no attribute 'shape'

If you encounter it, try re-setting environment with different version of OpenCV.

windows path issue

KeyError Traceback (most recent call last)
in
16 image_size = 64 # in pixels
17 number_of_classes = 2 #2-6 - normal blobs. 7-11 more difficult
---> 18 problem = generateBlobsData(imageDir, number_of_classes, number_of_samples, image_size, noiseSize=20)

~\OneDrive - Indian Institute of Science\Side\2020-03 Machine-Learning Mix\tasks\utils\practice_data.py in generateBlobsData(imageDir, noClasses, trainSamples, imSize, noiseSize, colour)
98 print(blob_file)
99 blob_class = blob_file.split("/")[-1].split("_")[0]
--> 100 blob_class_int=intblobclass[blob_class]
101 if(noClasses <= blob_class_int):
102 continue

KeyError: 'simple'

typo in task B

print('Correct classification of Logistic Regression: {0.2%}'.format(trueRate)) # Works for 2 cell types only

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.