Skip to content

Commit a2eeb2a

Browse files
authored
Move import inside region tags [(#2211)](GoogleCloudPlatform/python-docs-samples#2211)
* Move import inside region tags * Update detect.py
1 parent 60fe11c commit a2eeb2a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

samples/snippets/detect/detect.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
"""
3535

3636
import argparse
37-
import io
3837
import re
3938

4039

4140
# [START vision_face_detection]
4241
def detect_faces(path):
4342
"""Detects faces in an image."""
4443
from google.cloud import vision
44+
import io
4545
client = vision.ImageAnnotatorClient()
4646

4747
# [START vision_python_migration_face_detection]
@@ -107,6 +107,7 @@ def detect_faces_uri(uri):
107107
def detect_labels(path):
108108
"""Detects labels in the file."""
109109
from google.cloud import vision
110+
import io
110111
client = vision.ImageAnnotatorClient()
111112

112113
# [START vision_python_migration_label_detection]
@@ -147,6 +148,7 @@ def detect_labels_uri(uri):
147148
def detect_landmarks(path):
148149
"""Detects landmarks in the file."""
149150
from google.cloud import vision
151+
import io
150152
client = vision.ImageAnnotatorClient()
151153

152154
# [START vision_python_migration_landmark_detection]
@@ -191,6 +193,7 @@ def detect_landmarks_uri(uri):
191193
def detect_logos(path):
192194
"""Detects logos in the file."""
193195
from google.cloud import vision
196+
import io
194197
client = vision.ImageAnnotatorClient()
195198

196199
# [START vision_python_migration_logo_detection]
@@ -231,6 +234,7 @@ def detect_logos_uri(uri):
231234
def detect_safe_search(path):
232235
"""Detects unsafe features in the file."""
233236
from google.cloud import vision
237+
import io
234238
client = vision.ImageAnnotatorClient()
235239

236240
# [START vision_python_migration_safe_search_detection]
@@ -285,6 +289,7 @@ def detect_safe_search_uri(uri):
285289
def detect_text(path):
286290
"""Detects text in the file."""
287291
from google.cloud import vision
292+
import io
288293
client = vision.ImageAnnotatorClient()
289294

290295
# [START vision_python_migration_text_detection]
@@ -335,6 +340,7 @@ def detect_text_uri(uri):
335340
def detect_properties(path):
336341
"""Detects image properties in the file."""
337342
from google.cloud import vision
343+
import io
338344
client = vision.ImageAnnotatorClient()
339345

340346
# [START vision_python_migration_image_properties]
@@ -383,6 +389,7 @@ def detect_properties_uri(uri):
383389
def detect_web(path):
384390
"""Detects web annotations given an image."""
385391
from google.cloud import vision
392+
import io
386393
client = vision.ImageAnnotatorClient()
387394

388395
# [START vision_python_migration_web_detection]
@@ -495,6 +502,7 @@ def web_entities_include_geo_results(path):
495502
"""Detects web annotations given an image, using the geotag metadata
496503
in the image to detect web entities."""
497504
from google.cloud import vision
505+
import io
498506
client = vision.ImageAnnotatorClient()
499507

500508
with io.open(path, 'rb') as image_file:
@@ -543,6 +551,7 @@ def web_entities_include_geo_results_uri(uri):
543551
def detect_crop_hints(path):
544552
"""Detects crop hints in an image."""
545553
from google.cloud import vision
554+
import io
546555
client = vision.ImageAnnotatorClient()
547556

548557
# [START vision_python_migration_crop_hints]
@@ -597,6 +606,7 @@ def detect_crop_hints_uri(uri):
597606
def detect_document(path):
598607
"""Detects document features in an image."""
599608
from google.cloud import vision
609+
import io
600610
client = vision.ImageAnnotatorClient()
601611

602612
# [START vision_python_migration_document_text_detection]

0 commit comments

Comments
 (0)