Instructions to use colt12/maxcushion with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use colt12/maxcushion with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("colt12/maxcushion", 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
- Local Apps Settings
- Draw Things
- DiffusionBee
Download pytorch_model.bin from colt12/maxcushion: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/colt12/maxcushion/resolve/main/pytorch_model.bin
- Command line
-
hf download hf://colt12/maxcushion/pytorch_model.bin
-
curl -L -o pytorch_model.bin https://huggingface.co/colt12/maxcushion/resolve/main/pytorch_model.bin
1.83 kB
| python | |
| import os | |
| import torch | |
| from safetensors import safe_open | |
| from safetensors.torch import save_file | |
| import logging | |
| import shutil | |
| from datetime import datetime | |
| # Set up logging | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| def backup_existing_file(file_path): | |
| if os.path.exists(file_path): | |
| timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| backup_path = f"{file_path}.backup_{timestamp}" | |
| shutil.copy2(file_path, backup_path) | |
| logging.info(f"Created backup of existing file: {backup_path}") | |
| def convert_safetensors_to_pytorch(input_file, output_file): | |
| try: | |
| # Check if input file exists | |
| if not os.path.exists(input_file): | |
| raise FileNotFoundError(f"Input file {input_file} not found.") | |
| # Backup existing pytorch_model.bin if it exists | |
| backup_existing_file(output_file) | |
| # Load the safetensors file | |
| logging.info(f"Loading safetensors file: {input_file}") | |
| with safe_open(input_file, framework="pt", device="cpu") as f: | |
| state_dict = {key: f.get_tensor(key) for key in f.keys()} | |
| # Save as PyTorch bin file | |
| logging.info(f"Saving as PyTorch bin file: {output_file}") | |
| torch.save(state_dict, output_file) | |
| logging.info("Conversion complete.") | |
| logging.info(f"Created: {output_file}") | |
| except Exception as e: | |
| logging.error(f"An error occurred during conversion: {str(e)}") | |
| raise | |
| if __name__ == "__main__": | |
| input_file = "maxcushion.safetensors" | |
| output_file = "pytorch_model.bin" | |
| try: | |
| convert_safetensors_to_pytorch(input_file, output_file) | |
| except Exception as e: | |
| logging.error(f"Conversion failed: {str(e)}") | |
| else: | |
| logging.info("Script executed successfully.") |