Instructions to use d-wang26/mk1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use d-wang26/mk1 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("d-wang26/mk1", 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
Download diffusers/examples/wuerstchen/text_to_image/modeling_efficient_net_encoder.py from d-wang26/mk1: direct link, hf CLI and curl.
- Browser
- Download file 881 Bytes
-
https://huggingface.co/d-wang26/mk1/resolve/main/diffusers/examples/wuerstchen/text_to_image/modeling_efficient_net_encoder.py
- Command line
-
hf download hf://d-wang26/mk1/diffusers/examples/wuerstchen/text_to_image/modeling_efficient_net_encoder.py
-
curl -L -o modeling_efficient_net_encoder.py https://huggingface.co/d-wang26/mk1/resolve/main/diffusers/examples/wuerstchen/text_to_image/modeling_efficient_net_encoder.py
881 Bytes
| import torch.nn as nn | |
| from torchvision.models import efficientnet_v2_l, efficientnet_v2_s | |
| from diffusers.configuration_utils import ConfigMixin, register_to_config | |
| from diffusers.models.modeling_utils import ModelMixin | |
| class EfficientNetEncoder(ModelMixin, ConfigMixin): | |
| def __init__(self, c_latent=16, c_cond=1280, effnet="efficientnet_v2_s"): | |
| super().__init__() | |
| if effnet == "efficientnet_v2_s": | |
| self.backbone = efficientnet_v2_s(weights="DEFAULT").features | |
| else: | |
| self.backbone = efficientnet_v2_l(weights="DEFAULT").features | |
| self.mapper = nn.Sequential( | |
| nn.Conv2d(c_cond, c_latent, kernel_size=1, bias=False), | |
| nn.BatchNorm2d(c_latent), # then normalize them to have mean 0 and std 1 | |
| ) | |
| def forward(self, x): | |
| return self.mapper(self.backbone(x)) | |