-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·36 lines (30 loc) · 950 Bytes
/
main.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
# mealchk-cli
# main.py
import sys
import importlib
import mealchk
def main():
# Set the provider here
# Valid values: local, gcloud, aws
PROVIDER = 'local'
# compile list of filenames
filenames = []
for arg in sys.argv[1:]:
filenames.append(arg)
# perform analysis on each filename
for file_i in filenames:
# TODO: Add support for http download
# Import correct provider
try:
providermod = importlib.import_module('providers.%s' % PROVIDER)
except ModuleNotFoundError:
print('Error: Invalid provider specified. The \'%s\' provider could not be loaded.' % (PROVIDER))
sys.exit()
# Convert image to a string
text = providermod.image_to_string(file_i)
# print("Image analysis: ", text)
# Perform analysis via mealchk
mealchk.analyze(text)
if __name__=="__main__":
main()