Skip to content

def-a-name/img-description

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Description

img-description 是一个基于 Python Flask 框架开发的 Web 应用。用户上传一张图片后,应用将通过 API 把图片发送给大语言模型(LLM),请求其进行理解与描述,然后返回描述结果。

主要特性

  • 支持多种图片格式上传(png | jpg | jpeg | jpe | tif | tiff | webp | bmp | heic)
  • 图片上传后以 base64 编码暂存在内存中,不缓存到磁盘,减少空间占用和磁盘I/O;
  • 调用阿里云百炼 API,使用 QWEN-VL 系列模型;
  • 流式输出结果,并按照 Markdown 样式渲染;
  • 自定义 prompt,支持 prompt 历史记录的保存、查看和管理;
  • 保存 用户请求模型回应 记录到数据库中,制作了展示页面;
  • 多用户管理;

本地运行

  1. 下载项目

    git clone https://github.com/def-a-name/img-description.git
    cd img-description
  2. 安装依赖

    建议新建 python 虚拟环境:

    python -m venv venv
    # Linux
    source venv/bin/activate
    # Windows Powershell
    .\venv\Scripts\Activate.ps1
    python -m pip install -r requirements.txt
  3. 添加 API-Key

    阿里云百炼平台 的 API-Key 添加到 环境变量DASHSCOPE_API_KEY 中,或者直接在 api.py 里替换。

  4. 启动应用

    python app.py

    应用将默认以 debug 模式在本地运行,可访问 http://127.0.0.1:5000

部署

  • 关闭 FlaskDebug 模式(app.py 中 app.run(debug=False))
  • 使用 GunicornuWSGIWSGI 服务器运行 Flask
    # gunicorn 示例 
    gunicorn -w 4 -b 127.0.0.1:8000 app:app --timeout 0
  • 使用 Nginx 等工具反向代理;

About

Flask web app which retrives description of an image from LLM models

Resources

License

Stars

Watchers

Forks

Packages

No packages published