Instructions to use hikmatfarhat/wgan-gp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hikmatfarhat/wgan-gp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="hikmatfarhat/wgan-gp", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("hikmatfarhat/wgan-gp", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download utils.py from hikmatfarhat/wgan-gp: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/hikmatfarhat/wgan-gp/resolve/main/utils.py
- Command line
-
hf download hf://hikmatfarhat/wgan-gp/utils.py
-
curl -L -o utils.py https://huggingface.co/hikmatfarhat/wgan-gp/resolve/main/utils.py
866 Bytes
| #import yaml | |
| #from munch import DefaultMunch | |
| import torch | |
| import torch.nn as nn | |
| def norm(img): | |
| low=float(img.min()) | |
| high=float(img.max()) | |
| img.sub_(low).div_(max(high - low, 1e-5)) | |
| def random_sample(batch_size, z_dim, device): | |
| # input to the generator | |
| # z_dim channels, 1x1 pixels | |
| return torch.randn(batch_size,z_dim, 1, 1).to(device) | |
| def init_weight(m): | |
| if isinstance(m, (nn.Linear, nn.Conv2d, nn.ConvTranspose2d)): | |
| # the weights are initialized according to | |
| # https://arxiv.org/abs/1511.06434 | |
| nn.init.normal_(m.weight, 0, 0.02) | |
| if m.bias is not None: | |
| if m.bias.data is not None: | |
| m.bias.data.zero_() | |
| elif isinstance(m, nn.BatchNorm2d): | |
| m.weight.data.fill_(1) | |
| if m.bias.data is not None: | |
| m.bias.data.zero_() | |