0
点赞
收藏
分享

微信扫一扫

D2-浦语·灵笔图文理解创作 Demo

这里我使用InternStudio中的 A100(1/4) * 2 机器和internlm-xcomposer-7b 模型部署一个图文理解创作 Demo 。

一、环境准备

选择 A100(1/4)*2 的配置:

D2-浦语·灵笔图文理解创作 Demo_大模型

我的开发机列表:

D2-浦语·灵笔图文理解创作 Demo_大模型_02

打开刚刚租用服务器的进入开发机,并在终端输入 bash 命令,进入 conda 环境,接下来就是安装依赖

进入 conda 环境之后,使用以下命令从本地克隆一个已有的pytorch 2.0.1 的环境:

conda create --name xcomposer-demo --clnotallow=/root/share/conda_envs/internlm-base

然后使用以下命令激活环境:

conda activate xcomposer-demo

接下来运行以下命令,安装 transformersgradio 等依赖包。请严格安装以下版本安装!

pip install transformers==4.33.1 timm==0.4.12 sentencepiece==0.1.99 gradio==3.44.4 markdown2==2.4.10 xlsxwriter==3.1.2 einops accelerate

D2-浦语·灵笔图文理解创作 Demo_开源_03

D2-浦语·灵笔图文理解创作 Demo_大模型_04

二、模型下载

InternStudio平台的 share 目录下已经为我们准备了全系列的 InternLM 模型,所以我们可以直接复制即可。使用如下命令复制:

mkdir -p /root/model/Shanghai_AI_Laboratory

cp -r /root/share/temp/model_repos/internlm-xcomposer-7b /root/model/Shanghai_AI_Laboratory

D2-浦语·灵笔图文理解创作 Demo_大模型_05

三、代码准备

在 /root/code git clone InternLM-XComposer 仓库的代码:

cd /root/code
git clone https://gitee.com/internlm/InternLM-XComposer.git
cd /root/code/InternLM-XComposer
git checkout 3e8c79051a1356b9c388a6447867355c0634932d  # 最好保证和教程的 commit 版本一致

D2-浦语·灵笔图文理解创作 Demo_人工智能_06

四、Demo运行

在终端运行以下代码:

cd /root/code/InternLM-XComposer
python examples/web_demo.py  \
    --folder /root/model/Shanghai_AI_Laboratory/internlm-xcomposer-7b \
    --num_gpus 1 \
    --port 6006

注意前面的环境问题,使用的另外一个环境而不是base,这里便会出现问题:

D2-浦语·灵笔图文理解创作 Demo_开源_07

输入命令正确执行:

D2-浦语·灵笔图文理解创作 Demo_大模型_08

将端口映射到本地。(注意:需要在本地终端输入以下指令 .6006 是在服务器中打开的端口,而 33090 是根据开发机的端口进行更改。

ssh -CNg -L 6006:127.0.0.1:6006 root@ssh.intern-ai.org.cn -p 33090

在本地浏览器输入 http://127.0.0.1:6006可看见加载界面:

D2-浦语·灵笔图文理解创作 Demo_人工智能_09

进入该界面:

D2-浦语·灵笔图文理解创作 Demo_大模型_10

以提示词“又见敦煌”来输入:

D2-浦语·灵笔图文理解创作 Demo_大模型_11

D2-浦语·灵笔图文理解创作 Demo_开源_12

然后它是会下载图像加载出来:

D2-浦语·灵笔图文理解创作 Demo_大模型_13

D2-浦语·灵笔图文理解创作 Demo_人工智能_14

最下面还会有保存功能:

D2-浦语·灵笔图文理解创作 Demo_大模型_15

再以“星链新闻稿”来输入:

D2-浦语·灵笔图文理解创作 Demo_开源_16

英文输入“Shanghai Travel Guide in English”来生成:

D2-浦语·灵笔图文理解创作 Demo_开源_17

选取一小部分来感受:

Shanghai is the largest city in China and one of the most populous cities in the world, with a population of over 24 million people. The city is known for its modern skyscrapers, bustling financial district, and vibrant nightlife. Shanghai is also home to some of the country's top tourist attractions, including the Bund, Yuyuan Garden, and the Oriental Pearl Tower. In this guide, we'll provide you with all the information you need to plan your trip to Shanghai, including tips on where to stay, what to do, and how to get around.

D2-浦语·灵笔图文理解创作 Demo_大模型_18

Where to Stay in Shanghai

When it comes to finding a place to stay in Shanghai, there are plenty of options to choose from. If you're looking for a luxury experience, consider staying at one of the city's five-star hotels, such as the Fairmont Peace Hotel or the Waldorf Astoria Shanghai on the Bund. These hotels offer stunning views of the city skyline, luxurious amenities, and impeccable service.

D2-浦语·灵笔图文理解创作 Demo_开源_19

If you're looking for something more budget-friendly, there are plenty of hostels and guesthouses throughout the city that offer affordable accommodations. Some popular areas to stay include the Xintiandi neighborhood, which is known for its trendy bars and restaurants, and the French Concession, which is filled with charming cafes and boutiques.

此外,还有图片理解的能力,选择“Multimodal Chat”:

D2-浦语·灵笔图文理解创作 Demo_学习_20

在左边上传图片,然后右下方输入问题,选择“Submit”即可:

D2-浦语·灵笔图文理解创作 Demo_学习_21

D2-浦语·灵笔图文理解创作 Demo_大模型_22

经过我的测试,这里的对话能力是比较弱的,对于图像的描述很简单,但它是具备一定的图像识别理解能力的。


举报

相关推荐

D2-栈和队列

0 条评论