Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- can't find '__main__' module in 'crop_images_Final.py'
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- import sys
- import getopt
- import os
- import glob
- import datetime
- import numpy as np
- # import pandas as pd
- from PIL import Image
- # import matplotlib.pyplot as plt
- import xml.etree.ElementTree as ET
- def crop(image_path,coords,saved_location,categorie,outputname,label,log=False):
- import os
- from PIL import Image
- if '.JPG' in image_path or '.jpg' in image_path:
- # controleer of output map bestaat
- if not os.path.exists(saved_location):
- os.makedirs(saved_location)
- # print('Created folder for crop: {}'.format(saved_location))
- image_obj = Image.open(image_path)
- cropped_image = image_obj.crop(coords)
- saved_location = os.path.join(saved_location + str(label) + "_" + categorie.replace(" ","_"),'')
- # saved_location = saved_location + str(label) + "_" + categorie.replace(" ","_") + '/'
- if not os.path.exists(saved_location):
- os.makedirs(saved_location)
- # print('Created folder for crop: {}'.format(saved_location))
- cropped_image.save(saved_location + outputname, subsampleing=1)
- if __name__ == "__main__":
- folder_path = input('Enter folder path?')
- labelimg_process(folder_path ,image_crop_size = 200, image_size = 224,log = False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement