This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
def manage_args(): | |
parser = argparse.ArgumentParser() | |
#positional args | |
parser.add_argument("input_img", help="input image which mask has been computed", type=str) | |
parser.add_argument("input_mask", help="semantic segmentation mask computed from the input image", type=str) | |
parser.add_argument("output_dir", help="output directory where the result will be saved", type=str) | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == "__main__": | |
with open('somefile.txt', 'a') as the_file: | |
the_file.write('Hello\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base = os.path.basename(imagePath) | |
fileName = os.path.splitext(base)[0] | |
os.path.isdir(dataPath) | |
shutil.copyfile(imagePath, newImgPath) | |
os.makedirs(datasetPath) | |
if os.path.isdir(datasetPath): | |
shutil.rmtree(datasetPath, ignore_errors=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
os.chdir(datasetPath) | |
zipf = zipfile.ZipFile('./../pascal_voc_dataset.zip', 'a', zipfile.ZIP_DEFLATED) | |
zipdir('ImageSets/', zipf) | |
zipdir('JPEGImages/', zipf) | |
zipdir('SegmentationClass/', zipf) | |
zipf.close() | |
os.chdir('../') | |
print('[INFO] Archive successfully built.') | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import walk | |
f = [] | |
for (dirpath, dirnames, filenames) in walk(mypath): | |
f.extend(filenames) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img_path = outDirPath + 'images/' + imgName | |
img = cv2.imread(img_path, cv2.IMREAD_COLOR) | |
'''FIRST VERSION''' | |
mask = cv2.cvtColor(mask, cv2.COLOR_RGB2GRAY) | |
dest = cv2.bitwise_and(img, img, mask = mask) | |
for coordinates in coordinatesList: | |
coords = coordinates[:len(coordinates)-1] | |
#ANCIEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pour faire un clean d'un .sh édité avec un éditeur de texte standard (different de vi) | |
tr -d '\r' < export.sh > export_clean.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import etree | |
def getSifts(xmlFilePath): | |
doc = etree.parse(xmlFilePath) | |
pags = doc.xpath('//PAG') | |
pag = pags[0] | |
sifts = pag.xpath('SIFTMATCHER') | |
return sifts | |
for sift in sifts : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drawMask(width, height, coordinatesList): | |
mask = np.zeros((height,width,3), np.uint8) | |
color = (255,255,255) | |
for coordinates in coordinatesList: | |
cv2.fillConvexPoly(mask, np.array(coordinates, 'int32'), color) | |
return mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.digitalocean.com/community/tutorials/how-to-handle-plain-text-files-in-python-3 | |
#from list of tuples | |
class Person(object): | |
def __init__(self, name, profession): | |
self.name = name | |
self.profession = profession | |
people = [Person("Nick", "Programmer"), Person("Alice","Engineer")] | |
professions = dict([ (p.name, p.profession) for p in people ]) |
OlderNewer