mirror of
https://github.com/Xevion/phototag.git
synced 2025-12-10 06:07:57 -06:00
restructure
This commit is contained in:
26
package/app.py
Normal file
26
package/app.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import io, sys, os
|
||||
|
||||
# Imports the Google Cloud client library
|
||||
from google.cloud import vision
|
||||
from google.cloud.vision import types
|
||||
|
||||
# Instantiates a client
|
||||
client = vision.ImageAnnotatorClient()
|
||||
|
||||
def run():
|
||||
|
||||
# The name of the image file to annotate
|
||||
path = os.path.join(sys.path[0], 'DSC_6315.jpg')
|
||||
print(path)
|
||||
|
||||
# Loads the image into memory
|
||||
with io.open(path, 'rb') as image_file:
|
||||
content = image_file.read()
|
||||
|
||||
image = types.Image(content=content)
|
||||
|
||||
# Performs label detection on the image file
|
||||
response = client.label_detection(image=image)
|
||||
labels = response.label_annotations
|
||||
|
||||
print([label.description for label in labels])
|
||||
Reference in New Issue
Block a user