国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

英文網(wǎng)站建設(shè)方法網(wǎng)站怎么收錄到百度

英文網(wǎng)站建設(shè)方法,網(wǎng)站怎么收錄到百度,成都商務(wù)網(wǎng)站建設(shè),做個(gè)爬架網(wǎng)站如何做目錄 1、思路 2、代碼結(jié)構(gòu) 3、代碼運(yùn)行 4、api接口代碼 5、web ui界面 6、參考資料 7、代碼分享 1、思路 通過搭建flask微型服務(wù)器后端,以后通過vue搭建網(wǎng)頁前端。flask是第一個(gè)第三方庫。與其他模塊一樣,安裝時(shí)可以直接使用python的pip命令實(shí)現(xiàn)…

目錄

1、思路

2、代碼結(jié)構(gòu)

3、代碼運(yùn)行

4、api接口代碼

5、web ui界面

6、參考資料

7、代碼分享?


1、思路

通過搭建flask微型服務(wù)器后端,以后通過vue搭建網(wǎng)頁前端。flask是第一個(gè)第三方庫。與其他模塊一樣,安裝時(shí)可以直接使用python的pip命令實(shí)現(xiàn)。flask是web開發(fā)框架,簡單易學(xué),因此用flask來搭建web服務(wù)也非常簡單。

在pycharm新建一個(gè)項(xiàng)目,命名為web2020,然后新建一個(gè)python文件,命名為main.py。在代碼中輸入如下代碼:

from flask import  Flask    #導(dǎo)入Flask類
app=Flask(__name__)         #實(shí)例化并命名為app實(shí)例
if __name__=="__main__":app.run(port=2020,host="127.0.0.1",debug=True)   #調(diào)用run方法,設(shè)定端口號(hào),啟動(dòng)服務(wù)

路由定義:

from flask import  Flask
app=Flask(__name__)@app.route('/')
def index():return 'welcome to my webpage!'if __name__=="__main__":app.run(port=2020,host="127.0.0.1",debug=True)

通過這種方式,實(shí)現(xiàn)python調(diào)用模型,然后通過web服務(wù)器進(jìn)行數(shù)據(jù)輸入輸出,最后通過瀏覽器web頁面進(jìn)行展示。

2、代碼結(jié)構(gòu)

前端代碼結(jié)構(gòu)

后端代碼結(jié)構(gòu)

3、代碼運(yùn)行

4、api接口代碼

import datetime
import logging as rel_log
import os
import shutil
from datetime import timedelta
from flask import *
from flask import Flask, render_template, Response
from processor.AIDetector_pytorch import Detectorimport core.main# import camera driver
if os.environ.get('CAMERA'):Camera = import_module('camera_' + os.environ['CAMERA']).Camera
else:from camera import CameraUPLOAD_FOLDER = r'./uploads'ALLOWED_EXTENSIONS = set(['png', 'jpg'])
app = Flask(__name__)
app.secret_key = 'secret!'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDERwerkzeug_logger = rel_log.getLogger('werkzeug')
werkzeug_logger.setLevel(rel_log.ERROR)# 解決緩存刷新問題
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(seconds=1)# 添加header解決跨域
@app.after_request
def after_request(response):response.headers['Access-Control-Allow-Origin'] = '*'response.headers['Access-Control-Allow-Credentials'] = 'true'response.headers['Access-Control-Allow-Methods'] = 'POST'response.headers['Access-Control-Allow-Headers'] = 'Content-Type, X-Requested-With'return response#圖片檢測(cè)接口
def allowed_file(filename):return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS#@app.route('/')
#def hello_world():
#    return redirect(url_for('static', filename='./index.html'))
@app.route('/')
def index():"""Video streaming home page."""return render_template('index.html')@app.route('/upload', methods=['GET', 'POST'])
def upload_file():file = request.files['file']print(datetime.datetime.now(), file.filename)#if file and allowed_file(file.filename):src_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)file.save(src_path)shutil.copy(src_path, './tmp/ct')image_path = os.path.join('./tmp/ct', file.filename)pid, image_info = core.main.c_main(image_path, current_app.model, file.filename.rsplit('.', 1)[1])return jsonify({'status': 1,'image_url': 'http://127.0.0.1:5003/tmp/ct/' + pid,'draw_url': 'http://127.0.0.1:5003/tmp/draw/' + pid,'image_info': image_info})#return jsonify({'status': 0})@app.route("/download", methods=['GET'])
def download_file():# 需要知道2個(gè)參數(shù), 第1個(gè)參數(shù)是本地目錄的path, 第2個(gè)參數(shù)是文件名(帶擴(kuò)展名)return send_from_directory('data', 'testfile.zip', as_attachment=True)# show photo
@app.route('/tmp/<path:file>', methods=['GET'])
def show_photo(file):if request.method == 'GET':if not file is None:image_data = open(f'tmp/{file}', "rb").read()response = make_response(image_data)response.headers['Content-Type'] = 'image/png'return response#視頻檢測(cè)接口
def gen(camera):"""Video streaming generator function."""while True:frame = camera.get_frame()yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')@app.route('/video_start')
def video_feed():"""Video streaming route. Put this in the src attribute of an img tag."""return Response(gen(Camera()),mimetype='multipart/x-mixed-replace; boundary=frame')#視頻流檢測(cè)接口
#@app.route('/livestream_start')#程序啟動(dòng)入口
if __name__=='__main__': files = ['uploads', 'tmp/ct', 'tmp/draw','tmp/image', 'tmp/mask', 'tmp/uploads']for ff in files:if not os.path.exists(ff):os.makedirs(ff)with app.app_context():current_app.model = Detector()app.run(host='127.0.0.1', port=5003, debug=True)

5、web ui界面

<template><el-tabs stretch=true v-model="activeName" type="card" @tab-click="handleClick"><el-tab-pane  label="圖片檢測(cè)" name="first"><div id="Content"><el-dialogtitle="AI預(yù)測(cè)中":visible.sync="dialogTableVisible":show-close="false":close-on-press-escape="false":append-to-body="true":close-on-click-modal="false":center="true"><el-progress :percentage="percentage"></el-progress><span slot="footer" class="dialog-footer">請(qǐng)耐心等待約3秒鐘</span></el-dialog><div id="CT"><div id="CT_image"><el-cardid="CT_image_1"class="box-card"style="border-radius: 8px;width: 800px;height: 360px;margin-bottom: -30px;"><div class="demo-image__preview1"><divv-loading="loading"element-loading-text="上傳圖片中"element-loading-spinner="el-icon-loading"><el-image:src="url_1"class="image_1":preview-src-list="srcList"style="border-radius: 3px 3px 0 0"><div slot="error"><div slot="placeholder" class="error"><el-buttonv-show="showbutton"type="primary"icon="el-icon-upload"class="download_bt"v-on:click="true_upload">上傳圖像<inputref="upload"style="display: none"name="file"type="file"@change="update"/></el-button></div></div></el-image></div><div class="img_info_1" style="border-radius: 0 0 5px 5px"><span style="color: white; letter-spacing: 6px">原始圖像</span></div></div><div class="demo-image__preview2"><divv-loading="loading"element-loading-text="處理中,請(qǐng)耐心等待"element-loading-spinner="el-icon-loading"><el-image:src="url_2"class="image_1":preview-src-list="srcList1"style="border-radius: 3px 3px 0 0"><div slot="error"><div slot="placeholder" class="error">{{ wait_return }}</div></div></el-image></div><div class="img_info_1" style="border-radius: 0 0 5px 5px"><span style="color: white; letter-spacing: 4px">檢測(cè)結(jié)果</span></div></div></el-card></div><div id="info_patient"><!-- 卡片放置表格 --><el-card style="border-radius: 8px"><div slot="header" class="clearfix"><span>檢測(cè)目標(biāo)</span><el-buttonstyle="margin-left: 35px"v-show="!showbutton"type="primary"icon="el-icon-upload"class="download_bt"v-on:click="true_upload2">重新選擇圖像<inputref="upload2"style="display: none"name="file"type="file"@change="update"/></el-button></div><el-tabs v-model="activeName"><el-tab-pane label="檢測(cè)到的目標(biāo)" name="first"><!-- 表格存放特征值 --><el-table:data="feature_list"height="390"borderstyle="width: 750px; text-align: center"v-loading="loading"element-loading-text="數(shù)據(jù)正在處理中,請(qǐng)耐心等待"element-loading-spinner="el-icon-loading"lazy><el-table-column label="目標(biāo)類別" width="250px"><template slot-scope="scope"><span>{{ scope.row[2] }}</span></template></el-table-column><el-table-column label="目標(biāo)大小" width="250px"><template slot-scope="scope"><span>{{ scope.row[0] }}</span></template></el-table-column><el-table-column label="置信度" width="250px"><template slot-scope="scope"><span>{{ scope.row[1] }}</span></template></el-table-column></el-table></el-tab-pane></el-tabs></el-card></div></div></div></el-tab-pane><el-tab-pane label="視頻檢測(cè)" name="second"><h3>視頻名稱</h3><img :src="vidoedectetion"> </el-tab-pane><el-tab-pane label="視頻流檢測(cè)" name="third"></el-tab-pane><el-tab-pane label="多路視頻流檢測(cè)" name="fourth"></el-tab-pane></el-tabs></template><script>
import axios from "axios";export default {name: "Content",data() {return {vidoedectetion:"http://127.0.0.1:5003" + "/video_start",server_url: "http://127.0.0.1:5003",activeName: "first",active: 0,centerDialogVisible: true,url_1: "",url_2: "",textarea: "",srcList: [],srcList1: [],feature_list: [],feature_list_1: [],feat_list: [],url: "",visible: false,wait_return: "等待上傳",wait_upload: "等待上傳",loading: false,table: false,isNav: false,showbutton: true,percentage: 0,fullscreenLoading: false,opacitys: {opacity: 0,},dialogTableVisible: false,};},created: function () {document.title = "Yolov5安全帽檢測(cè)web推理部署";},methods: {true_upload() {this.$refs.upload.click();},true_upload2() {this.$refs.upload2.click();},next() {this.active++;},// 獲得目標(biāo)文件getObjectURL(file) {var url = null;if (window.createObjcectURL != undefined) {url = window.createOjcectURL(file);} else if (window.URL != undefined) {url = window.URL.createObjectURL(file);} else if (window.webkitURL != undefined) {url = window.webkitURL.createObjectURL(file);}return url;},// 上傳文件update(e) {this.percentage = 0;this.dialogTableVisible = true;this.url_1 = "";this.url_2 = "";this.srcList = [];this.srcList1 = [];this.wait_return = "";this.wait_upload = "";this.feature_list = [];this.feat_list = [];this.fullscreenLoading = true;this.loading = true;this.showbutton = false;let file = e.target.files[0];this.url_1 = this.$options.methods.getObjectURL(file);let param = new FormData(); //創(chuàng)建form對(duì)象param.append("file", file, file.name); //通過append向form對(duì)象添加數(shù)據(jù)var timer = setInterval(() => {this.myFunc();}, 30);let config = {headers: { "Content-Type": "multipart/form-data" },}; //添加請(qǐng)求頭axios.post(this.server_url + "/upload", param, config).then((response) => {this.percentage = 100;clearInterval(timer);this.url_1 = response.data.image_url;this.srcList.push(this.url_1);this.url_2 = response.data.draw_url;this.srcList1.push(this.url_2);this.fullscreenLoading = false;this.loading = false;this.feat_list = Object.keys(response.data.image_info);for (var i = 0; i < this.feat_list.length; i++) {response.data.image_info[this.feat_list[i]][2] = this.feat_list[i];this.feature_list.push(response.data.image_info[this.feat_list[i]]);}this.feature_list.push(response.data.image_info);this.feature_list_1 = this.feature_list[0];this.dialogTableVisible = false;this.percentage = 0;this.notice1();});},myFunc() {if (this.percentage + 33 < 99) {this.percentage = this.percentage + 33;} else {this.percentage = 99;}},drawChart() {},notice1() {this.$notify({title: "預(yù)測(cè)成功",message: "點(diǎn)擊圖片可以查看大圖",duration: 0,type: "success",});},},mounted() {this.drawChart();},
};
</script><style>
.el-button {padding: 12px 20px !important;
}#hello p {font-size: 15px !important;/*line-height: 25px;*/
}.n1 .el-step__description {padding-right: 20%;font-size: 14px;line-height: 20px;/* font-weight: 400; */
}
</style><style scoped>
* {box-sizing: border-box;margin: 0;padding: 0;
}.dialog_info {margin: 20px auto;
}.text {font-size: 14px;
}.item {margin-bottom: 18px;
}.clearfix:before,
.clearfix:after {display: table;content: "";
}.clearfix:after {clear: both;
}.box-card {width: 680px;height: 200px;border-radius: 8px;margin-top: -20px;
}.divider {width: 50%;
}#CT {display: flex;height: 100%;width: 100%;flex-wrap: wrap;justify-content: center;margin: 0 auto;margin-right: 0px;max-width: 1800px;
}#CT_image_1 {width: 90%;height: 40%;margin: 0px auto;padding: 0px auto;margin-right: 180px;margin-bottom: 0px;border-radius: 4px;
}#CT_image {margin-bottom: 60px;margin-left: 30px;margin-top: 5px;
}.image_1 {width: 275px;height: 260px;background: #ffffff;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}.img_info_1 {height: 30px;width: 275px;text-align: center;background-color: #21b3b9;line-height: 30px;
}.demo-image__preview1 {width: 250px;height: 290px;margin: 20px 60px;float: left;
}.demo-image__preview2 {width: 250px;height: 290px;margin: 20px 460px;/* background-color: green; */
}.error {margin: 100px auto;width: 50%;padding: 10px;text-align: center;
}.block-sidebar {position: fixed;display: none;left: 50%;margin-left: 600px;top: 350px;width: 60px;z-index: 99;
}.block-sidebar .block-sidebar-item {font-size: 50px;color: lightblue;text-align: center;line-height: 50px;margin-bottom: 20px;cursor: pointer;display: block;
}div {display: block;
}.block-sidebar .block-sidebar-item:hover {color: #187aab;
}.download_bt {padding: 10px 16px !important;
}#upfile {width: 104px;height: 45px;background-color: #187aab;color: #fff;text-align: center;line-height: 45px;border-radius: 3px;box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.1), 0 2px 2px 0 rgba(0, 0, 0, 0.2);color: #fff;font-family: "Source Sans Pro", Verdana, sans-serif;font-size: 0.875rem;
}.file {width: 200px;height: 130px;position: absolute;left: -20px;top: 0;z-index: 1;-moz-opacity: 0;-ms-opacity: 0;-webkit-opacity: 0;opacity: 0; /*css屬性&mdash;&mdash;opcity不透明度,取值0-1*/filter: alpha(opacity=0);cursor: pointer;
}#upload {position: relative;margin: 0px 0px;
}#Content {width: 85%;height: 800px;background-color: #ffffff;margin: 15px auto;display: flex;min-width: 1200px;
}.divider {background-color: #eaeaea !important;height: 2px !important;width: 100%;margin-bottom: 50px;
}.divider_1 {background-color: #ffffff;height: 2px !important;width: 100%;margin-bottom: 20px;margin: 20px auto;
}.steps {font-family: "lucida grande", "lucida sans unicode", lucida, helvetica,"Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;color: #21b3b9;text-align: center;margin: 15px auto;font-size: 20px;font-weight: bold;text-align: center;
}.step_1 {/*color: #303133 !important;*/margin: 20px 26px;
}#info_patient {margin-top: 10px;margin-right: 160px;
}
</style>

6、參考資料

yolov5-flask-web - 知乎 (zhihu.com)

Flask部署YOLOv5 - 知乎 (zhihu.com)

https://zhuanlan.zhihu.com/p/104273184

特別感謝作者

GitHub - Sharpiless/Yolov5-Flask-VUE: 基于Flask+VUE前后端,在阿里云公網(wǎng)WEB端部署YOLOv5目標(biāo)檢測(cè)模型

7、代碼分享?

http://aloenet.com.cn/news/34860.html

相關(guān)文章:

  • 信陽網(wǎng)站建設(shè)策劃方案廣東今日最新疫情通報(bào)
  • 酒類網(wǎng)站建設(shè)方案海南seo排名優(yōu)化公司
  • 黃石做網(wǎng)站的公司網(wǎng)絡(luò)營銷實(shí)施計(jì)劃
  • wordpress主題下新建頁面網(wǎng)站seo站外優(yōu)化
  • 杭州百度推廣公司有幾家手機(jī)優(yōu)化軟件排行
  • 網(wǎng)站建設(shè)的公司哪家是上市公司電商培訓(xùn)基地
  • 網(wǎng)站建設(shè)公司怎么做業(yè)務(wù)aso優(yōu)化教程
  • 瀘州市住房與城鄉(xiāng)建設(shè)局網(wǎng)站google免費(fèi)入口
  • 珠海網(wǎng)站制作首頁上線了建站
  • 怎么購買網(wǎng)站空間免費(fèi)廣告發(fā)布平臺(tái)
  • 2023年企業(yè)年報(bào)入口推動(dòng)防控措施持續(xù)優(yōu)化
  • wordpress+4.5+多站點(diǎn)手機(jī)百度免費(fèi)下載
  • 網(wǎng)站設(shè)計(jì)怎么做創(chuàng)建自己的網(wǎng)站怎么弄
  • 閔行網(wǎng)站設(shè)計(jì)seo專家是什么意思
  • 六安建設(shè)局網(wǎng)站百度搜索關(guān)鍵詞數(shù)據(jù)
  • bec聽力哪個(gè)網(wǎng)站做的好網(wǎng)站制作公司排名
  • wordpress tag 別名北京優(yōu)化seo公司
  • 石家莊百度推廣家莊網(wǎng)站建設(shè)提高搜索引擎檢索效果的方法
  • 成都網(wǎng)站排名 生客seo自己搭建網(wǎng)站
  • 網(wǎng)站內(nèi)地圖位置怎么做制作app軟件平臺(tái)
  • wordpress如何上傳超過2m合肥seo網(wǎng)站排名
  • 公安廳網(wǎng)站 做10道相關(guān)題目2022年小學(xué)生新聞?wù)畻l
  • 河南網(wǎng)站制作線上銷售平臺(tái)有哪些
  • 貴州省網(wǎng)站節(jié)約化建設(shè)通知公司網(wǎng)址怎么制作
  • php網(wǎng)站開發(fā)需要什么軟件友情鏈接獲取的途徑有哪些
  • 網(wǎng)站后臺(tái)視頻app開發(fā)公司哪家好
  • 有關(guān)做聚合物電池公司的網(wǎng)站什么是網(wǎng)絡(luò)營銷渠道
  • 河南網(wǎng)站推廣網(wǎng)站seo好學(xué)嗎
  • 網(wǎng)站建設(shè)方案市場營銷策劃方案
  • 青島網(wǎng)站制作價(jià)格南京百度提升優(yōu)化