首页 > 其他分享 >D2-浦语·灵笔图文理解创作 Demo

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

时间:2024-01-05 21:01:01浏览次数:20  
标签:6006 -- 灵笔 Shanghai xcomposer internlm Demo root D2

这里我使用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 [email protected] -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

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


标签:6006,--,灵笔,Shanghai,xcomposer,internlm,Demo,root,D2
From: https://blog.51cto.com/morcake/9118470

相关文章

  • D3-Lagent 智能体工具调用 Demo
    现在还是使用 InternStudio 中的A100(1/4)机器、InternLM-Chat-7B 模型和 Lagent 框架部署一个智能工具调用Demo。Lagent是一个轻量级、开源的基于大语言模型的智能体(agent)框架,支持用户快速地将一个大语言模型转变为多种类型的智能体,并提供了一些典型工具为大语言模型赋能......
  • D2-InternLM-Chat-7B 智能对话 Demo
    使用InternStudio中的A100(1/4)机器和InternLM-Chat-7B模型部署一个智能对话Demo。一、环境准备进入 conda 环境:bash#请每次使用jupyterlab打开终端时务必先执行bash命令进入bash中使用以下命令从本地克隆一个已有的 pytorch2.0.1 的环境:condacreate--nameinte......
  • Linux驱动开发笔记(六):用户层与内核层进行数据传递的原理和Demo
    前言  驱动作为桥梁,用户层调用预定义名称的系统函数与系统内核交互,而用户层与系统层不能直接进行数据传递,进行本篇主要就是理解清楚驱动如何让用户编程来实现与内核的数据交互传递。<br>温故知新设备节点是应用层(用户层)与内核层交互;使用预先的结构体进行操作,如系统open函数......
  • 使用CMakeLists.txt创建一个动态库工程Demo给main程序使用
    主要需求是把hello程序编译动态库,再main程序或者第三方程序执行的时候动态加载。工程目录如下:$ls-al*-rw-r--r--1neuti197609352Oct2019:30CMakeLists.txtinclude:total1drwxr-xr-x1neuti1976090Oct2019:30./drwxr-xr-x1neuti1976090Oct201......
  • 解决方案 | VS2022 + AutoCAD2024 + ObjectARX2024环境搭建过程
    一、准备工具1.vs2022自行网络搜索,各种版本均可(比如专业版、社区版),注意使用社区版必须使用最新版,目前是17.8版本,否则最终会无法使用样板。2.cad2024 自行网络搜索3.ObjectARX2024SDK和 ObjectARX2024 Wizard  3.1给出 ObjectARX2024SDK的下载地址:https://damasset......
  • svelte的一些基础demo
    脚手架Vite:vite是集成了svelte,初始化的时候选择svelte就行了。npminitviteSvelteKit:底层基于vite的更上层框架,类似于nextjs。[email protected]文件结构和vue类似svelte文件是.svelte结尾的文件,比如demo.svelte......
  • JavaScript读写15693 ICod2 卡源码
    本示例使用设备:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="......
  • 随机点名demo+文字特效
    上代码:一、HTML部分<div><h2>随机点名</h2><spanid="name"></span></div><buttonid="button-text">点一下不要钱</button>二、CSS部分*{margin:0;padd......
  • demo
    importReact,{useState,useEffect}from'react';import{Modal,Button,Form,Checkbox}from'antd';import{useForm}from'antd/lib/form/Form';interfaceResourceSelectProps{form:ReturnType<typeofuseForm>......
  • 003元素定位方式与项目demo创建
    一、环境搭建1、创建项目,添加java-client依赖包             新建maven项目,引入java-client依赖包       2、创建并编写代码 测试运行以上代码,运行前需打开Appnium.Appnium没有打开时,运行会报错:Connectionrefused:connect 二、......