# Scalable Group Inference

**TL;DR:** Treat outputs as a set; formulate group inference as a Quadratic Integer Programming (QIP) problem; scale efficiently with progressive pruning.


## Getting Started

**Environment Setup**

- We provide a [conda env file](environment.yml) that contains all the required dependencies.
  ```bash
  conda env create -f environment.yaml
  ```
- Following this, you can activate the conda environment with the command below.
  ```bash 
  conda activate group-inference


### Text-to-Image group inference

The following command will generate an output of 4 samples for a given prompt with the model `flux-schnell`.

```python
python src/inference.py --prompt "a photo of a dog" --model_name "flux-schnell"
```

For a complete list of available arguments, see [docs/arguments.md](docs/arguments.md).

  <details open>
  <summary><b>Example Outputs: </b> </summary>
  <table>
    <tr>
    <th>Input Caption</th>
    <th>Output Group Size</th>
    <th>Generated Group</th>
    </tr>
    <tr>
      <td width="200px">A photo of a dog.</td>
      <td width="200px">4</td>
      <td width="350px">
        <img src='assets/example_outputs/flux_schnell/dog_result_0.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dog_result_1.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dog_result_2.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dog_result_3.jpg' width="150px">
      </td>
    </tr>
    <tr>
      <td width="200px">A painting of a dog in the style of van gogh.</td>
      <td width="200px">4</td>
      <td width="350px">
        <img src='assets/example_outputs/flux_schnell/dogP_result_0.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dogP_result_1.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dogP_result_2.jpg' width="150px">
        <img src='assets/example_outputs/flux_schnell/dogP_result_3.jpg' width="150px">
      </td>
    </tr>
    </table>
  </details>