|
1 | 1 | r"""Example for dalle-mini demo model.
|
2 | 2 |
|
| 3 | +First run following command to install required packages: |
| 4 | + pip install -r ./lit_nlp/examples/dalle_mini/requirements.txt |
| 5 | +
|
3 | 6 | To run locally with a small number of examples:
|
4 | 7 | python -m lit_nlp.examples.dalle_mini.demo
|
5 | 8 |
|
6 |
| -
|
| 9 | +By default, this module uses the "cuda" device for image generation. |
| 10 | +The `requirements.txt` file installs a CUDA-enabled version of PyTorch for GPU acceleration. |
| 11 | +
|
| 12 | +If you are running on a machine without a compatible GPU or CUDA drivers, |
| 13 | +you must switch the device to "cpu" and reinstall the CPU-only version of PyTorch. |
| 14 | +
|
| 15 | +Usage: |
| 16 | + - Default: device="cuda" |
| 17 | + - On CPU-only machines: |
| 18 | + 1. Set device="cpu" during model initialization |
| 19 | + 2. Uninstall the CUDA version of PyTorch: |
| 20 | + pip uninstall torch |
| 21 | + 3. Install the CPU-only version: |
| 22 | + pip install torch==2.1.2+cpu --extra-index-url https://download.pytorch.org/whl/cpu |
| 23 | +
|
| 24 | +Example: |
| 25 | + >>> model = MinDalle(..., device="cpu") |
| 26 | +
|
| 27 | +Check CUDA availability: |
| 28 | + >>> import torch |
| 29 | + >>> torch.cuda.is_available() |
| 30 | + False # if no GPU support is present |
| 31 | +
|
| 32 | +Error Handling: |
| 33 | + - If CUDA is selected but unsupported, you will see: |
| 34 | + AssertionError: Torch not compiled with CUDA enabled |
| 35 | + - To fix this, either install the correct CUDA-enabled PyTorch or switch to CPU mode. |
| 36 | + |
7 | 37 | Then navigate to localhost:5432 to access the demo UI.
|
8 | 38 | """
|
9 | 39 |
|
|
26 | 56 | _FLAGS.set_default("development_demo", True)
|
27 | 57 | _FLAGS.set_default("default_layout", "DALLE_LAYOUT")
|
28 | 58 |
|
29 |
| -_FLAGS.DEFINE_integer("grid_size", 4, "The grid size to use for the model.") |
30 |
| - |
31 | 59 | _MODELS = (["dalle-mini"],)
|
32 | 60 |
|
33 | 61 | _CANNED_PROMPTS = ["I have a dream", "I have a shiba dog named cola"]
|
|
0 commit comments