【问题标题】:Image Upload Functionlity in wit.ai, without using facebook messengerwit.ai 中的图片上传功能,无需使用 facebook messenger
【发布时间】:2017-01-26 19:43:01
【问题描述】:

我正在使用wit.ai 和我自己的用户界面而不是 facebook Messenger 开发一个聊天机器人。我正在使用python 来执行操作。 This postthis post 提供了一些关于如何在 facebook messenger 中完成此操作的见解。但是我想在我自己的 UI 中使用图像上传和显示功能,它使用 wit.ai。如何做到这一点?

我当前的代码可以提取一个名为uploadintent 并调用uploadImage() 函数。 uploadImage() 功能中应该有什么可以上传图片甚至显示在聊天 UI 中的功能?

【问题讨论】:

    标签: python nlp chat chatbot wit.ai


    【解决方案1】:

    以下适用于一般 Python 程序。我不确定这是否是使用 wit.ai 的正确方法。

    如果你想对图像进行图像处理,我推荐OpenCV library。使用它和easygui 库,您可以提示用户输入图像、阅读并显示它。以下代码显示了如何处理它。该对话框默认为文件夹“c:\”,并具有针对 png 和 jpg 文件的过滤器。您需要弄清楚如何在 UI 中显示图像。

    import numpy as np
    import cv2
    import easygui
    
    # Prompt the user to open a file.
    file_path = easygui.fileopenbox(msg='Locate an image file',
                                filetypes=["*.png", "*.jpg"],
                                title='Specify the image file to upload', 
                                default='c:\*.png')
    # Load an image
    img = cv2.imread(file_path)
    cv2.imshow('image', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    

    【讨论】:

    • 是的,虽然这可以完美地工作,但我需要一个解决方案来将它与 wit.ai 集成。
    猜你喜欢
    • 2017-01-23
    • 1970-01-01
    • 2016-11-05
    • 2016-12-02
    • 1970-01-01
    • 2023-03-03
    • 2017-04-26
    • 1970-01-01
    • 2016-09-10
    相关资源
    最近更新 更多