Comments (5)
Забыл сказать, что если запускаю просто код "Hello World", то все нормально проходит и распознавание отрабатывается.
from nomeroff-net.
@Sergio-Badanin
передавайте graph = tf.get_default_graph()
когда вызываете функций распознавании, а в функциях распознавания добавьте
def function_recognition(): with graph.as_default(): #operations of function
попробуйте так и отпишитесь если работает
from nomeroff-net.
Поставил после img = mpimg.imread(imgPath):
@app.route("/", methods=["POST", "GET"])
def index():
if request.method == "POST":
file = request.files["file"]
if file and (file.content_type.rsplit('/', 1)[1] in ALLOWED_EXTENSIONS).__bool__():
filename = secure_filename(file.filename)
file.save(NOMEROFF_NET_DIR + '/examples/images/' + filename)
imgPath = (NOMEROFF_NET_DIR + '/examples/images/' + filename)
img = mpimg.imread(imgPath)
graph = tf.get_default_graph()
NP = nnet.detect([img])
cv_img_masks = filters.cv_img_mask(NP)
arrPoints = rectDetector.detect(cv_img_masks)
zones = rectDetector.get_cv_zonesBGR(img, arrPoints)
regionIds, stateIds, countLines = optionsDetector.predict(zones)
regionNames = optionsDetector.getRegionLabels(regionIds)
textArr = textDetector.predict(zones)
textArr = textPostprocessing(textArr, regionNames)
print(textArr)
return render_template("index.html")
Выдает ошибку:
[2020-03-04 12:27:13,016] ERROR in app: Exception on / [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/src/nomeroff-net/examples/py/site.py", line 52, in index
graph = tf.get_default_graph()
NameError: name 'tf' is not defined
from nomeroff-net.
это на верху где импорты
import
tensorflow as tf
graph = tf.get_default_graph()
`
и снизу где def index
`with graph.as_default():
NP = nnet.detect([img])
cv_img_masks = filters.cv_img_mask(NP)
.....`
from nomeroff-net.
@GalymzhanAbdimanap , премного благодарен!
Заработало в таком варианте:
import os
import numpy as np
import sys
import matplotlib.image as mpimg
import tensorflow as tf
import warnings
graph = tf.get_default_graph()
warnings.filterwarnings('ignore')
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
NOMEROFF_NET_DIR = os.path.abspath('../../')
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
MASK_RCNN_DIR = os.path.join(NOMEROFF_NET_DIR, 'Mask_RCNN')
MASK_RCNN_LOG_DIR = os.path.join(NOMEROFF_NET_DIR, 'logs')
sys.path.append(NOMEROFF_NET_DIR)
from flask import Flask, render_template, request, url_for
from werkzeug.utils import secure_filename
from NomeroffNet import filters, RectDetector, TextDetector, OptionsDetector, Detector, textPostprocessing, textPostprocessingAsync
nnet = Detector(MASK_RCNN_DIR, MASK_RCNN_LOG_DIR)
nnet.loadModel("latest")
rectDetector = RectDetector()
optionsDetector = OptionsDetector()
optionsDetector.load("latest")
textDetector = TextDetector.get_static_module("eu")()
textDetector.load("latest")
app = Flask(__name__)
@app.route("/", methods=["POST", "GET"])
def index():
global graph
if request.method == "POST":
file = request.files["file"]
if file and (file.content_type.rsplit('/', 1)[1] in ALLOWED_EXTENSIONS).__bool__():
filename = secure_filename(file.filename)
file.save(NOMEROFF_NET_DIR + '/examples/images/' + filename)
imgPath = (NOMEROFF_NET_DIR + '/examples/images/' + filename)
img = mpimg.imread(imgPath)
with graph.as_default():
NP = nnet.detect([img])
cv_img_masks = filters.cv_img_mask(NP)
arrPoints = rectDetector.detect(cv_img_masks)
zones = rectDetector.get_cv_zonesBGR(img, arrPoints)
regionIds, stateIds, countLines = optionsDetector.predict(zones)
regionNames = optionsDetector.getRegionLabels(regionIds)
textArr = textDetector.predict(zones)
textArr = textPostprocessing(textArr, regionNames)
print(textArr)
return render_template("index.html")
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
from nomeroff-net.
Related Issues (20)
- ModuleNotFoundError: No module named 'modelhub_client' HOT 4
- Failed to run get-started-demo.py in docker container HOT 3
- обучать пользовательский набор данных HOT 7
- I have error about checkpoint HOT 5
- KeyError: 'pytorch-lightning_version' HOT 3
- How to train OCR model? HOT 3
- ImportError: cannot import name 'efficientnet_v2_s' from 'torchvision.models' HOT 1
- when change name of folder nomer_net code not work HOT 5
- Size of docker image HOT 1
- Multiline example doesn't return correct recognitions
- draw rectangle bbox on plate HOT 4
- Некорректное распознавание российских номер с регионом 799, 977 HOT 1
- Некорректное распознавание номеров в 3 строки
- Ошибка при установке пакета в req.txt HOT 1
- Columns and DataType Not Explicitly Set on line 157 of datasets_tools.py
- Error in nomeroff-net setup command: 'install_requires' HOT 1
- Label 'md' not in dict_keys && Label changed on default 'eu_ua_2015'
- Realtime Video performance / Benchmrk
- Getting OCR score
- Performance question
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nomeroff-net.