semvec/pypi-packages huggingface dataset:
numerbay 0.2.4
Programmatic interaction with numerbay.ai - the Numerai community marketplace
License: MIT License

# NumerBay Python API
Programmatic interaction with [numerbay.ai](https://numerbay.ai) - the Numerai community marketplace.

If you encounter a problem or have suggestions, feel free to open an issue or post in [#numerbay](https://community.numer.ai/channel/numerbay) in RocketChat.

Credit: code structure adapted from the `numerapi` [repo](https://github.com/uuazed/numerapi)

# Installation
`pip install --upgrade numerbay`

# Usage

## Python module

Checkout the NumerBay [Python Client Tutorials](https://docs.numerbay.ai/docs/tutorial-extras/ensemble) for usage examples.


## Command line interface

To get started with the cli interface, let's take a look at the help page:

    $ numerbay --help
    Usage: numerbay [OPTIONS] COMMAND [ARGS]...

      Wrapper around the NumerBay API

      Options:
        --help  Show this message and exit.

      Commands:
        Commands:
          account   Get all information about your account!
          download  Download artifact file.
          listings  Get all your listings!
          orders    Get all your orders!
          sales     Get all your sales!
          submit    Upload artifact from file.
          version   Installed numerbay version.



Each command has it's own help page, for example:

    $ numerbay submit --help
    Usage: numerbay submit [OPTIONS] PATH

      Upload artifact from file.

    Options:
      --product_id INTEGER      NumerBay product ID
      --product_full_name TEXT  NumerBay product full name (e.g. numerai-
                                predictions-numerbay), used for resolving
                                product_id if product_id is not provided
      --order_id INTEGER        NumerBay order ID, used for encrypted per-order
                                artifact upload
      --help                    Show this message and exit.



# API Reference

Checkout the [detailed API](https://docs.numerbay.ai/docs/reference/numerbay) docs to learn about all available methods, parameters and returned values.
deepapi 0.4.3
Deep Learning as a Cloud API Service.
License: MIT License
Requires Python: >=3.6

## Deep API

> Deep Learning as Cloud APIs.

This project provides an image classification cloud service for research on **Black-box Adversarial Attacks**.

![](demo.gif)


### Quick Start

#### Using Docker:

```
docker run -p 8080:8080 wuhanstudio/deepapi
```

#### Python 3:

```
$ pip install deepapi

# For development
# python setup.py develop

# By default, we enable all models on the server.
# Use deepapi -h to see more options.

$ python -m deepapi
Serving on port 8080...
```

The website and API service are available at https://localhost:8080.



### DeepAPI Client

To initiate **black-box adversarial attacks**, we can get predictions from a cloud API using `model.predict()`.

Behind the scene, this `model` makes predictions by sending a POST request to http://localhost:8080/vgg16_cifar10.

```
import numpy as np
from PIL import Image

from deepapi.api import DeepAPI_VGG16_Cifar10

# Load the image
x = Image.open("dog.jpg")
x = np.array(x)

# Initialize the model
model  = DeepAPI_VGG16_Cifar10('http://localhost:8080', concurrency=8)

# Predict
y = model.predict(np.array([x]))[0]

# Print the result
model.print(y)
```

</details>
<details>
  <summary><h3> Using Curl</h3></summary>

```
export IMAGE_FILE=test/cat.jpg
(echo -n '{"file": "'; base64 $IMAGE_FILE; echo '"}') | \
curl -H "Content-Type: application/json" \
     -d @- http://127.0.0.1:8080/vgg16_cifar10
```
</details>


<details>
  <summary><h3> Using Python Request</h3></summary>

You can also implement the API client from scratch using the request module.

```
def classification(url, file):
    # Load the input image and construct the payload for the request
    image = Image.open(file)
    buff = BytesIO()
    image.save(buff, format="JPEG")

    data = {'file': base64.b64encode(buff.getvalue()).decode("utf-8")}
    return requests.post(url, json=data).json()

res = classification('http://127.0.0.1:8080/vgg16_cifar10', 'cat.jpg')
```

This python script is available in the `test` folder. You should see prediction results by running `python3 minimal.py`:

```
cat            0.99804
deer           0.00156
truck          0.00012
airplane       0.00010
dog            0.00009
bird           0.00005
ship           0.00003
frog           0.00001
horse          0.00001
automobile     0.00001
```

#### Concurrent requests

Sending 5 concurrent requests to the API server:

```
$ python3 multi-client.py --num_workers 5 cat.jpg
```

You should see the result:

```
----- start -----
Sending requests
Sending requests
Sending requests
Sending requests
Sending requests
------ end ------
Concurrent Requests: 5
Total Runtime: 2.441638708114624
```