Introduce.ipynb @master — view markup · raw · history · blame
视觉问答¶
1. 项目介绍¶
视觉问答(Visual Question Answering,VQA)是一项结合计算机视觉和自然语言处理的学习任务,该项目使用 BLIP 视觉语言模态预训练模型在 VQA 任务上进行 Finetuned ,我们只需要上传图片和输入问题,便能快速生成问题答案,快来试试吧!
2. 项目结构¶
In [3]:
# 显示文件夹树状目录
import os
import os.path
def dfs_showdir(path, depth):
if depth == 0:
print("root:[" + path + "]")
for item in os.listdir(path):
if item[0] not in ['.', '__']:
print("| " * depth + "+--" + item)
newitem = path +'/'+ item
if os.path.isdir(newitem):
dfs_showdir(newitem, depth +1)
if __name__ == '__main__':
path = os.getcwd() # 文件夹路径
dfs_showdir(path, 0) # 显示文件夹的树状结构
3. 项目demo¶
In [ ]:
# 环境安装
!/home/jovyan/.virtualenvs/basenv/bin/pip install -r requirement.txt -i https://pypi.doubanio.com/simple/
In [1]:
# 导入相关模块
from app import *
In [2]:
print("Input img:")
Image.open('./img/demo.jpg').resize((256, 256))
Out[2]:
In [4]:
print("Output Answer:")
handle({'Photo': './img/demo.jpg', 'Question': 'What is in this image?'})
Out[4]:
In [ ]: