Instructions to use 43ntropy/NEvo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use 43ntropy/NEvo with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("43ntropy/NEvo", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| from __future__ import annotations | |
| from typing import Any | |
| import torch | |
| from diffusers import DiffusionPipeline | |
| from .base import TextToImageGenerator | |
| class DiffusersTextToImageAdapter(TextToImageGenerator): | |
| def __init__(self, model_id: str, device: str = "cuda", torch_dtype: Any | None = None, pipeline: Any | None = None, **kwargs) -> None: | |
| if pipeline is None: | |
| dtype = torch_dtype | |
| if dtype is None and str(device).startswith("cuda"): | |
| dtype = torch.float16 | |
| pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=dtype, **kwargs) | |
| self.pipe = pipeline | |
| self.device = device | |
| if hasattr(self.pipe, "to"): | |
| self.pipe.to(device) | |
| if hasattr(self.pipe, "set_progress_bar_config"): | |
| self.pipe.set_progress_bar_config(disable=True) | |
| def generate(self, prompts: list[str], *, generator: Any | None = None, **kwargs) -> list[Any]: | |
| out = self.pipe(prompt=prompts, generator=generator, **kwargs) | |
| if hasattr(out, "images"): | |
| return list(out.images) | |
| if isinstance(out, list): | |
| return out | |
| raise TypeError("Text-to-image pipeline output does not expose `.images`.") | |
| def generate_batch(self, prompts, *, generators=None, **kwargs): | |
| out = self.pipe(prompt=list(prompts), generator=generators, **kwargs) | |
| if hasattr(out, "images"): | |
| return list(out.images) | |
| if isinstance(out, list): | |
| return out | |
| raise TypeError("Text-to-image pipeline output does not expose `.images`.") | |