Visualization of image data under Python folder

Source: Internet
Author: User

Python folders like data visualization

  1. Import Matplotlib.pyplot as Plt
  2. Import Matplotlib.image as Mpimg
  3. Import NumPy as NP
  4. Import Urllib2
  5. Import Urllib
  6. Import OS
  7. Import Shutil
  8. Subdir= "/7"
  9. Homedir = OS.GETCWD () + subdir
  10. # "/home/haoyou/dev/last_caffe_with_stn/myprojects/spn-mnistcluttered/mnist-cluttered/" +subdir
  11. Import OS
  12. def walk_dir (dir,fileinfo,topdown=true):
  13. For root, dirs, files in Os.walk (dir, topdown):
  14. For name in Files:
  15. Print (Os.path.join (name))
  16. Fileinfo.write (Os.path.join (root,name) + ' \ n ')
  17. For name in dirs:
  18. Print (Os.path.join (name))
  19. Fileinfo.write (' + os.path.join (root,name) + ' \ n ')
  20. FileInfo = open (homedir+ '/list.txt ', ' W ')
  21. Walk_dir (Homedir,fileinfo)
  22. f = open (homedir+ "/list.txt", "R")
  23. While True:
  24. For I in Range (1,101):
  25. line = F.readline ()
  26. If line:
  27. Line=line.strip ()
  28. Plt.subplot (10,10,i)
  29. Lena = Mpimg.imread (line)
  30. Plt.imshow (lena,cmap= ' Gray ')
  31. Plt.axis (' off ')
  32. Else
  33. Break
  34. Plt.show ()
  35. # for line in F:
  36. # #pass # do something here
  37. # Line=line.strip ()
  38. # Print (line)
  39. # Lena = Mpimg.imread (line)
  40. F.close ()

Python folders like data visualization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.