GeezerVison is showing github.com — Merge pull request #41 from mspandit/pil-image-fix · iamsile/DeepLearningTutorials@32d2ce1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: code/cA.py +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 42 | 42 | from logistic_sgd import load_data | 43 | 43 | from utils import tile_raster_images | 44 | 44 |
| 45 | | -import PIL.Image | | 45 | +try: | | 46 | + import PIL.Image as Image | | 47 | +except ImportError: | | 48 | + import Image | 46 | 49 |
| 47 | 50 |
| 48 | 51 | class cA(object): | @@ -290,7 +293,7 @@ def test_cA(learning_rate=0.01, training_epochs=20, | 290 | 293 |
| 291 | 294 | print >> sys.stderr, ('The code for file ' + os.path.split(__file__)[1] + | 292 | 295 | ' ran for %.2fm' % ((training_time) / 60.)) | 293 | | - image = PIL.Image.fromarray(tile_raster_images( | | 296 | + image = Image.fromarray(tile_raster_images( | 294 | 297 | X=ca.W.get_value(borrow=True).T, | 295 | 298 | img_shape=(28, 28), tile_shape=(10, 10), | 296 | 299 | tile_spacing=(1, 1))) | |
Collapse file Copy file name to clipboardExpand all lines: code/dA.py +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 45 | 45 | from logistic_sgd import load_data | 46 | 46 | from utils import tile_raster_images | 47 | 47 |
| 48 | | -import PIL.Image | | 48 | +try: | | 49 | + import PIL.Image as Image | | 50 | +except ImportError: | | 51 | + import Image | 49 | 52 |
| 50 | 53 |
| 51 | 54 | class dA(object): | @@ -306,7 +309,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 306 | 309 | print >> sys.stderr, ('The no corruption code for file ' + | 307 | 310 | os.path.split(__file__)[1] + | 308 | 311 | ' ran for %.2fm' % ((training_time) / 60.)) | 309 | | - image = PIL.Image.fromarray( | | 312 | + image = Image.fromarray( | 310 | 313 | tile_raster_images(X=da.W.get_value(borrow=True).T, | 311 | 314 | img_shape=(28, 28), tile_shape=(10, 10), | 312 | 315 | tile_spacing=(1, 1))) | @@ -352,7 +355,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 352 | 355 | os.path.split(__file__)[1] + | 353 | 356 | ' ran for %.2fm' % (training_time / 60.)) | 354 | 357 |
| 355 | | - image = PIL.Image.fromarray(tile_raster_images( | | 358 | + image = Image.fromarray(tile_raster_images( | 356 | 359 | X=da.W.get_value(borrow=True).T, | 357 | 360 | img_shape=(28, 28), tile_shape=(10, 10), | 358 | 361 | tile_spacing=(1, 1))) | |
Collapse file Copy file name to clipboardExpand all lines: code/rbm.py +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | import cPickle | 8 | 8 | import gzip | 9 | 9 | import time | 10 | | -import PIL.Image | | 10 | + | | 11 | +try: | | 12 | + import PIL.Image as Image | | 13 | +except ImportError: | | 14 | + import Image | 11 | 15 |
| 12 | 16 | import numpy | 13 | 17 |
| @@ -396,7 +400,7 @@ def test_rbm(learning_rate=0.1, training_epochs=15, | 396 | 400 | # Plot filters after each training epoch | 397 | 401 | plotting_start = time.clock() | 398 | 402 | # Construct image from the weight matrix | 399 | | - image = PIL.Image.fromarray(tile_raster_images( | | 403 | + image = Image.fromarray(tile_raster_images( | 400 | 404 | X=rbm.W.get_value(borrow=True).T, | 401 | 405 | img_shape=(28, 28), tile_shape=(10, 10), | 402 | 406 | tile_spacing=(1, 1))) | @@ -459,7 +463,7 @@ def test_rbm(learning_rate=0.1, training_epochs=15, | 459 | 463 | tile_spacing=(1, 1)) | 460 | 464 | # construct image | 461 | 465 |
| 462 | | - image = PIL.Image.fromarray(image_data) | | 466 | + image = Image.fromarray(image_data) | 463 | 467 | image.save('samples.png') | 464 | 468 | os.chdir('../') | 465 | 469 |
| |
Collapse file Copy file name to clipboardExpand all lines: code/utils.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,7 +47,7 @@ def tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0, 0), | 47 | 47 |
| 48 | 48 |
| 49 | 49 | :returns: array suitable for viewing as an image. | 50 | | - (See:`PIL.Image.fromarray`.) | | 50 | + (See:`Image.fromarray`.) | 51 | 51 | :rtype: a 2-d array with same dtype as X. | 52 | 52 |
| 53 | 53 | """ | |
Collapse file Copy file name to clipboardExpand all lines: doc/dA.txt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -588,7 +588,7 @@ save the filters as an image : | 588 | 588 |
| 589 | 589 | .. code-block:: python | 590 | 590 |
| 591 | | - image = PIL.Image.fromarray(tile_raster_images(X=da.W.get_value(borrow=True).T, | | 591 | + image = Image.fromarray(tile_raster_images(X=da.W.get_value(borrow=True).T, | 592 | 592 | img_shape=(28, 28), tile_shape=(10, 10), | 593 | 593 | tile_spacing=(1, 1))) | 594 | 594 | image.save('filters_corruption_30.png') | |
Collapse file Copy file name to clipboardExpand all lines: doc/rbm.txt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -754,7 +754,7 @@ been shown to lead to a better generative model ([Tieleman08]_). | 754 | 754 | # Plot filters after each training epoch | 755 | 755 | plotting_start = time.clock() | 756 | 756 | # Construct image from the weight matrix | 757 | | - image = PIL.Image.fromarray(tile_raster_images( | | 757 | + image = Image.fromarray(tile_raster_images( | 758 | 758 | X=rbm.W.get_value(borrow=True).T, | 759 | 759 | img_shape=(28, 28), tile_shape=(10, 10), | 760 | 760 | tile_spacing=(1, 1))) | @@ -841,7 +841,7 @@ samples at every 1000 steps. | 841 | 841 | tile_spacing=(1, 1)) | 842 | 842 | # construct image | 843 | 843 |
| 844 | | - image = PIL.Image.fromarray(image_data) | | 844 | + image = Image.fromarray(image_data) | 845 | 845 | print ' ... plotting sample ', idx | 846 | 846 | image.save('samples.png') | 847 | 847 |
| |
Collapse file Copy file name to clipboardExpand all lines: doc/utilities.txt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -78,7 +78,7 @@ Tiling minibatches together is done for us by the | 78 | 78 |
| 79 | 79 |
| 80 | 80 | :returns: array suitable for viewing as an image. | 81 | | - (See:`PIL.Image.fromarray`.) | | 81 | + (See:`Image.fromarray`.) | 82 | 82 | :rtype: a 2-d array with same dtype as X. | 83 | 83 |
| 84 | 84 | """ | |
|