From 46fb691b4e34cbe5a040f8ae065fbe69c123792d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=88=A9=E6=A0=8B?= <2421235683@qq.com> Date: Sat, 23 Dec 2023 22:55:14 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=88=86=E7=A6=BB=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=BE=BF=E4=BA=8E=E5=AE=9E=E7=8E=B0docker=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app.py | 8 +------- backend/config.yaml | 3 +++ config.yaml | 9 --------- 3 files changed, 4 insertions(+), 16 deletions(-) create mode 100644 backend/config.yaml delete mode 100644 config.yaml diff --git a/backend/app.py b/backend/app.py index c4a1331..982c6c5 100644 --- a/backend/app.py +++ b/backend/app.py @@ -29,13 +29,7 @@ def error_handler(e): if __name__ == '__main__': import yaml - with open('../config.yaml') as file: + with open('./config.yaml') as file: config = yaml.load(file.read(), Loader=yaml.FullLoader) debug_mode = bool(config.get("debug", False)) - with open("../frontend/.env", 'w') as file: - file.write( - "VUE_APP_BACKEND_PORT = {}\nVUE_APP_BACKEND_IP = {}\nVUE_APP_BAIDU_MAP_ACCESS_KEY = {}". - format(config["port"]["backend"], config["host"]["backend"] - if config["host"]["backend"] != "0.0.0.0" else "127.0.0.1", - config["baidu_map"]["access_key"])) app.run(host=config["host"]["backend"], port=config["port"]["backend"]) diff --git a/backend/config.yaml b/backend/config.yaml new file mode 100644 index 0000000..7df32b3 --- /dev/null +++ b/backend/config.yaml @@ -0,0 +1,3 @@ +port: 5008 +host: 127.0.0.1 +debug: false \ No newline at end of file diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 055668f..0000000 --- a/config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -port: - backend: 5008 - frontend: 3000 -host: - backend: 0.0.0.0 - frontend: 0.0.0.0 -baidu_map: - access_key: -debug: false \ No newline at end of file From dc8d4af9c9b41af69ef1667a6e9e856b422eb189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=88=A9=E6=A0=8B?= <2421235683@qq.com> Date: Sat, 23 Dec 2023 22:59:06 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E9=99=90=E5=88=B6numpy=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index f346ae9..194fd35 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -6,7 +6,7 @@ Flask_SQLAlchemy>=2.5.1 marshmallow>=3.18.0 marshmallow_sqlalchemy>=0.28.1 matplotlib>=3.5.3 -numpy>=1.21.3 +numpy>=1.21.3,<1.22 opencv-python>=4.3.0 Pillow>=9.2.0 PyMySQL>=1.0.2 From 35313a1221d81f5de9637ead119cecaf0f5aee81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=88=A9=E6=A0=8B?= <2421235683@qq.com> Date: Sun, 24 Dec 2023 14:00:10 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BB=A5=E5=85=BC=E5=AE=B9docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 163 +++++++++++++++++++ backend.dockerfile | 14 ++ backend/.flaskenv_template | 16 -- backend/app.py | 2 +- backend/applications/interface/analysis.py | 6 +- backend/config.yaml | 3 - config.yaml | 8 + docker-compose.yml | 47 ++++++ frontend.dockerfile | 6 + frontend/.env | 2 - frontend/src/components/ImgShow.vue | 8 +- frontend/src/global.vue | 4 +- frontend/src/utils/getUploadImg.js | 4 +- frontend/src/utils/preHandle.js | 8 +- frontend/src/utils/preview.js | 12 +- frontend/src/views/history/History.vue | 11 +- frontend/src/views/mainfun/DetectChanges.vue | 42 ++--- frontend/src/views/mainfun/OnlineMap.vue | 14 +- frontend/vue.config.js | 16 ++ 19 files changed, 313 insertions(+), 73 deletions(-) create mode 100644 .gitignore create mode 100644 backend.dockerfile delete mode 100644 backend/.flaskenv_template delete mode 100644 backend/config.yaml create mode 100644 config.yaml create mode 100644 docker-compose.yml create mode 100644 frontend.dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d10ae4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,163 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Model +backend/model/ \ No newline at end of file diff --git a/backend.dockerfile b/backend.dockerfile new file mode 100644 index 0000000..4cac7f0 --- /dev/null +++ b/backend.dockerfile @@ -0,0 +1,14 @@ +FROM paddlepaddle/paddle:2.4.1 +#RUN wget https://github.com/girder/large_image_wheels/raw/wheelhouse/GDAL-3.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl +COPY GDAL-3.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl . +RUN pip install GDAL-3.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl +RUN rm -rf GDAL-3.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl +RUN mkdir /app +COPY PaddleRS /app/PaddleRS +WORKDIR /app/PaddleRS +RUN pip install -r /app/PaddleRS/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple +RUN pip install -e . +COPY backend /app/backend +WORKDIR /app/backend +RUN pip install -r /app/backend/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple +ENTRYPOINT ["python", "app.py"] \ No newline at end of file diff --git a/backend/.flaskenv_template b/backend/.flaskenv_template deleted file mode 100644 index 6a82f73..0000000 --- a/backend/.flaskenv_template +++ /dev/null @@ -1,16 +0,0 @@ -# flask配置 -FLASK_APP=app.py -FLASK_DEBUG=1 - -#flask配置 -SYSTEM_NAME=Hippo - -# MySql配置信息 -MYSQL_HOST=127.0.0.1 -MYSQL_PORT=3306 -MYSQL_DATABASE=paddle_rs -MYSQL_USERNAME=paddle_rs -MYSQL_PASSWORD=123456 - -# 密钥配置(记得改) -SECRET_KEY='Hippo' diff --git a/backend/app.py b/backend/app.py index 982c6c5..2df833f 100644 --- a/backend/app.py +++ b/backend/app.py @@ -29,7 +29,7 @@ def error_handler(e): if __name__ == '__main__': import yaml - with open('./config.yaml') as file: + with open('../config.yaml') as file: config = yaml.load(file.read(), Loader=yaml.FullLoader) debug_mode = bool(config.get("debug", False)) app.run(host=config["host"]["backend"], port=config["port"]["backend"]) diff --git a/backend/applications/interface/analysis.py b/backend/applications/interface/analysis.py index 7cbffe9..b4366aa 100644 --- a/backend/applications/interface/analysis.py +++ b/backend/applications/interface/analysis.py @@ -116,7 +116,7 @@ def change_detection(model_path, cv2.imwrite( os.path.join(out_dir, os.path.splitext(filenames[i])[0] + "_mask.png"), mask) - res[i]["mask"] = out_dir + os.path.splitext(filenames[i])[ + res[i]["mask"] = generate_url + os.path.splitext(filenames[i])[ 0] + "_mask.png" res[i]["count"] = count res[i]["fractional_variation"] = compute_variation( @@ -135,11 +135,11 @@ def change_detection(model_path, out_dir + "hole/", os.path.splitext(os.path.basename(after_img))[0] + "_mask.png"), mask) - res[i]["mask_hole"] = out_dir + "hole/" + os.path.splitext( + res[i]["mask_hole"] = generate_url + "hole/" + os.path.splitext( os.path.basename(after_img))[0] + "_mask.png" res[i]["count_hole"] = count res[i]["fractional_variation_hole"] = compute_variation( - os.path.join(generate_dir + "hole/", os.path.basename(after_img))) + os.path.join(out_dir + "hole/", os.path.basename(after_img))) data = json.dumps(res[i]) save_analysis( type_, diff --git a/backend/config.yaml b/backend/config.yaml deleted file mode 100644 index 7df32b3..0000000 --- a/backend/config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -port: 5008 -host: 127.0.0.1 -debug: false \ No newline at end of file diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..d3ace55 --- /dev/null +++ b/config.yaml @@ -0,0 +1,8 @@ +port: + backend: 5008 + frontend: 3000 +host: + backend: 0.0.0.0 + frontend: 0.0.0.0 +debug: true +docker: true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4212e0a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: "3.9" +services: + mysql: + image: mysql:5.7.44 + restart: always + environment: + MYSQL_ROOT_PASSWORD: GeoView2023 + volumes: + - /etc/localtime:/etc/localtime:ro + networks: + - GeoView + backend: + build: + context: . + dockerfile: backend.dockerfile + restart: always + volumes: + - /etc/localtime:/etc/localtime:ro + - $PWD/config.yaml:/app/config.yaml + - $PWD/backend/.flaskenv:/app/backend/.flaskenv + - $PWD/backend/model:/app/backend/model + depends_on: + - mysql + links: + - mysql + networks: + - GeoView + frontend: + build: + context: . + dockerfile: frontend.dockerfile + restart: always + ports: + - "3000:3000" + volumes: + - /etc/localtime:/etc/localtime:ro + - $PWD/config.yaml:/app/config.yaml + - $PWD/frontend/.env:/app/frontend/.env + depends_on: + - backend + networks: + - GeoView +networks: + GeoView: + ipam: + config: + - subnet: 172.19.0.0/24 \ No newline at end of file diff --git a/frontend.dockerfile b/frontend.dockerfile new file mode 100644 index 0000000..20e1e67 --- /dev/null +++ b/frontend.dockerfile @@ -0,0 +1,6 @@ +FROM node:20.10.0-alpine +RUN mkdir /app +COPY frontend /app/frontend +WORKDIR /app/frontend +RUN npm install +ENTRYPOINT ["npm", "run", "serve"] diff --git a/frontend/.env b/frontend/.env index 27345f5..227ca0f 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,3 +1 @@ -VUE_APP_BACKEND_PORT = 5008 -VUE_APP_BACKEND_IP = 127.0.0.1 VUE_APP_BAIDU_MAP_ACCESS_KEY = \ No newline at end of file diff --git a/frontend/src/components/ImgShow.vue b/frontend/src/components/ImgShow.vue index 5dde0ea..9afee5f 100644 --- a/frontend/src/components/ImgShow.vue +++ b/frontend/src/components/ImgShow.vue @@ -66,7 +66,7 @@ diff --git a/frontend/src/utils/getUploadImg.js b/frontend/src/utils/getUploadImg.js index 6a553bb..91f63e4 100644 --- a/frontend/src/utils/getUploadImg.js +++ b/frontend/src/utils/getUploadImg.js @@ -5,8 +5,8 @@ import {showFullScreenLoading} from "@/utils/loading"; function getUploadImg(type) { historyGetPage(1, 20, type).then((res) => { this.imgArr = res.data.data.forEach((item)=>{ - item['before_img'] = global.BASEURL+item.before_img - item['after_img'] = global.BASEURL+item.after_img + item['before_img'] = global.BASE_IMAGE_URL+item.before_img + item['after_img'] = global.BASE_IMAGE_URL+item.after_img }) this.imgArr = res.data.data this.isUpload = this.imgArr.length !== 0; diff --git a/frontend/src/utils/preHandle.js b/frontend/src/utils/preHandle.js index 6480ea9..6d83bf7 100644 --- a/frontend/src/utils/preHandle.js +++ b/frontend/src/utils/preHandle.js @@ -30,7 +30,7 @@ function selectSharpen(type) { } createSrc(formData).then((res) => { this.uploadSrc.list = res.data.data.map((item) => { - return global.BASEURL+item.src; + return global.BASE_IMAGE_URL+item.src; }); this.before = this.uploadSrc.list.splice(0,3) @@ -40,7 +40,7 @@ function selectSharpen(type) { prePhotoHandle(this.prePhoto).then((res)=>{ this.sharpenImg = res.data.data.map((item)=>{ - return global.BASEURL + item + return global.BASE_IMAGE_URL + item }) }).catch(()=>{}) }).catch((rej)=>{}) @@ -75,7 +75,7 @@ function selectSharpen(type) { } createSrc(formData).then((res) => { this.uploadSrc.list = res.data.data.map((item) => { - return global.BASEURL+item.src; + return global.BASE_IMAGE_URL+item.src; }); this.before = this.uploadSrc.list.splice(0,3) @@ -85,7 +85,7 @@ function selectSharpen(type) { prePhotoHandle(this.prePhoto).then((res)=>{ this.claheImg = res.data.data.map((item)=>{ - return global.BASEURL + item + return global.BASE_IMAGE_URL + item }) }).catch((rej)=>{}) }).catch((rej)=>{}) diff --git a/frontend/src/utils/preview.js b/frontend/src/utils/preview.js index 14eb915..7ab4586 100644 --- a/frontend/src/utils/preview.js +++ b/frontend/src/utils/preview.js @@ -3,22 +3,22 @@ import global from '@/global' function previewOnePic(pic) { this.flag = 1 this.fbflag = 1 - this.previewPic1 = global.BASEURL + pic + this.previewPic1 = global.BASE_IMAGE_URL + pic this.preVisible = true; } function previewTwoPic(pic1, pic2) { this.flag = 2 this.fbflag = 2 - this.previewPic1 = global.BASEURL + pic1 - this.previewPic2 = global.BASEURL + pic2 + this.previewPic1 = global.BASE_IMAGE_URL + pic1 + this.previewPic2 = global.BASE_IMAGE_URL + pic2 this.preVisible = true } function previewThreePic(pic1, pic2, pic3) { this.flag = 3 this.fbflag = 3 - this.previewPic1 = global.BASEURL + pic1 - this.previewPic2 = global.BASEURL + pic2 - this.previewPic3 = global.BASEURL + pic3 + this.previewPic1 = global.BASE_IMAGE_URL + pic1 + this.previewPic2 = global.BASE_IMAGE_URL + pic2 + this.previewPic3 = global.BASE_IMAGE_URL + pic3 this.preVisible = true } diff --git a/frontend/src/views/history/History.vue b/frontend/src/views/history/History.vue index 3115c56..d3927b1 100644 --- a/frontend/src/views/history/History.vue +++ b/frontend/src/views/history/History.vue @@ -41,7 +41,7 @@