Shutffle (change dict to item and do shutffle) ; Mark id to each person

#!/usr/bin/python
import time
import sys
import os
from os import walk
import random

import numpy as np

if len(sys.argv) != 2:
    print(
        "This script will make img_path --- > person_id  with random \n"
        "For example, for folder 1,  then run:\n "
        " ./xxx.py 1 \n")
    exit()

folder_number = sys.argv[1]
aa = {}
bb = []
person = {}
count = 0

oripath = "./identities_"+folder_number+"/"


for (dirpath, dirnames, filenames) in walk(oripath):
  for dir in dirnames:
     person[dir] = count
     for (dirpath1, dirnames1, filenames1) in walk(oripath+dir):
        for i in filenames1:
            aa.update({dirpath1+"/"+i : count})
     count = count + 1

bb =  aa.items()
random.shuffle(bb)
for k,v in bb:
   print k,"\t\t",v

aa.clear()
person.clear()

 

posted on 2018-01-29 17:02  cdekelon  阅读(110)  评论(0编辑  收藏  举报

导航