ai概念了解和尝试

本文介绍了如何利用TensorFlow、OpenCV和Tesseract进行人脸识别和文字识别,并概述了学习深度学习框架、岗位需求和实践路线,推荐了几个基于TensorFlow的实战项目作为学习目标。
摘要由CSDN通过智能技术生成

一、了解

一些概念:

tensorflow:一个用来训练数据的框架

opencv:包含已经训练好的模型,和一些图像识别的训练方法

Tesseract:文字识别的模型

二、尝试

1、opencv和tesseract配合,实现人脸识别、文字识别

	public static void main(String[] args) {
        // 人脸识别,使用opencv自带模型
//        faceImage();

        // 文字识别,opencv 转为灰度图像  +  Tesseract提供ocr功能
//        textImage();

        // tensorflow框架尝试
        helloTensorFlow();
    }

    private static void helloTensorFlow() {
        System.out.println("Hello TensorFlow " + TensorFlow.version());

        try (ConcreteFunction dbl = ConcreteFunction.create(HelloTensorFlow::dbl);
             TInt32 x = TInt32.scalarOf(10);
             Tensor dblX = dbl.call(x)) {
            System.out.println(x.getInt() + " doubled is " + ((TInt32)dblX).getInt());
        }
    }

    private static Signature dbl(Ops tf) {
        Placeholder<TInt32> x = tf.placeholder(TInt32.class);
        Add<TInt32> dblX = tf.math.add(x, x);
        return Signature.builder().input("x", x).output("dbl", dblX).build();
    }

 	private static void textImage() {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        // 加载图片
        Mat image = Imgcodecs.imread("C:\\Users\\1\\Desktop\\img_v3_028a_17a5f01a-e8b1-49c0-a30e-87bd10b9213g.jpg");
        // 转为灰度图片(就是0(黑色)-255(白色)),灰度xx的图像,方便识别,降低复杂度
        Mat grayImage = new Mat();
        Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_BGR2GRAY);
        // Apply thresholding to the image
        Imgproc.threshold(grayImage, grayImage, 0, 255, Imgproc.THRESH_BINARY_INV | Imgproc.THRESH_OTSU);
        // Save the processed image
        Imgcodecs.imwrite("processed_image.jpg", grayImage);
        // Use Tesseract for OCR
        Tesseract tesseract = new Tesseract();
        // 设置语言
        tesseract.setLanguage("chi_sim");
        // 设置语言包路径
        tesseract.setDatapath("D:\\software\\Tesseract-OCR\\tessdata");
        try {
            String result = tesseract.doOCR(new File("processed_image.jpg"));
            System.out.println("Recognized text: " + result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }

    private static void faceImage() {
        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
        // 加载OpenCV库
        CascadeClassifier faceDetector = new CascadeClassifier("C:\\Users\\1\\Desktop\\haarcascade_frontalface_default.xml");
        // 加载分类器
        Mat image = Imgcodecs.imread("C:\\Users\\1\\Desktop\\screenshot-20240219-175444.png");
        // 读取图片
        Mat grayImage = new Mat();
        Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_BGR2GRAY);
        Imgproc.equalizeHist(grayImage, grayImage);
        // 将图片转换为灰度图
        MatOfRect faceDetections = new MatOfRect();
        faceDetector.detectMultiScale(grayImage, faceDetections);
        // 使用分类器检测人脸
        for (Rect rect : faceDetections.toArray()) {
            Imgproc.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
                    new Scalar(0, 255, 0), 3);
        }
        // 绘制检测结果
        Imgcodecs.imwrite("result.jpg", image);
    }


三、学习路线

1、岗位需求:

2、需要学习的技术:

深度学习框架:caffe、tensorflow、pytorch

实践能力:ai推理引擎开发经验(比如这个岗位,ai推理可能就是通过学习,预测各个基金股票的走势,然后给出最优投资方案,最大收益最小风险)

可参考课程:机器学习、计算机视觉、自然语言处理、人工智能应用和实践

3、实践步骤:

数据收集、模型选择、参数设置、模型训练、模型评估、模型优化、模型应用

四、目标

学习tensorflow框架,参考完成以下项目之一:

TensorFlow 卷积神经网络 Model Project:
FaceRank - Rank Face by CNN Model based on TensorFlow (add keras version). FaceRank-人脸打分基于 TensorFlow (新增 Keras 版本) 的 CNN 模型(可能是最有趣的 TensorFlow 中文入门实战项目)

https://github.com/fendouai/FaceRank

TensorFlow 循环神经网络 Model Project:
一个比特币交易机器人基于 Tensorflow LSTM 模型,仅供娱乐。 A Bitcoin trade robot based on Tensorflow LSTM model.Just for fun.

https://github.com/TensorFlowNews/TensorFlow-Bitcoin-Robot

TensorFlow Seq2Seq Model Project:
ChatGirl is an AI ChatBot based on TensorFlow Seq2Seq Model.ChatGirl 一个基于 TensorFlow Seq2Seq 模型的聊天机器人。(包含预处理过的 twitter 英文数据集,训练,运行,工具代码,可以运行但是效果有待提高。)

https://github.com/fendouai/ChatGirl

五、参考链接

tensorFlow安装:
https://blog.csdn.net/langhonglin/article/details/124697420
tensorFlow项目:
https://gitee.com/fendouai/Awesome-TensorFlow-Chinese?_from=gitee_search#https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Faymericdamien%2FTensorFlow-Examples

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值