Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Hackathon 7th PPSCI No.7】No.7 AI-aided geometric design of anti-infection catheters 论文复现 #986

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

ADream-ki
Copy link

PR types

PR changes

Describe

Copy link

paddle-bot bot commented Sep 2, 2024

Thanks for your contribution!

@ADream-ki ADream-ki changed the title 【Hackathon 7th】No.7 AI-aided geometric design of anti-infection catheters 论文复现 【Hackathon 7th No.7】No.7 AI-aided geometric design of anti-infection catheters 论文复现 Sep 2, 2024
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交PR,有一些修改建议如下,另外提交的代码请使用pre-commit格式化(参考文档:https://paddlescience-docs.readthedocs.io/zh-cn/latest/zh/development/#1


=== "模型训练命令"

``sh python laplace2d.py ``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请使用三个重音符号包裹代码块,下同


| 预训练模型 | 指标 |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------- |
| [GeoFno.pdparams](https://paddle-orghttps://aistudio.baidu.com/datasetdetail/291940.bj.bcebos.com/paddlescience/models/laplace2d/laplace2d_pretrained.pdparams) | Test loss(LPLoss): 0.07319313049316406 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. laplace案例模版的内容请删除干净
  2. 预训练模型可以放aistudio或者本PR里,我会帮忙上传

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请不要修改无关文件

Comment on lines 1 to 24
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_geofno/${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
callbacks:
init_callback:
_target_: ppsci.utils.callbacks.InitCallback
sweep:
# output directory for multirun
dir: ${geofno.run.dir}
subdir: ./

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_geofno/${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
callbacks:
init_callback:
_target_: ppsci.utils.callbacks.InitCallback
sweep:
# output directory for multirun
dir: ${geofno.run.dir}
subdir: ./
defaults:
- ppsci_default
- TRAIN: train_default
- TRAIN/ema: ema_default
- TRAIN/swa: swa_default
- EVAL: eval_default
- INFER: infer_default
- hydra/job/config/override_dirname/exclude_keys: exclude_keys_default
- _self_
hydra:
run:
# dynamic output directory according to running time and override name
dir: outputs_geofno/${now:%Y-%m-%d}/${now:%H-%M-%S}/${hydra.job.override_dirname}
job:
name: ${mode} # name of logfile
chdir: false # keep current working directory unchanged
callbacks:
init_callback:
_target_: ppsci.utils.callbacks.InitCallback
sweep:
# output directory for multirun
dir: ${geofno.run.dir}
subdir: ./

Comment on lines 23 to 26
x_path: "examples/geofno/data/training/x_1d_structured_mesh.npy"
y_path: "examples/geofno/data/training/y_1d_structured_mesh.npy"
para_path: "examples/geofno/data/training/data_info.npy"
output_path: "examples/geofno/data/training/density_1d_data.npy"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请删除路径中的"examples/geofno/"前缀,一般默认当前路径在examples/geofno/下

Comment on lines 129 to 133
# initialize solver OK
solver = ppsci.solver.Solver(
model,
constraint,
cfg.output_dir,
optimizer,
epochs=cfg.TRAIN.epochs,
iters_per_epoch=ITERS_PER_EPOCH,
eval_during_train=cfg.TRAIN.eval_during_train,
validator=l2rel_validator,
save_freq=cfg.TRAIN.save_freq,
seed=cfg.seed,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# initialize solver OK
solver = ppsci.solver.Solver(
model,
constraint,
cfg.output_dir,
optimizer,
epochs=cfg.TRAIN.epochs,
iters_per_epoch=ITERS_PER_EPOCH,
eval_during_train=cfg.TRAIN.eval_during_train,
validator=l2rel_validator,
save_freq=cfg.TRAIN.save_freq,
seed=cfg.seed,
)
# initialize solver OK
solver = ppsci.solver.Solver(
model,
constraint,
cfg.output_dir,
optimizer,
epochs=cfg.TRAIN.epochs,
iters_per_epoch=ITERS_PER_EPOCH,
eval_during_train=cfg.TRAIN.eval_during_train,
validator=l2rel_validator,
save_freq=cfg.TRAIN.save_freq,
)

Comment on lines 149 to 140
# set random seed for reproducibility
ppsci.utils.misc.set_random_seed(cfg.seed)
# initialize logger
logger.init_logger("ppsci", osp.join(cfg.output_dir, f"{cfg.mode}.log"), "info")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除


plt.legend()
plt.tight_layout()
plt.savefig("Validation."+str(sample_id)+".pdf")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
plt.savefig("Validation."+str(sample_id)+".pdf")
plt.savefig(f"Validation.{sample_id}.pdf")

Comment on lines 192 to 231
raise ValueError(
f"cfg.mode should in ['train', 'eval', 'export', 'infer'], but got '{cfg.mode}'"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

麻烦添加模型导出和推理代码

Comment on lines 58 to 62
def count_params(model):
c = 0
for p in model.parameters():
c += np.prod(p.shape) # 使用paddle.prod计算参数的总数
return c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不重要的调试函数可以删除


| 预训练模型 | 指标 |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------- |
| [GeoFno.pdparams](https://paddle-orghttps://aistudio.baidu.com/datasetdetail/291940.bj.bcebos.com/paddlescience/models/laplace2d/laplace2d_pretrained.pdparams) | Test loss(LPLoss): 0.07319313049316406 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刚刚弄完

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

链接也弄好了

Copy link
Contributor

@wangguan1995 wangguan1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix



# loss function with rel/abs Lp loss
class LpLoss(nn.Layer):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除utilities3.py
复用:ppsci.loss.L2Loss
如果不能复用,新建一个/workspace/wangguan/Hackathon_7/ppsci/loss/Lp.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复原laplace2.md

Copy link
Contributor

@wangguan1995 wangguan1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个好像还没做,注意下
3. catheter_design.ipynb: Real-time design optimization by using Geo-FNO model and BFGS algorithm.

  1. catheter_analysis.ipynb: Compassion with linear regression model; Visualization of the landscape of the loss function around the optimal design.


## 1. 背景简介

[论文](https://www.science.org/doi/pdf/10.1126/sciadv.adj1741)提出了一种基于人工智能的导尿管几何设计方法,可以有效抑制细菌逆流,从而预防 CAUTI。该方法通过流体动力学和粒子动力学模拟研究细菌运动机制,并使用人工智能模型优化导尿管几何形状,使其能够最大程度地抑制细菌逆流。实验结果表明,该设计能够将细菌逆流的程度降低一到两个数量级,具有安全、有效、易于实施和成本低等优点,有望成为未来 CAUTI 预防的重要手段。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

人工智能辅助的抗感染导管几何创新设计

在狭窄管道内的流体环境中,细菌能借助流体动力学作用逆流迁移,对使用植入性导管的患者构成泌尿道感染的严重威胁。尽管已有提议采用涂层与结构化表面来抑制导管内的细菌滋生,但遗憾的是,至今尚无一种表面结构或涂层技术能从根本上解决污染难题。鉴于此,我们依据逆流游动的物理原理,创新性地提出了一种几何设计方案,并通过人工智能模型对细菌流入动力学进行预测与优化。相较于传统模拟方法,所采用的傅立叶神经算子人工智能技术实现了显著的速度提升。

在准二维微流体实验中,我们以大肠杆菌为对象,验证了该设计的抗感染机制,并在临床相关流速下,通过3D打印的导管原型对其有效性进行了评估。实验结果显示,我们的导管设计在抑制导管上游端细菌污染方面,实现了1-2个数量级的提升,有望大幅延长导管的安全留置时间,并整体降低导管相关性尿路感染的风险。

![1725428017615](image/catheter/1725428017615.png)

可以看到模型预测结果与真实结果基本一致,模型泛化效果良好。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Training Test Loss 也放一下

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经加了

@ADream-ki
Copy link
Author

这两个好像还没做,注意下 3. catheter_design.ipynb: Real-time design optimization by using Geo-FNO model and BFGS algorithm.

  1. catheter_analysis.ipynb: Compassion with linear regression model; Visualization of the landscape of the loss function around the optimal design.

加在aistudio那里了

@luotao1 luotao1 changed the title 【Hackathon 7th No.7】No.7 AI-aided geometric design of anti-infection catheters 论文复现 【Hackathon 7th PPSCI No.7】No.7 AI-aided geometric design of anti-infection catheters 论文复现 Sep 18, 2024
@@ -0,0 +1,195 @@
# Catheter

<a href="https://aistudio.baidu.com/aistudio/projectdetail/6169897?sUid=455441&shared=1&ts=1684122038217" class="md-button md-button--primary" style>AI Studio 快速体验</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

这个链接不太对啊....

################################################################
# fourier layer
################################################################
class SpectralConv1d(nn.Layer):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

神经网络的代码,应归类到:ppsci/arch
调用方式如图:
image

这样方便网络算法直接,快速的横向对比,对用户友好,别的数据集也可以用这种网络~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议把这个案例文件,以及文件夹,命名为catheter
当前的catheter.py,因为其包含了geofno网络架构,建议命名为geofno

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抱歉,我马上改掉,最近在写论文

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好,已经按照要求修改了

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2024

CLA assistant check
All committers have signed the CLA.

@wangguan1995
Copy link
Contributor

wangguan1995 commented Oct 8, 2024

image
image

数据集没有公开,另外需要【挂载】到aistudio项目上

@ADream-ki
Copy link
Author

ADream-ki commented Oct 9, 2024

抱歉抱歉,忘了公开数据集了,现在已经可以了,请review @wangguan1995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants