介绍
交通标志识别系统,采用Python TensorFlow构建神经网络,通过对数据集图像的训练,得到模型,然后采用QT构建桌面端可视化操作软件,Django构建网页端WEB可视化操作平台。可识别50多种常见的交通标志。
QT版展示
网页版展示
部分代码
代码语言:python代码运行次数:2复制def upload_img(request):
# 图片上传
file = request.FILES.get('file')
file_name = file.name
with open(os.path.join(settings.MEDIA_ROOT, file_name), 'wb') as f:
for chunk in file.chunks():
f.write(chunk)
upload_url = request.build_absolute_uri(settings.MEDIA_URL file_name)
try:
ImageCheck.objects.create(file_name=file_name, file_url=upload_url)
except ImageCheck:
return restful.server_error(message='数据库发生错误!')
return restful.ok(data={'url': upload_url})
def check_img(request):
# 图片检测
image_url = request.POST.get('img_url')
if not image_url:
return restful.params_error(message='缺少必要的参数image_url')
image_name = image_url.rsplit('/')[-1]
image_path = os.path.join(settings.MEDIA_ROOT, image_name)
pred_name = check_handle(image_path)
try:
obj = ImageCheck.objects.filter(file_name=image_name).last()
obj.check_result = pred_name
obj.save()
except:
return restful.server_error(message='数据库发生错误')
return restful.ok(data={'flower': pred_name, 'chance': str(pred_name) or '0'})