Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. can't find '__main__' module in 'crop_images_Final.py'
  2.  
  3. #!/usr/bin/env python3
  4. # -*- coding: utf-8 -*-
  5.  
  6. import sys
  7. import getopt
  8. import os
  9. import glob
  10. import datetime
  11. import numpy as np
  12. # import pandas as pd
  13. from PIL import Image
  14. # import matplotlib.pyplot as plt
  15. import xml.etree.ElementTree as ET
  16.  
  17. def crop(image_path,coords,saved_location,categorie,outputname,label,log=False):
  18. import os
  19. from PIL import Image
  20.  
  21. if '.JPG' in image_path or '.jpg' in image_path:
  22. # controleer of output map bestaat
  23. if not os.path.exists(saved_location):
  24. os.makedirs(saved_location)
  25. # print('Created folder for crop: {}'.format(saved_location))
  26.  
  27. image_obj = Image.open(image_path)
  28. cropped_image = image_obj.crop(coords)
  29.  
  30. saved_location = os.path.join(saved_location + str(label) + "_" + categorie.replace(" ","_"),'')
  31. # saved_location = saved_location + str(label) + "_" + categorie.replace(" ","_") + '/'
  32.  
  33. if not os.path.exists(saved_location):
  34. os.makedirs(saved_location)
  35. # print('Created folder for crop: {}'.format(saved_location))
  36.  
  37. cropped_image.save(saved_location + outputname, subsampleing=1)
  38.  
  39.  
  40. if __name__ == "__main__":
  41. folder_path = input('Enter folder path?')
  42. labelimg_process(folder_path ,image_crop_size = 200, image_size = 224,log = False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement