Home  >  Article  >  Technology peripherals  >  OCR+ChatGPT is a tough job in identifying food ingredients!

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

王林
王林forward
2023-05-02 17:22:071674browse

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)

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!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete