带有代理的Google视觉API

问题描述

我想知道,如何使用python上的代理访问地址。他们还有另一种简单的方法来设置代理吗?还是我需要更改源代码

这是Google的演示代码,谢谢大家!

import io
import os

# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision_v1 import types

# Instantiates a client
client = vision.ImageAnnotatorClient()

# The name of the image file to annotate
file_name = os.path.abspath('JPG/claim0_L.JPG')

# Loads the image into memory
with io.open(file_name,'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('Labels:')
for label in labels:
    print(label.description)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)