-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeoguess.py
79 lines (63 loc) · 2.43 KB
/
geoguess.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# this is the program that gets run to hold all the other ones
# to call: python geoguess.py <image.jpg>
#####################################
# imports
import os
import argparse
import aggregatecode as agc
import language_det as ladet
from arch_classification.vgg_classify import arch_classify
from License_Plate_Detection.license_det import license_det
#####################################
# define locations and var names
dir_path = os.getcwd()
loc_path = dir_path + "\\locations\\"
json_path = dir_path + "\\geoguesserautomation-5264cd87ce70.json"
arch_path = dir_path + "\\arch_classification\\"
mlb_path = arch_path + "mlb.pickle"
arch_model = arch_path + "arch_model.pkl"
#####################################
# define functions
def parse_args():
parser = argparse.ArgumentParser(
prog = 'Geoguesser Automation',
description='Automatically detects image characteristics without metadata. \nusage: geoguess.py <img.jpg>'
)
parser.add_argument("file")
args = parser.parse_args()
if not args.file:
print("file input required.")
quit()
return args.file
def process_license(input):
# will call the necessary parts of the license plate functions
# returns list of license plates (or an empty list)
ret = license_det(input)
print("License plate function")
print("License plate: " + ret)
return ret
def process_language(image_path):
print("Language detection")
detected_language = ladet.detect_language(image_path,json_path)
print(f"Detected language: {detected_language}")
ret = []
return detected_language
def process_architecture(image_path,model,labelbin):
# will call architecture functions
# will return list of arch characteristics
ret = arch_classify(image_path,model,labelbin)
print("architecture")
return ret
#####################################
# main function
def main():
print("Geoguesser Automation: \nDetecting image location without metadata based on architecture, license plates, and language")
input = parse_args() # "image_input.jpg"
print("Classifying " + input)
allLoc = agc.loadLocs(loc_path)
# TODO: fill these in as the models are completed.
license_output = process_license(input)
language_ouput = process_language(input,json_path)
arch_output = process_architecture(input,arch_model,mlb_path)
print(agc.process_tags(allLoc,(license_output,language_ouput,arch_output)))
main()