Advertisement
Guest User

get_pet_labels.py

a guest
Oct 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def get_pet_labels(pet_images):
  2.  
  3. in_files = listdir("pet_images/")
  4. results_dic = dict()
  5. for idx in range[0, len(in_files), 1]:
  6. if in_files[idx][0] != ".":
  7. pet_label = ""
  8. pet_list += in_files[idx].lower().split("_")
  9. for word in pet_list:
  10. if word.isalpha():
  11. pet_label += word + " "
  12. pet_label = pet_label.strip()
  13. if in_files[idx] not in results_dic:
  14. results_dic[in_files[idx]] = [pet_label[idx]]
  15. else:
  16. print("** Warning: Duplicate files exist in directory:",
  17. in_files[idx])
  18. return results_dic
  19. for key in results_dic:
  20. print("Filename=", key, " Pet Label=", results_dic[key])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement