Users/rdheekonda/update read me (#61)

* Updated results location after completion of attack to be consistent with predict; fixed docker file to conform latest pip install command

* Add static Azure images to help users deploy and test Counterfit instructions in Azure Cloud

* increased memory to 12 GB, updated Counterfit jupyterlab docker images

Co-authored-by: Raja Sekhar Rao Dheekonda <rdheekonda@microsoft.com>
This commit is contained in:
Raja Sekhar Rao Dheekonda 2022-11-10 17:33:37 -08:00 коммит произвёл GitHub
Родитель f3203dc3ce
Коммит ffdcf43e9b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 51 добавлений и 26 удалений

Просмотреть файл

@ -35,22 +35,42 @@ Choose one of these methods to get started quickly:
For more information including alternative installation instructions, please visit our [wiki](https://github.com/Azure/counterfit/wiki).
### Option 1: Deploy via Azure Shell
### Option 1: Deploy and Test in Azure Cloud
To run Counterfit from your browser
1. Click the button below to initiate small resource deployment to your Azure account.
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fcounterfit%2Fmaster%2Finfrastructure%2Fazuredeploy.json)
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fcounterfit%2Fmaster%2Finfrastructure%2Fazuredeploy.json)
2. In the configuration blade, specify your subscription and resource group.
3. In your [Azure Shell](https://shell.azure.com), type the following, replacing `RESOURCE_GROUP` with the name of the resource group selected in the previous step.
2. In the configuration blade, select your Subscription name, Resource group (Create new if you do not have one.), and Region from the drop-down menu as shown below.
```
az container exec --resource-group RESOURCE_GROUP --name counterfit --exec-command '/bin/bash'
```
![Counterfit ARM Deployment](./static/counterfit_arm_deployment.png)
3. The above deployment would take approximately 5-8 minutes approximately. This deployment involves creating Azure Storage Account resource for storing Counterfit generated original and adversarial images and Azure Container Instance resource for running Counterfit.
4. Once deployment is successful, you can get into the Azure Container Instance using the below 2 options.
a. Using Azure Shell, click the link [Azure Shell](https://shell.azure.com) and sign-in to your Azure Subscription, type the following command in the Azure Shell terminal by replacing `RESOURCE_GROUP` with the name of the resource group selected/created in the previous ARM deployment step.
```
az container exec --resource-group RESOURCE_GROUP --name counterfit --exec-command '/bin/bash'
```
b. Using Azure Container Instance(ACI), follow the below steps if you would like to run Counterfit directly in the ACI instance
+ Once deployment is successful, go to the Azure Resource Group and select `counterfit` Azure Container Instance resource as shown below.
![Counterfit Azure Resource Group](./static/counterfit_resource_group.png)
![Counterfit Azure Container Instance](./static/counterfit_container_instance.png)
+ Once the above step is completed, it will take you to the `Container instance` page, click `Containers` under `Settings` section on the left side and click `Connect` from the menu and hit `Connect` button again.
![Counterfit Azure Container Instance Terminal](./static/counterfit_container_aci_terminal.png)
5. Within the container terminal, launch Counterfit using the command `counterfit` in the terminal. Once Counterfit is loaded, you should be able to see a banner as shown below
![Counterfit Terminal](./static/counterfit_terminal_cmd.PNG)
4. Within the container, launch Counterfit.
### Option 2: Set up an Anaconda Python environment and install locally

Просмотреть файл

@ -140,8 +140,16 @@ class CFTarget:
output = np.atleast_2d(output)
return [self.output_classes[i] for i in np.argmax(output, axis=1)]
def get_results_folder(self, folder="results"):
return os.path.join(os.curdir, folder)
def get_results_folder(self, folder_path="counterfit/targets/results"):
"""Folder that stores attack run results.
Args:
folder_path (str, optional): Defaults to "counterfit/targets/results".
Returns:
str: folder prefix path where attack results would be stored.
"""
return folder_path
def get_data_type_obj(self):
target_data_types = {

Просмотреть файл

@ -1,17 +1,17 @@
import numpy as np
import hashlib
from counterfit.core.reporting import CFReportGenerator
from counterfit.data.image import ImageDataType
from PIL import Image
from rich.table import Table
import numpy as np
from azure.storage.blob import BlobClient, ContentSettings
from counterfit.core.output import CFPrint
from counterfit.core.reporting import CFReportGenerator
from counterfit.core.utils import (get_azure_storage_sas_uri,
get_image_in_bytes, get_mime_type,
get_predict_folder,
is_img_save_in_azure_storage,
transform_numpy_to_bytes)
from counterfit.data.image import ImageDataType
from PIL import Image
from rich.table import Table
class ImageReportGenerator(CFReportGenerator):

Просмотреть файл

@ -11,14 +11,10 @@ RUN apt-get update \
WORKDIR /home/counterfituser
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install tensorflow python-Levenshtein
COPY . .
RUN pip install .[dev]
RUN chown -R counterfituser:counterfituser /home/counterfituser
USER counterfituser

Просмотреть файл

@ -11,7 +11,7 @@ RUN apt-get update \
USER 1000
RUN git clone https://github.com/Azure/counterfit.git \
&& cd counterfit \
&& pip install --no-cache-dir -r requirements.txt\
&& pip install .[dev]\
&& cd ..
EXPOSE 8888
EXPOSE 2718

Просмотреть файл

@ -10,6 +10,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i "s/\"default\": \"inherit\"/\"default\": \"dark\"/g" /opt/conda/share/jupyter/lab/schemas/@jupyterlab/terminal-extension/plugin.json
USER 1000
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN pip install .[dev]
EXPOSE 8888

Просмотреть файл

@ -60,7 +60,7 @@
},
"memoryInGb": {
"type": "string",
"defaultValue": "6.0",
"defaultValue": "12.0",
"metadata": {
"description": "The amount of memory to allocate to the container in gigabytes."
}

Двоичные данные
static/counterfit_arm_deployment.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 62 KiB

Двоичные данные
static/counterfit_container_aci_terminal.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 34 KiB

Двоичные данные
static/counterfit_container_instance.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 38 KiB

Двоичные данные
static/counterfit_resource_group.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 43 KiB

Двоичные данные
static/counterfit_terminal_cmd.PNG Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.8 KiB