{"id":13415219,"url":"https://github.com/Sharpiless/PaddleX-Flask-VUE-demo","last_synced_at":"2025-03-14T22:33:04.418Z","repository":{"id":41167661,"uuid":"335573284","full_name":"Sharpiless/PaddleX-Flask-VUE-demo","owner":"Sharpiless","description":"基于PaddleX+Flask开发后端，基于VUE开发前端应用，做一个AI医疗的WEB应用","archived":false,"fork":false,"pushed_at":"2021-03-05T13:35:23.000Z","size":4693,"stargazers_count":148,"open_issues_count":0,"forks_count":50,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T21:53:32.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sharpiless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-03T09:34:21.000Z","updated_at":"2024-07-31T02:27:10.000Z","dependencies_parsed_at":"2022-07-27T16:03:02.103Z","dependency_job_id":null,"html_url":"https://github.com/Sharpiless/PaddleX-Flask-VUE-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharpiless%2FPaddleX-Flask-VUE-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharpiless%2FPaddleX-Flask-VUE-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharpiless%2FPaddleX-Flask-VUE-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sharpiless%2FPaddleX-Flask-VUE-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sharpiless","download_url":"https://codeload.github.com/Sharpiless/PaddleX-Flask-VUE-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221514002,"owners_count":16835758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:00:45.301Z","updated_at":"2025-03-14T22:33:04.412Z","avatar_url":"https://github.com/Sharpiless.png","language":"Vue","funding_links":[],"categories":["新项目脚手架"],"sub_categories":[],"readme":"# 基于Paddle+Flask的眼部医疗辅助系统（前后端分离）\n\n视频链接：https://www.bilibili.com/video/BV1k54y1s7j9\n\n# 1. 项目简介：\n\n本项目基于PaddleX提供的FastSCNN语义分割模型，在眼部图像视盘分割数据集上进行训练，并开发了前后端分离项目。\n\n后端代码基于Flask开发，前端WEB界面基于VUE开发。\n\n![](https://ai-studio-static-online.cdn.bcebos.com/936a7f88ceac4085924961e023e0b974e38138def41444dfaf6a58cec091ec4d)\n\n# 2. 训练语义分割模型：\n\n\n\n```python\n! pip install paddlex -i https://mirror.baidu.com/pypi/simple\n```\n\n    \bdone\n    \u001b[?25h  Created wheel for pycocotools: filename=pycocotools-2.0.2-cp37-cp37m-linux_x86_64.whl size=278368 sha256=69425bf5985e5aa2c1a6c475a0d5e5975b3e5e5a024bda6e4573d07ccae57a21\n      Stored in directory: /home/aistudio/.cache/pip/wheels/fb/44/67/8baa69040569b1edbd7776ec6f82c387663e724908aaa60963\n    Successfully built pycocotools\n    Installing collected packages: paddleslim, xlwt, colorama, shapely, paddlehub, pycocotools, paddlex\n      Found existing installation: paddlehub 1.6.0\n        Uninstalling paddlehub-1.6.0:\n          Successfully uninstalled paddlehub-1.6.0\n    Successfully installed colorama-0.4.4 paddlehub-1.8.3 paddleslim-1.1.1 paddlex-1.3.4 pycocotools-2.0.2 shapely-1.7.1 xlwt-1.3.0\n\n\n\n```python\n! wget https://bj.bcebos.com/paddlex/datasets/optic_disc_seg.tar.gz\n! tar xzf optic_disc_seg.tar.gz\n```\n\n    --2021-01-23 08:11:17--  https://bj.bcebos.com/paddlex/datasets/optic_disc_seg.tar.gz\n    Resolving bj.bcebos.com (bj.bcebos.com)... 182.61.200.229, 182.61.200.195, 2409:8c00:6c21:10ad:0:ff:b00e:67d\n    Connecting to bj.bcebos.com (bj.bcebos.com)|182.61.200.229|:443... connected.\n    HTTP request sent, awaiting response... 200 OK\n    Length: 19077558 (18M) [application/octet-stream]\n    Saving to: ‘optic_disc_seg.tar.gz’\n    \n    optic_disc_seg.tar. 100%[===================\u003e]  18.19M  29.0MB/s    in 0.6s    \n    \n    2021-01-23 08:11:18 (29.0 MB/s) - ‘optic_disc_seg.tar.gz’ saved [19077558/19077558]\n    \n\n\n\n```python\n# 设置使用0号GPU卡（如无GPU，执行此代码后仍然会使用CPU训练模型）\nimport matplotlib\nmatplotlib.use('Agg') \nimport os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0'\nimport paddlex as pdx\n```\n\n    2021-01-23 08:11:24,888-INFO: font search path ['/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf', '/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/afm', '/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts']\n    2021-01-23 08:11:25,242-INFO: generated new fontManager\n\n\n\n```python\nfrom paddlex.seg import transforms\ntrain_transforms = transforms.Compose([\n    transforms.RandomHorizontalFlip(),\n    transforms.Resize(target_size=512),\n    transforms.RandomPaddingCrop(crop_size=500),\n    transforms.Normalize()\n])\neval_transforms = transforms.Compose([\n    transforms.Resize(512),\n    transforms.Normalize()\n])\n```\n\n\n```python\ntrain_dataset = pdx.datasets.SegDataset(\n    data_dir='optic_disc_seg',\n    file_list='optic_disc_seg/train_list.txt',\n    label_list='optic_disc_seg/labels.txt',\n    transforms=train_transforms,\n    shuffle=True)\neval_dataset = pdx.datasets.SegDataset(\n    data_dir='optic_disc_seg',\n    file_list='optic_disc_seg/val_list.txt',\n    label_list='optic_disc_seg/labels.txt',\n    transforms=eval_transforms)\n```\n\n    2021-01-23 08:11:39 [INFO]\t267 samples in file optic_disc_seg/train_list.txt\n    2021-01-23 08:11:39 [INFO]\t76 samples in file optic_disc_seg/val_list.txt\n\n\n\n```python\nnum_classes = len(train_dataset.labels)\nnum_classes\n```\n\n\n\n\n    2\n\n\n\n\n```python\nnum_classes = len(train_dataset.labels)\nmodel = pdx.seg.FastSCNN(num_classes=num_classes)\nmodel.train(\n    num_epochs=40,\n    train_dataset=train_dataset,\n    train_batch_size=4,\n    eval_dataset=eval_dataset,\n    learning_rate=0.01,\n    save_interval_epochs=1,\n    save_dir='output/',\n    use_vdl=True)\n```\n\n\n```python\n!paddlex --export_inference --model_dir=./output/best_model --save_dir=./inference_model --fixed_input_shape=[512,512]\n```\n\n    W0123 08:16:03.194139  1332 device_context.cc:252] Please NOTE: device: 0, CUDA Capability: 70, Driver API Version: 10.1, Runtime API Version: 9.0\n    W0123 08:16:03.199599  1332 device_context.cc:260] device: 0, cuDNN Version: 7.6.\n    2021-01-23 08:16:06 [INFO]\tModel[FastSCNN] loaded.\n    2021-01-23 08:16:06 [INFO]\tModel for inference deploy saved in ./inference_model.\n\n\n# 3. 模型预测\n\n使用模型进行预测，同时使用`pdx.seg.visualize`将结果可视化，可视化结果将保存到`./output/deeplab`下，其中`weight`代表原图的权重，即mask可视化结果与原图权重因子。\n\n\n```python\nimport paddlex as pdx\nmodel = pdx.deploy.Predictor('inference_model')\nimage_name = 'optic_disc_seg/JPEGImages/H0005.jpg'\nresult = model.predict(image_name)\npdx.seg.visualize(image_name, result, weight=0.4, save_dir='./output/deeplab')\n```\n\n    2021-01-23 08:16:45 [INFO]\tThe visualized result is saved as ./output/deeplab/visualize_H0005.jpg\n\n\n\n```python\n!zip -r inference_model/ weights.zip\n```\n\n    \tzip warning: name not matched: weights.zip\n    \n    zip error: Nothing to do! (try: zip -r inference_model/ . -i weights.zip)\n\n\n# 4. 启动WEB应用：\n\n在 Flask 项目下运行以下代码启动后端：\n```\npython app.py\n```\n\n在 VUE 项目下运行以下代码安装依赖：\n```\nnpm install\n```\n运行以下代码启动前端：\n```\nnpm run serve\n```\n\n然后在浏览器打开Localhost即可：\n\n![](https://ai-studio-static-online.cdn.bcebos.com/fbd0e4b62a3a435a9afa683456bfebb3ef173c5794854576ad0279aefa2e5bdb)\n\n# 我的公众号：\n\n感兴趣的同学关注我的公众号——可达鸭的深度学习教程：\n\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20210127153004430.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDkzNjg4OQ==,size_16,color_FFFFFF,t_70)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharpiless%2FPaddleX-Flask-VUE-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSharpiless%2FPaddleX-Flask-VUE-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSharpiless%2FPaddleX-Flask-VUE-demo/lists"}