Home > Article > Technology peripherals > OCR+ChatGPT is a tough job in identifying food ingredients!
Hello, everyone.
I have shared with you an ingredient list identification program before. This time we use ChatGPT to transform it.
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
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.
Use the drop-down list to display the identified ingredients
Click For each ingredient, call ChatGPT's api to obtain ingredient details
You can also create an additional dialog box to support further communication with ChatGPT
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!