Script takes image path as input
This commit is contained in:
@@ -1,19 +1,23 @@
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
# Imports the Google Cloud client library
|
# Imports the Google Cloud client library
|
||||||
from google.cloud import vision
|
from google.cloud import vision
|
||||||
|
|
||||||
# Instantiates a client
|
# User input from the command line
|
||||||
client = vision.ImageAnnotatorClient()
|
image_path = sys.argv[1]
|
||||||
|
|
||||||
# The name of the image file to annotate
|
# The name of the image file to annotate
|
||||||
file_name = os.path.abspath('images/mmr.jpg')
|
file_name = os.path.abspath(image_path)
|
||||||
|
|
||||||
# Loads the image into memory
|
# Loads the image into memory
|
||||||
with io.open(file_name, 'rb') as image_file:
|
with io.open(file_name, 'rb') as image_file:
|
||||||
content = image_file.read()
|
content = image_file.read()
|
||||||
|
|
||||||
|
# Instantiates a client
|
||||||
|
client = vision.ImageAnnotatorClient()
|
||||||
|
|
||||||
image = vision.Image(content=content)
|
image = vision.Image(content=content)
|
||||||
|
|
||||||
# Performs label detection on the image file
|
# Performs label detection on the image file
|
||||||
|
|||||||
Reference in New Issue
Block a user