-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp_rank_generator.py
61 lines (49 loc) · 1.82 KB
/
temp_rank_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
@author: aman1
Script to identify unique PR and MM ranks.
"""
import os
import cv2
from PIL import Image, ImageGrab
import numpy as np
import shutil
from tqdm import tqdm
from project_path import steam_path
#rank_type = 'mm'
rank_type = 'pr'
base_path = os.path.join(rank_type + '_snippets')
full_image_files = os.listdir(base_path)
try: full_image_files.remove('Thumbs.db')
except: pass
accepted_list = {}
for file_name in tqdm(full_image_files): #file_name = full_image_files[1]
image = Image.open(os.path.join(base_path, file_name))
if accepted_list == {}:
accepted_list[file_name] = 1
continue
to_append = True
for crosscheck_image in accepted_list.keys(): #crosscheck_image = accepted_list[0]
if np.all(np.array(Image.open(os.path.join(base_path, crosscheck_image))) == np.array(image)):
accepted_list[crosscheck_image] += 1
to_append = False
if to_append:
accepted_list[file_name] = 1
#%%
rank_list = []
target_path = os.path.join('images', rank_type + '_ranks')
for image in sorted(accepted_list, reverse = True, key = lambda x:accepted_list[x]): #image = accepted_list[0]
print(accepted_list[image])
print(*sorted(rank_list))
image = Image.open(os.path.join(base_path, image)).convert('RGB')
display(image)
rank_name = input("Enter the rank name: ")
if rank_name == "": continue
rank_list.append(rank_name)
if rank_name in rank_list:
get_count = rank_list.count(rank_name)
rank_name = rank_name + "_" + str(get_count)
# else:
# rank_name = rank_name + "_" + "1"
image.save(os.path.join(target_path, rank_name + '.png'))
np.save(os.path.join(target_path, 'numpy_objects', rank_name + '.npy'), np.array(image))