分类目录归档:None

MAC上部署Wan2.1 1.3b生成视频模型安装 ERROR 250312

flash-attention 只能X86下CUDA。apple的MPS 无法安装!!!

撤退!

主要是 :下载代码库,安装依赖,下载模型,调用即可。

  1. GIT上下载Wan2.1 git clone https://github.com/Wan-Video/Wan2.1.git
  2. 进入刚刚下载的wan2.1的目录,在其中安装 pip install -r requirements.txt 其中注意flash-attention的安装;使用清华源安装 pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  3. 执行修改为hf-mirror的镜像:export HF_ENDPOINT=https://hf-mirror.com;hf-mirror上下载 Wan-AI/Wan2.1-T2V-1.3B huggingface-cli download Wan-AI/Wan2.1-T2V-1.3B --local-dir ./Wan2.1-T2V-1.3B
  4. 进入GIT下载的wan2.1目录进行测试。python generate.py --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."

1.3B只能txt,不能图片转视频且只能最高480P。14B可以指出图片转视频最高720P。

下面来自wan2.1的官方部署信息。

 Installation
Clone the repo:
git clone https://github.com/Wan-Video/Wan2.1.git cd Wan2.1
Install dependencies:
# Ensure torch >= 2.4.0 pip install -r requirements.txt
 Model Download
Models
Download Link
Notes
T2V-14B
🤗 Huggingface 🤖 ModelScope
Supports both 480P and 720P
I2V-14B-720P
🤗 Huggingface 🤖 ModelScope
Supports 720P
I2V-14B-480P
🤗 Huggingface 🤖 ModelScope
Supports 480P
T2V-1.3B
🤗 Huggingface 🤖 ModelScope
Supports 480P
💡Note: The 1.3B model is capable of generating videos at 720P resolution. However, due to limited training at this resolution, the results are generally less stable compared to 480P. For optimal performance, we recommend using 480P resolution.
Download models using 🤗 huggingface-cli:
pip install "huggingface_hub[cli]" huggingface-cli download Wan-AI/Wan2.1-T2V-1.3B --local-dir ./Wan2.1-T2V-1.3B
Download models using 🤖 modelscope-cli:
pip install modelscope modelscope download Wan-AI/Wan2.1-T2V-1.3B --local_dir ./Wan2.1-T2V-1.3B
 Run Text-to-Video Generation
This repository supports two Text-to-Video models (1.3B and 14B) and two resolutions (480P and 720P). The parameters and configurations for these models are as follows:
Task
Resolution
Model
480P
720P
t2v-14B
✔️
✔️
Wan2.1-T2V-14B
t2v-1.3B
✔️

Wan2.1-T2V-1.3B
 (1) Without Prompt Extention
To facilitate implementation, we will start with a basic version of the inference process that skips the prompt extension step.
Single-GPU inference
python generate.py --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --sample_shift 8 --sample_guide_scale 6 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
If you encounter OOM (Out-of-Memory) issues, you can use the --offload_model True and --t5_cpu options to reduce GPU memory usage. For example, on an RTX 4090 GPU:
python generate.py --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --offload_model True --t5_cpu --sample_shift 8 --sample_guide_scale 6 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
💡Note: If you are using the T2V-1.3B model, we recommend setting the parameter --sample_guide_scale 6. The --sample_shift parameter can be adjusted within the range of 8 to 12 based on the performance.
Multi-GPU inference using FSDP + xDiT USP
pip install "xfuser>=0.4.1" torchrun --nproc_per_node=8 generate.py --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --dit_fsdp --t5_fsdp --ulysses_size 8 --sample_shift 8 --sample_guide_scale 6 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."

利息计算

每个类型的利息计算单独自拿出来,1。传入数据自动计算再返回数据

计算第一期利息 月度和季度有问题;第一期计算;执行start开始日期小于合同开始日期为第一期,则开始日期修改为合同开始日期。

最后一期,当合同结束日期,小于end日期,则结束日期修改为合同结束日期。

提前结束合同,会有个值出现时提前结束合同,相当于合同结束日期。

合同结束日期:如果合同提前结束日期出现,那么合同结束日期就改为合同提前结束日期。

每期利息都计入数据表;利率 、开始日期 、结束日期 、天数、 剩余本金 、贷款ID。

结算利息

剩余本金*间隔的天数*每日的利息=结算所需要的利息

剩余本金=本金-已还本金

间隔天数=选择的间隔类型:月 季度 年 固定日期(需要自己设定 开始结束日期)

每日的利息:

1.LPR调整利息(更具采集的LPR及选择LPR类型(1,3)及上浮的点数)/360

2.固定利息/360

A:数据库查询 在还款日期前的最近一次利息:LPR 或者固定利息

B:间隔天数 设置对应的函数 用于夸周期的天数生产;

C:触发周期,即利息计算:进入新的月份后 执行查询,根据贷款及债券的利息还款设置,通过数据库查询得出间隔天数,和对应的利息。

C.1:对于不同的查询 1 月度 2 季度 3 年度 4 固定(结算月份)

问题1. 是否存在约定15日利息收取?

问题2.是否存在债券 的年度付款利息 不为20号 ,即10年债券是否每年12月10号 付利息?

固定日期间的天数 PHP

<?php
// 定义日期范围(格式:YYYY-MM-DD)
$startDate = new DateTime('2023-02-21'); // 起始日期
$endDate = new DateTime('2023-03-20');   // 结束日期

// 计算间隔天数(包含起始日则 +1,不包含则 -1)
$interval = $startDate->diff($endDate);
$days = $interval->days + 1; // +1 表示包含起始日

echo "间隔天数:" . $days; // 输出:28天
?>