bat.apis

This module implements several API clients for Deep Learning cloud API services, so that we can use model.predict() to get prediction results from API servers.

bat.apis.deepapi

DeepAPI is an open source image classification cloud service for research on distributed black-box attacks.

from bat.apis.deepapi import DeepAPI_VGG16_Cifar10

# Load Image
x = np.sarray(Image.open("dog.jpg"))
x = np.array([x])

# Initialize API Model
model = DeepAPI_VGG16_Cifar10("http://localhost:8080" )

# Get Preditctions
y_pred = model.predict(np.array([x]))[0]

# Print Predictions
model.print(y_pred)

bat.apis.google

from bat.apis.google import CloudVision

# Initialize API Model
model = CloudVision()

# Get Preditctions
y_pred = model.predict("dog.jpg")

# Print Predictions
model.print(y_pred)

bat.apis.imagga

from bat.apis.imagga import Imagga

# Initialize API Model
api_key = input(f"Please input the Imagga API Key: ")
api_secret = input(f"Please input the Imagga API Secret: ")

model = Imagga(api_key, api_secret, concurrency=2)

# Get Preditctions
y_pred = model.predict("dog.jpg")

# Print Predictions
model.print(y_pred)
 1r'''
 2This module implements several API clients for Deep Learning cloud API services, so that we can use `model.predict()` to get prediction results from API servers.
 3
 4
 5### bat.apis.deepapi
 6
 7[DeepAPI](https://github.com/wuhanstudio/deepapi) is an open source image classification cloud service for research on distributed black-box attacks.
 8
 9```python
10from bat.apis.deepapi import DeepAPI_VGG16_Cifar10
11
12# Load Image
13x = np.sarray(Image.open("dog.jpg"))
14x = np.array([x])
15
16# Initialize API Model
17model = DeepAPI_VGG16_Cifar10("http://localhost:8080" )
18
19# Get Preditctions
20y_pred = model.predict(np.array([x]))[0]
21
22# Print Predictions
23model.print(y_pred)
24```
25
26### bat.apis.google
27
28- [Google Cloud Vision](https://cloud.google.com/vision)
29
30```python
31from bat.apis.google import CloudVision
32
33# Initialize API Model
34model = CloudVision()
35
36# Get Preditctions
37y_pred = model.predict("dog.jpg")
38
39# Print Predictions
40model.print(y_pred)
41```
42
43### bat.apis.imagga
44
45- [Imagga](https://docs.imagga.com/#tags)
46
47```python
48from bat.apis.imagga import Imagga
49
50# Initialize API Model
51api_key = input(f"Please input the Imagga API Key: ")
52api_secret = input(f"Please input the Imagga API Secret: ")
53
54model = Imagga(api_key, api_secret, concurrency=2)
55
56# Get Preditctions
57y_pred = model.predict("dog.jpg")
58
59# Print Predictions
60model.print(y_pred)
61```
62
63'''
64
65from bat.apis import deepapi
66from bat.apis import google
67from bat.apis import imagga