Instructions to use timduck8/mmhrem with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use timduck8/mmhrem with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("timduck8/mmhrem", 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
feat: 移除项目文件以准备重构
Browse files- 删除了转换脚本convert_to_diffusers.py及其相关文档
- 移除了requirements.txt依赖配置文件
- 清理了项目许可证相关的README.md文件
- 删除了中文说明文档转换说明.md
- README.md +0 -5
- convert_to_diffusers.py +0 -69
- requirements.txt +0 -7
- 转换说明.md +0 -71
README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: other
|
| 3 |
-
license_name: faipl-1.0-sd
|
| 4 |
-
license_link: LICENSE
|
| 5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convert_to_diffusers.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
将 .safetensors 文件转换为 Diffusers 格式的脚本
|
| 3 |
-
用于 fal.ai 等需要完整 Diffusers 格式的平台
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
from diffusers import StableDiffusionXLPipeline
|
| 7 |
-
import torch
|
| 8 |
-
import os
|
| 9 |
-
|
| 10 |
-
def convert_to_diffusers(
|
| 11 |
-
input_path: str,
|
| 12 |
-
output_dir: str,
|
| 13 |
-
torch_dtype=torch.float16
|
| 14 |
-
):
|
| 15 |
-
"""
|
| 16 |
-
转换 .safetensors 文件为 Diffusers 格式
|
| 17 |
-
|
| 18 |
-
Args:
|
| 19 |
-
input_path: 输入的 .safetensors 文件路径
|
| 20 |
-
output_dir: 输出的 Diffusers 格式目录
|
| 21 |
-
torch_dtype: 模型精度,默认 float16
|
| 22 |
-
"""
|
| 23 |
-
|
| 24 |
-
print(f"开始转换: {input_path}")
|
| 25 |
-
print(f"目标目录: {output_dir}")
|
| 26 |
-
|
| 27 |
-
# 检查输入文件是否存在
|
| 28 |
-
if not os.path.exists(input_path):
|
| 29 |
-
raise FileNotFoundError(f"找不到文件: {input_path}")
|
| 30 |
-
|
| 31 |
-
# 加载单个文件
|
| 32 |
-
print("\n步骤 1/2: 加载 .safetensors 文件...")
|
| 33 |
-
pipe = StableDiffusionXLPipeline.from_single_file(
|
| 34 |
-
input_path,
|
| 35 |
-
torch_dtype=torch_dtype,
|
| 36 |
-
use_safetensors=True
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
# 保存为 Diffusers 格式
|
| 40 |
-
print("\n步骤 2/2: 保存为 Diffusers 格式...")
|
| 41 |
-
pipe.save_pretrained(
|
| 42 |
-
output_dir,
|
| 43 |
-
safe_serialization=True
|
| 44 |
-
)
|
| 45 |
-
|
| 46 |
-
print("\n✓ 转换完成!")
|
| 47 |
-
print(f"\n生成的目录结构位于: {output_dir}")
|
| 48 |
-
print("\n包含的文件:")
|
| 49 |
-
print(" ├── model_index.json")
|
| 50 |
-
print(" ├── scheduler/")
|
| 51 |
-
print(" ├── text_encoder/")
|
| 52 |
-
print(" ├── text_encoder_2/")
|
| 53 |
-
print(" ├── tokenizer/")
|
| 54 |
-
print(" ├── tokenizer_2/")
|
| 55 |
-
print(" ├── unet/")
|
| 56 |
-
print(" └── vae/")
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
if __name__ == "__main__":
|
| 60 |
-
# 配置参数
|
| 61 |
-
INPUT_FILE = "./miaomiaoHarem_v175.safetensors"
|
| 62 |
-
OUTPUT_DIR = "./miaomiaoHarem-diffusers"
|
| 63 |
-
|
| 64 |
-
# 执行转换
|
| 65 |
-
convert_to_diffusers(
|
| 66 |
-
input_path=INPUT_FILE,
|
| 67 |
-
output_dir=OUTPUT_DIR,
|
| 68 |
-
torch_dtype=torch.float16
|
| 69 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
numpy<2.0.0,>=1.24.0
|
| 2 |
-
torch==2.4.0
|
| 3 |
-
torchvision==0.19.0
|
| 4 |
-
diffusers>=0.21.0
|
| 5 |
-
transformers>=4.30.0
|
| 6 |
-
accelerate>=0.20.0
|
| 7 |
-
safetensors>=0.3.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
转换说明.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
# Safetensors 转 Diffusers 格式说明
|
| 2 |
-
|
| 3 |
-
## 快速开始
|
| 4 |
-
|
| 5 |
-
### 1. 安装依赖
|
| 6 |
-
```bash
|
| 7 |
-
pip install -r requirements.txt
|
| 8 |
-
```
|
| 9 |
-
|
| 10 |
-
### 2. 执行转换
|
| 11 |
-
```bash
|
| 12 |
-
python convert_to_diffusers.py
|
| 13 |
-
```
|
| 14 |
-
|
| 15 |
-
### Hugging Face 仓库的大文件(>5GB)上传支持。
|
| 16 |
-
### hf lfs-enable-largefiles .
|
| 17 |
-
## 转换后的目录结构
|
| 18 |
-
|
| 19 |
-
转换完成后,会在当前目录生成 `novaAsianXL-diffusers/` 文件夹,包含完整的 Diffusers 格式:
|
| 20 |
-
|
| 21 |
-
```
|
| 22 |
-
novaAsianXL-diffusers/
|
| 23 |
-
├── model_index.json ← 模型索引配置
|
| 24 |
-
├── scheduler/
|
| 25 |
-
│ └── scheduler_config.json ← 调度器配置
|
| 26 |
-
├── text_encoder/
|
| 27 |
-
│ ├── config.json
|
| 28 |
-
│ └── model.safetensors ← 文本编码器权重
|
| 29 |
-
├── text_encoder_2/
|
| 30 |
-
│ ├── config.json
|
| 31 |
-
│ └── model.safetensors ← 第二个文本编码器
|
| 32 |
-
├── tokenizer/ ← 分词器配置
|
| 33 |
-
├── tokenizer_2/ ← 第二个分词器
|
| 34 |
-
├── unet/
|
| 35 |
-
│ ├── config.json ← UNet 配置
|
| 36 |
-
│ └── diffusion_pytorch_model.safetensors
|
| 37 |
-
├── vae/
|
| 38 |
-
│ ├── config.json ← VAE 配置
|
| 39 |
-
│ └── diffusion_pytorch_model.safetensors
|
| 40 |
-
└── ...
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
## 上传到 fal.ai
|
| 44 |
-
|
| 45 |
-
转换完成后,可以直接将 `novaAsianXL-diffusers/` 整个文件夹上传到 Hugging Face,然后在 fal.ai 中引用。
|
| 46 |
-
|
| 47 |
-
### 上传到 Hugging Face(可选)
|
| 48 |
-
```python
|
| 49 |
-
from huggingface_hub import HfApi
|
| 50 |
-
|
| 51 |
-
api = HfApi()
|
| 52 |
-
api.upload_folder(
|
| 53 |
-
folder_path="./novaAsianXL-diffusers",
|
| 54 |
-
repo_id="your-username/novaAsianXL",
|
| 55 |
-
repo_type="model"
|
| 56 |
-
)
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-
## 自定义参数
|
| 60 |
-
|
| 61 |
-
如需修改输入/输出路径,编辑 `convert_to_diffusers.py` 中的:
|
| 62 |
-
```python
|
| 63 |
-
INPUT_FILE = "./novaAsianXL_illustriousV50.safetensors" # 输入文件
|
| 64 |
-
OUTPUT_DIR = "./novaAsianXL-diffusers" # 输出目录
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
## 注意事项
|
| 68 |
-
|
| 69 |
-
- 转换过程需要较大内存(至少 16GB RAM 推荐)
|
| 70 |
-
- 生成的文件夹大小约为原文件的 1.5-2 倍
|
| 71 |
-
- 确保有足够的磁盘空间(至少 20GB)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|