Tutorial 27 - Using glob to read multiple files in python

Поділитися
Вставка
  • Опубліковано 28 жов 2024

КОМЕНТАРІ • 64

  • @raht9578
    @raht9578 2 роки тому

    this was awesome
    really feels like I am learning something

    • @ZEISS_arivis
      @ZEISS_arivis  2 роки тому

      That is the goal, to make sure you learn :)

  • @sayanbhattacharya3233
    @sayanbhattacharya3233 3 роки тому

    Many thanks for this series.. Excellent quality ..:) Please make more content, this is going really cool!

  • @hassanmusa155
    @hassanmusa155 4 роки тому +1

    Thank you very much Sir for this lecture. Here is my question. How can I design this code in such a way without specifying file location so everyone can run it on his computer and access data from his directory

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      Not sure what exactly you're asking for. Do you want to deploy your code so others can use it? If so, you need to convert your code into an application. If you are familiar with Docker technology then look at apeer.com and see if you can create applications (modules) out of your code.

  • @muhammadrafiq182-HR
    @muhammadrafiq182-HR 2 роки тому

    thank you sir for this amazing video.
    I have a question , how to load images from two folder in for loop and do something with it .

  • @prathibhapillai5611
    @prathibhapillai5611 3 роки тому

    Thanks Sir. Time saving and life saving.....

  • @pampadey6488
    @pampadey6488 3 роки тому

    I have one question.
    When the code is starting read the images from the file, it is not reading in order. First it reads image_1 then image_10,.....,image_20,image_2,....
    But I need the order of images.
    Would you please suggest me to remove this issue?

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      It reads images based on file names. One way to make them in the sequence you want is to rename your original files. Or you can write a few lines of code in python to first read file names, e.g. into a Pandas dataframe. Then you can sort the dataframe however you want it to read the files and then read files based on the names from your dataframe.

  • @rahulsinha2987
    @rahulsinha2987 4 роки тому

    Thanks a lot for this video, I have a small issue which I am facing. I am extracting the PDF table/nested table data in python using Tabula. Could you please let me know how to user for loop activity for this scenario where I could be able to read all the PDF data from the specific folder and the create a CSV with the same name as PDF.
    Eg: 3 PDF files are there as (A.pdf, B.pdf, C.pdf) reading all pdf and creating the excel with the same name A, B, and C) :)

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      Are you asking about reading a file, doing some stuff and then saving the output with same file name but different extension. In that case this video and the next one should have answered it. Use glob to read files, within the for loop do your operation using Tabula and assign same name to the output from Tabula that you plan on saving. Now continue the loop to read the next file and perform same operations.

  • @cheechunglee9631
    @cheechunglee9631 4 роки тому

    Thanks your tutorials are great and very detailed. I have a task I need to do which is to count the number of files in each class of dog breed files. Plot the results so that I can generate a frequency distribution of the number of images I have in each dog breed class.
    Do you have any tutorial of this?
    I found all the different dog breed classes with classes=os.listdir('dogImages/train'). With one example as '119.Petit_basset_griffon_vendeen'. Not sure how I can use this list of classes with the substring to match the filenames. Count the number of matches and store the list of classes and its number of matches in a dataframe.
    There after I can plot a frequency distribution for the classes. Would you have a suggestion on how to do this?

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      If you are trying to count the number of files starting with or containing some specific text then you can search for those files and capture the names as a list. Then look at the length of each list to count the total number of files in each class. Then you can capture them into a pandas dataframe and plot. Here is a couple of lines for the first part.
      import glob
      import pandas as pd
      b_list = glob.glob('images/b*.*') #Rerurns a list of file names starting with b
      c_list = glob.glob('images/c*.*') #Rerurns a list of file names starting with c
      h_list = glob.glob('images/h*.*') #Rerurns a list of file names starting with h
      b = len(b_list) #Number of files starting with b
      c = len(c_list)
      h = len(h_list)

  • @AnNguyen-lm5dm
    @AnNguyen-lm5dm 2 роки тому

    I have error with out of range :(, don't know why. I only can call li[0] but it's error with li[1], even I have 2 files in the folder

  • @SjaduAC
    @SjaduAC 4 роки тому

    Thank you very much. Your tutorial helped me a lot!

  • @karamabdullah7867
    @karamabdullah7867 3 роки тому

    how can i save and then load the list Or dict of images in another file like matlab there is save X X and then there is load X ,, Please

  • @salarghaffarian4914
    @salarghaffarian4914 3 роки тому

    thanks so much for this valuable video. I was wondering if you could make a video for 'Mask-RCNN' for segmenting images. Thank you so much!

  • @akashpanday3583
    @akashpanday3583 4 роки тому

    Can I use glob.glob() if my files are not in the same directory?

  • @XinhLe
    @XinhLe 2 роки тому

    I was trying the recursive option but it never works, so i change to use os.walk

    • @ZEISS_arivis
      @ZEISS_arivis  2 роки тому

      os.walk is also a good way to achieve the task.

  • @nembilwiwamashudu7692
    @nembilwiwamashudu7692 2 роки тому

    how can i combine netcdf files from multiples directories to one single netcdf

  • @ihgnmah
    @ihgnmah 4 роки тому

    Thank you, sir! Great tutorial

  • @sung-binpark3807
    @sung-binpark3807 3 роки тому

    would you give me some hit why my_list has[None, None, None, None, None, None, None, None, None, None] although I run the for loop? I'm bit lost

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      It says none as it cannot find any images. Please make sure you verify the path and also your current working directory.

  • @pratapsrules
    @pratapsrules 3 роки тому

    sir i have a grey image and when I am reading it with io.imread its showing image in bluish color. please tell me how read exact image ?
    thank you

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому +1

      What are you using to view the image? If it is pyplot from matplotlib then please look into color maps. The default colormap of pyplot is not gray, so it makes your image appear colorful but your data is still 'gray' as you will notice that the numpy array itself does not have 3 channels. In any case, if you want to view image in gray then add this to your plt.imshow command... cmap='gray'. SO if your image is called img then it would be: plt.imshow(img, cmap='gray')

  • @abigailwaring4720
    @abigailwaring4720 2 роки тому

    How do we use this to find all the files in different directories?

  • @pampadey6488
    @pampadey6488 3 роки тому

    Thank you. It helps me a lot.

  • @zarintasnim2634
    @zarintasnim2634 3 роки тому

    Thank you sir. I have a question. what if one don't need to read all the 10 images just like want to load 5 images. Then what should we do?

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому +1

      You can use for or while loop to loop thorough each image and exit when a predefined count is reached. Please watch the videos on for and while loops.

    • @zarintasnim2634
      @zarintasnim2634 3 роки тому

      @@ZEISS_arivis Thank you so much sir for your reply. Definitely gonna check your other videos. They are really great.

  • @tilkesh
    @tilkesh 2 роки тому

    Thank you very much

  • @puvenes1994
    @puvenes1994 4 роки тому +1

    thank you so much sir..

  • @hassanmusa155
    @hassanmusa155 4 роки тому

    This answer is really relevant to what I am busy searching for. All I need is to use python and its libraries to design a program that will read a serious of drone Images and detect, adjust, correct and register the images to become a single seamless image of search and rescue operation. This the intention. So I beg that anything relevant to this I am interested. I need help because I am from Geomatics background

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      The best way to register multiple images is by using pystackreg library. Please watch our video on this topic (Tutorial 47). You can write a for loop to register images but the best approach would be to stack all images into a single tiff file and then use pystackreg for registration. That way you can register not only by individual images but also by calculating mean of a stack of images. You can find more information here: pypi.org/project/pystackreg/

  • @kamleshrathor1866
    @kamleshrathor1866 2 роки тому

    how to take 5 img from 10 img of a specific number inside folder

  • @ericksonboang
    @ericksonboang 3 роки тому

    Lets say I have 100 images in a directory (000.jpg upto 100.jpg), but I only wan to process 050.jpg upto 100.jpg. How do I do that with glob?

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      One way to do this is by adding all images into a numpy array and then selecting images from 50 and above from the array.
      Example, for 100 color images that are 256x256 in size your numpy array would be (100, 256, 256, 3).
      Other way is to capture all file names from glob into a list and then select files from the list for further processing.

  • @deniltondonizetti2215
    @deniltondonizetti2215 4 роки тому

    Thank you, Sir!

  • @avachavoshi574
    @avachavoshi574 4 роки тому

    Thank you. it really helped me.

  • @bakethere8993
    @bakethere8993 2 роки тому

    Hello, how would I batch convert hundreds of .tif files to .czi?

    • @ZEISS_arivis
      @ZEISS_arivis  2 роки тому

      You cannot write .czi files, yet. Zeiss may publish a library soon to allow for czi writing. As of now you can convert from czi to tif. If you want to write czi files, look into downloading the free version of ZEN (called ZEN Lite).

  • @gauravms2799
    @gauravms2799 3 роки тому

    good video

  • @surflaweb
    @surflaweb 3 роки тому

    Glob only read jpg images? I'm using imutils

    • @vargas4762
      @vargas4762 3 роки тому +1

      I guess it read any type of image, you can specified de extension of your archive like this
      path_firs = '\\Users\\tester\\Desktop\\Myfiles\\'
      all_files_csv = glob.glob(path_firs + '*.csv')
      At the end of all_files_csv you can change the extension (csv) to whatever you want

    • @surflaweb
      @surflaweb 3 роки тому +1

      @@vargas4762 Thanks but imutils Is ok

  • @MMKhan-tk4ir
    @MMKhan-tk4ir 4 роки тому

    How to import cv2 what is that in python? i want to read text file?

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      Please watch all videos as a course, otherwise things may not make sense.
      By the way, cv2 (opencv) is for reading images, not text files.

    • @uroosasehar
      @uroosasehar 3 роки тому

      use pandas to read txt files..

  • @nowrozimohammad
    @nowrozimohammad 3 роки тому

    it is not possible for me to import cv2!!

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      Please make sure you have installed opencv.

  • @sujaymhaske6679
    @sujaymhaske6679 3 роки тому

    please help me , i want to perform easyocr on 1 million images , please help me ,please

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      Follow the same process as in this video except when it comes to processing images you are going to use easyocr to extract text from images. You will be capturing result from each image and write to a pandas dataframe.

    • @ZEISS_arivis
      @ZEISS_arivis  3 роки тому

      Here are a few lines of code to read multiple images in a folder (images folder), perform OCR and capture text from each image into a dataframe. You can save the dataframe to csv if you want.
      #Read multiple images in a directory, extract text using OCR and capture it in a pandas dataframe.
      import cv2
      import glob
      import pandas as pd
      #select the path
      path = "images/*.*"
      img_number = 1
      reader = easyocr.Reader(['en']) #English
      df=pd.DataFrame()
      for file in glob.glob(path):
      print(file) #just stop here to see all file names printed
      img= cv2.imread(file, 0) #now, we can read each file since we have the full path
      results = reader.readtext(img, detail=0, paragraph=True) #Set detail to 0 for simple text output
      df = df.append(pd.DataFrame({'image': file, 'detected_text': results[0]}, index=[0]), ignore_index=True)
      img_number +=1

  • @sangeetadnyaneshwarpalekar9889
    @sangeetadnyaneshwarpalekar9889 4 роки тому

    can you please provide the codes

    • @ZEISS_arivis
      @ZEISS_arivis  4 роки тому

      Yes, working on it, please give us a week.

  • @rameshwarsingh5859
    @rameshwarsingh5859 3 роки тому

    YOR GITHUB IS FILLED WITH RELIABLE CODE SIR...