中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

3d效果圖軟件seo的基礎是什么

3d效果圖軟件,seo的基礎是什么,突發(fā) 佛山出大事,怎么給自己喜歡的人做網(wǎng)站今天初步實現(xiàn)了網(wǎng)頁&#xff0c;上傳圖片&#xff0c;識別顯示結果到頁面的服務。后續(xù)再完善。 采用flask paddleocr bootstrap快速搭建OCR識別服務。 代碼結構如下&#xff1a; 模板頁面代碼文件如下&#xff1a; upload.html : <!DOCTYPE html> <html> <…

今天初步實現(xiàn)了網(wǎng)頁,上傳圖片,識別顯示結果到頁面的服務。后續(xù)再完善。

采用flask + paddleocr+ bootstrap快速搭建OCR識別服務。

代碼結構如下:

模板頁面代碼文件如下:

upload.html :

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head><title>PandaCodeOCR</title><!--靜態(tài)加載 樣式--><link rel="stylesheet" href={{ url_for('static',filename='bootstrap3/css/bootstrap.min.css') }}></link><style>body {font-family: Arial, sans-serif;margin: 0;padding: 0;}.header {background-color: #f0f0f0;text-align: center;padding: 20px;}.title {font-size: 32px;margin-bottom: 10px;}.menu {list-style-type: none;margin: 0;padding: 0;overflow: hidden;background-color: #FFDEAD;border: 2px solid #DCDCDC;}.menu li {float: left;font-size: 24px;}.menu li a {display: block;color: #333;text-align: center;padding: 14px 16px;text-decoration: none;}.menu li a:hover {background-color: #ddd;}.content {padding: 20px;border: 2px solid blue;}</style>
</head>
<body><div class="header"><div class="title">PandaCodeOCR</div></div><ul class="menu"><li><a href="http://localhost:5000/uploader">通用文本識別</a></li></ul><div class="content"><!--上傳圖片文件--><div id="upload_file"><form action="http://localhost:5000/uploader" method="POST" enctype="multipart/form-data"><div class="form-group"><input type="file" class="form-control" id="upload_file" name="upload_file" placeholder="upload_file"></div><div class="form-group"><button type="submit" class="form-control btn-primary">上傳圖片文件</button></div></form></div></div>
</body>
</html>

result.html :

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head><title>結果</title><!--靜態(tài)加載 樣式--><link rel="stylesheet" href={{ url_for('static',filename='bootstrap3/css/bootstrap.min.css') }}></link><style>body {font-family: Arial, sans-serif;margin: 0;padding: 0;}.header {background-color: #f0f0f0;text-align: center;padding: 20px;}.title {font-size: 32px;margin-bottom: 10px;}.menu {list-style-type: none;margin: 0;padding: 0;overflow: hidden;background-color: #FFDEAD;border: 2px solid #DCDCDC;}.menu li {float: left;font-size: 24px;}.menu li a {display: block;color: #333;text-align: center;padding: 14px 16px;text-decoration: none;}.menu li a:hover {background-color: #ddd;}</style>
</head>
<body><div class="header"><div class="title">PandaCodeOCR</div></div><ul class="menu"><li><a href="http://localhost:5000/uploader">通用文本識別</a></li></ul><div class="row"><!--顯示上傳的圖片--><div class="col-md-6" style="border: 2px solid #ddd;"><span class="label label-info">上傳圖片</span><!--靜態(tài)加載 圖片--><img src="{{ url_for('static', filename = result_dict['filename'])}}" alt="show_img"  class="img-responsive"></div><div class="col-md-6" style="border: 2px solid #ddd;"><!--顯示識別結果JSON報文列表--><span class="label label-info">識別結果:</span>{% for line_str in result_dict['result'] %}<p class="text-left">{{ line_str['text'] }}</p>{% endfor %}</div></div>
</body>
</html>
<!--靜態(tài)加載 script-->
<script src={{ url_for('static',filename='jquery1.3.3/jquery.min.js')}}></script>

?主要視圖代碼文件如下:

views.py :
import json
import os
import timefrom . import blue_task
from flask import Flask, render_template, requestfrom paddleocr import PaddleOCR
from PIL import Image,ImageDraw
import numpy as np'''
自定義模型測試ocr方法
'''def test_model_ocr(img):# 返回字典結果對象result_dict = {'result': []}# paddleocr 目前支持的多語言語種可以通過修改lang參數(shù)進行切換# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`# 使用CPU預加載,不用GPU# 模型路徑下必須包含model和params文件,目前開源的v3版本模型 已經(jīng)是識別率很高的了# 還要更好的就要自己訓練模型了。ocr = PaddleOCR(det_model_dir='./inference/ch_PP-OCRv3_det_infer/',rec_model_dir='./inference/ch_PP-OCRv3_rec_infer/',cls_model_dir='./inference/ch_ppocr_mobile_v2.0_cls_infer/',use_angle_cls=True, lang="ch", use_gpu=False)# 識別圖片文件result0 = ocr.ocr(img, cls=True)result = result0[0]for index in range(len(result)):line = result[index]tmp_dict = {}points = line[0]text = line[1][0]score = line[1][1]tmp_dict['points'] = pointstmp_dict['text'] = texttmp_dict['score'] = scoreresult_dict['result'].append(tmp_dict)return result_dict# 轉換圖片
def convert_image(image, threshold=None):# 閾值 控制二值化程度,不能超過256,[200, 256]# 適當調(diào)大閾值,可以提高文本識別率,經(jīng)過測試有效。if threshold is None:threshold = 200print('threshold : ', threshold)# 首先進行圖片灰度處理image = image.convert("L")pixels = image.load()# 在進行二值化for x in range(image.width):for y in range(image.height):if pixels[x, y] > threshold:pixels[x, y] = 255else:pixels[x, y] = 0return image@blue_task.route('/upload')
def upload_file():return render_template('upload.html')@blue_task.route('/uploader', methods=['GET', 'POST'])
def uploader():if request.method == 'POST':#每個上傳的文件首先會保存在服務器上的臨時位置,然后將其實際保存到它的最終位置。filedata = request.files['upload_file']upload_filename = filedata.filenameprint(upload_filename)#保存文件到指定路徑#目標文件的名稱可以是硬編碼的,也可以從 ?request.files[file] ?對象的? filename ?屬性中獲取。#但是,建議使用 ?secure_filename()? 函數(shù)獲取它的安全版本img_path = os.path.join('upload/', upload_filename)filedata.save(img_path)print('file uploaded successfully')start = time.time()print('=======開始OCR識別======')# 打開圖片img1 = Image.open(img_path)# 轉換圖片, 識別圖片文本# print('轉換圖片,閾值=220時,再轉換為ndarray數(shù)組, 識別圖片文本')# 轉換圖片img2 = convert_image(img1, 220)# Image圖像轉換為ndarray數(shù)組img_2 = np.array(img2)# 識別圖片result_dict = test_model_ocr(img_2)# 識別時間end = time.time()recognize_time = int((end - start) * 1000)result_dict["filename"] = img_pathresult_dict["recognize_time"] = str(recognize_time)result_dict["error_code"] = "000000"result_dict["error_msg"] = "識別成功"# return json.dumps(result_dict, ensure_ascii=False), {'Content-Type': 'application/json'}# render_template方法:渲染模板# 參數(shù)1: 模板名稱  參數(shù)n: 傳到模板里的數(shù)據(jù)return render_template('result.html', result_dict=result_dict)else:return render_template('upload.html')

啟動flask應用,測試結果如下:

http://www.risenshineclean.com/news/27476.html

相關文章:

  • 杭州哪家做企業(yè)網(wǎng)站網(wǎng)絡廣告
  • 南通公司建站模板百度號碼認證申訴平臺
  • 外貿(mào)網(wǎng)站建設價格應用商店aso優(yōu)化
  • 市委辦公廳網(wǎng)站 做合格黨辦人推廣策劃方案模板
  • 深圳政府在線網(wǎng)站石家莊網(wǎng)絡seo推廣
  • 群暉套件wordpressseo優(yōu)化教程視頻
  • 便宜做網(wǎng)站灰色行業(yè)推廣平臺網(wǎng)站
  • 網(wǎng)站模板怎么做有沒有免費的廣告平臺
  • 北京做網(wǎng)站的軟文街怎么樣
  • 做電子商務網(wǎng)站需要什么軟件seo標題優(yōu)化褲子關鍵詞
  • 電子商務網(wǎng)站規(guī)劃的原則是什么專門做排名的軟件
  • wp網(wǎng)站源碼百度最新財報
  • 網(wǎng)站制作論文題目網(wǎng)絡營銷師主要做什么
  • 怎樣制作自己的網(wǎng)站網(wǎng)頁游戲推廣平臺
  • 百容千域可以免費做網(wǎng)站嗎上海廣告公司
  • 機械門戶網(wǎng)站建設特點市場營銷推廣策劃
  • 百度收錄網(wǎng)站怎么更改關鍵詞長沙網(wǎng)站優(yōu)化指導
  • 有什么做任務的網(wǎng)站嗎網(wǎng)絡營銷有哪些模式
  • 企業(yè)汽車網(wǎng)站建設關鍵詞優(yōu)化難度查詢
  • 韓國女足還能出線嗎愛站seo綜合查詢
  • 做網(wǎng)站的公司叫什么名字國際新聞最新消息戰(zhàn)爭
  • 專業(yè)網(wǎng)站開發(fā)公司免費發(fā)布推廣的平臺有哪些
  • 企業(yè)網(wǎng)站 .net正規(guī)考證培訓機構
  • 開發(fā)公司總工崗位職責網(wǎng)站優(yōu)化策略分析
  • 無錫微網(wǎng)站開發(fā)方象科技服務案例
  • 作品集用什么網(wǎng)站做模板建站難嗎
  • 網(wǎng)站建設需求怎么寫河北百度推廣客服電話
  • 可以注冊郵箱的網(wǎng)站今天微博熱搜前十名
  • 網(wǎng)站開發(fā)語言怎么看中國國際新聞
  • 網(wǎng)頁版微信二維碼怎么生成seo網(wǎng)站關鍵詞優(yōu)化方法