Home > Technology peripherals > AI > body text

OCR+ChatGPT is a tough job in identifying food ingredients!

王林
Release: 2023-05-02 17:22:07
forward
1646 people have browsed it

Hello, everyone.

I have shared with you an ingredient list identification program before. This time we use ChatGPT to transform it.

OCR+ChatGPT is a tough job in identifying food ingredients!

The general idea before was to use OCR to identify the text of the ingredient list, and then develop a crawler to crawl the detailed information of each ingredient (crawl Baidu Encyclopedia).

There are two differences in this program. First, the ingredient details are obtained by calling ChatGPT, which eliminates the need for crawling and results in more accurate results.

Second, the web development framework uses gradient. Gradio is similar to streamlit, both of which are designed to facilitate AI personnel to quickly build a framework for web apps.

The source code has been packaged, please see the end of the article.

Simply paste the core code

1. OCR recognition

OCR recognition uses paddle

def __init__(self):
self.paddle_ocr = PaddleOCR(use_angle_cls=False, lang="ch")

def ocr(self, img):
result = self.paddle_ocr.ocr(img, cls=True)
Copy after login

ocr can directly use the pre-trained model, or you can train it yourself A text recognition model. It has been introduced before and will not be repeated here.

OCR+ChatGPT is a tough job in identifying food ingredients!

2. Get ingredient details

Use the drop-down list to display the identified ingredients

OCR+ChatGPT is a tough job in identifying food ingredients!

Click For each ingredient, call ChatGPT's api to obtain ingredient details

OCR+ChatGPT is a tough job in identifying food ingredients!

You can also create an additional dialog box to support further communication with ChatGPT

OCR+ChatGPT is a tough job in identifying food ingredients!

Using ChatGPT also requires magic and api key, everyone needs to solve it by themselves.

The above is the detailed content of OCR+ChatGPT is a tough job in identifying food ingredients!. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!