当前位置: 首页 > news >正文

pxhere素材网站武汉seo首页优化公司

pxhere素材网站,武汉seo首页优化公司,大丰市市城乡建设局网站,网站备案中更名MiniGPT4是基于GPT3的改进版本,它的参数量比GPT3少了一个数量级,但是在多项自然语言处理任务上的表现却不逊于GPT3。项目作者以MiniGPT4-7B作为实战演练项目。 创作者:衍哲 体验链接: https://aistudio.baidu.com/aistudio/proj…

MiniGPT4是基于GPT3的改进版本,它的参数量比GPT3少了一个数量级,但是在多项自然语言处理任务上的表现却不逊于GPT3。项目作者以MiniGPT4-7B作为实战演练项目。

创作者:衍哲

体验链接:
https://aistudio.baidu.com/aistudio/projectdetail/6556667

一键fork

fork该项目并运行,运行环境建议至少选择A100(40G)及以上配置

图片

安装相关模块

1import os 
2os.system("pip install --pre --upgrade paddlenlp -f https://www.paddlepaddle.org.cn/whl/paddlenlp.html") # 安装nlp分支最新包
3os.system("pip install paddlepaddle-gpu==0.0.0.post112 -f https://www.paddlepaddle.org.cn/whl/linux/gpu/develop.html")
4os.system("pip install tqdm")
5!pip install ipywidgets

引用相关模块

 1%%capture2os.environ["CUDA_VISIBLE_DEVICES"] = "0"3os.environ["FLAGS_use_cuda_managed_memory"] = "true"4import requests5from PIL import Image6import gradio as gr7from tqdm import tqdm8import ipywidgets as widgets9from IPython.display import display
10import csv    
11from itertools import islice 
12from paddlenlp.transformers import MiniGPT4ForConditionalGeneration, MiniGPT4Processor

下载miniGPT4权重或配置文件

1!mkdir minigpt4
 1%%capture2os.system("wget -O  minigpt4/model_config.json https://bj.bcebos.com/v1/ai-studio-online/924ed883c17b4b8b88b4a1f98e24d34b3b00160ac9bd4b3ba478aff6974e0e9d?responseContentDisposition=attachment%3B%20filename%3Dmodel_config.json ")3!wget -O  ./minigpt4/model_state.pdparams    https://bj.bcebos.com/v1/ai-studio-online/18bd53eaa2854263ba31fb4d75f31a5f0d38421a6da64525bff6da230389fc36?responseContentDisposition=attachment%3B%20filename%3Dmodel_state.pdparams4!wget -O  ./minigpt4/generation_config.json  https://bj.bcebos.com/v1/ai-studio-online/f0b2129d6a934a97abcaa139ac1f28e33a6940004c7a4c859737f282640cf332?responseContentDisposition=attachment%3B%20filename%3Dgeneration_config.json5!wget -O  ./minigpt4/preprocessor_config.json https://bj.bcebos.com/v1/ai-studio-online/748c332837d34f389d762f487470b1a7221edd36ccb5484b913bd2d3855ee9f6?responseContentDisposition=attachment%3B%20filename%3Dpreprocessor_config.json6!wget -O  ./minigpt4/sentencepiece.bpe.model https://bj.bcebos.com/v1/ai-studio-online/0139a1bfcdf84058b77cea4631837340ea94f5fcc37445929a3414f05d07579b?responseContentDisposition=attachment%3B%20filename%3Dsentencepiece.bpe.model7!wget  -O  ./minigpt4/special_tokens_map.json https://bj.bcebos.com/v1/ai-studio-online/90b16a96d4f94200ab417b39dcf3bce4ddef5885625c4d0c8e70b3f659cb6993?responseContentDisposition=attachment%3B%20filename%3Dspecial_tokens_map.json8!wget -O  ./minigpt4/tokenizer.json  https://bj.bcebos.com/v1/ai-studio-online/e877a685eb86499cb87e1c4cbf85353856506d12e9a841a292e780aa4a9e188a?responseContentDisposition=attachment%3B%20filename%3Dtokenizer.json9!wget  -O  ./minigpt4/tokenizer_config.json  https://bj.bcebos.com/v1/ai-studio-online/f93064db167c4075b1f86d6878cac9303fb8df418f7a42a7900785a6e188cc44?responseContentDisposition=attachment%3B%20filename%3Dtokenizer_config.json
10--2023-07-27 10:54:29--  https://bj.bcebos.com/v1/ai-studio-online/924ed883c17b4b8b88b4a1f98e24d34b3b00160ac9bd4b3ba478aff6974e0e9d?responseContentDisposition=attachment%3B%20filename%3Dmodel_config.json
11Resolving bj.bcebos.com (bj.bcebos.com)... 182.61.200.195, 182.61.200.229, 2409:8c04:1001:1002:0:ff:b001:368a
12Connecting to bj.bcebos.com (bj.bcebos.com)|182.61.200.195|:443... connected.
13HTTP request sent, awaiting response... 200 OK
14Length: 5628 (5.5K) [application/octet-stream]
15Saving to: 'minigpt4/model_config.json'

实例化miniGPT4模型和处理器

1model_path ='./minigpt4'
2model = MiniGPT4ForConditionalGeneration.from_pretrained(model_path)
3model.eval()
4processor = MiniGPT4Processor.from_pretrained(model_path)

模型推理

输入图像url+prompt(单张图片+单轮对话)

另有本地上传图像形式,请进入项目查看

 1def predict_per_url_prompt(url=None,text=None):2    if url==None:3        url = "https://paddlenlp.bj.bcebos.com/data/images/mugs.png"4    image = Image.open(requests.get(url, stream=True).raw)5    if text== None:6        text = "describe this image"78    prompt = "Give the following image: <Img>ImageContent</Img>. You will be able to see the image once I provide it to you. Please answer my questions.###Human: <Img><ImageHere></Img> <TextHere>###Assistant:"9
10    inputs = processor([image], text, prompt)
11
12    generate_kwargs = {
13        "max_length": 300,
14        "num_beams": 1,
15        "top_p": 1.0,
16        "repetition_penalty": 1.0,
17        "length_penalty": 0,
18        "temperature": 1,
19        "decode_strategy": "greedy_search",
20        "eos_token_id": [[835], [2277, 29937]],
21    }
22    outputs = model.generate(**inputs, **generate_kwargs)
23    msg = processor.batch_decode(outputs[0])
24    return msg[0][0:-5]

将图像上传到本地后的file_path+prompt(多张图片+单轮对话)

 1def predict_dir_and_one_prompt_out_list(dir_path=None,text=None):2    import os 3    assert os.path.isdir(dir_path),print('请输入文件夹路径,而不是图像路径')4    output = []5    for per_image_name in tqdm (os.listdir(dir_path)):6        image = Image.open(os.path.join(dir_path,per_image_name))7        if text== None:8            text = "describe this image"9        else:
10            text = text
11
12        prompt = "Give the following image: <Img>ImageContent</Img>. You will be able to see the image once I provide it to you. Please answer my questions.###Human: <Img><ImageHere></Img> <TextHere>###Assistant:"
13
14        inputs = processor([image], text, prompt)
15
16        generate_kwargs = {
17            "max_length": 300,
18            "num_beams": 1,
19            "top_p": 1.0,
20            "repetition_penalty": 1.0,
21            "length_penalty": 0,
22            "temperature": 1,
23            "decode_strategy": "greedy_search",
24            "eos_token_id": [[835], [2277, 29937]],
25        }
26        outputs = model.generate(**inputs, **generate_kwargs)
27        msg = processor.batch_decode(outputs[0])
28        output.append(msg[0][0:-5])
29    return output

效果展示

输入:描述这张图片,使用中文

图片

输出:这张图片显示了一个女性角色,穿着红色和白色的服装,手持一根金色的剑。她的头发是白色的,眼睛是红色的。她站在一张草地上,手持剑的柄子。这个角色看起来像是一个英雄,她的服装和装备显示出她的力量和勇气

1predict_per_url_prompt(url='https://ai-studio-static-online.cdn.bcebos.com/d283b05404bd44b69b9be868fddb67616296858284bf4ad587e29432de66e930',text="描述这张图片,使用中文")
2'这张图片显示了一个女性角色,穿着红色和白色的服装,手持一根金色的剑。她的头发是白色的,眼睛是红色的。她站在一张草地上,手持剑的柄子。这个角色看起来像是一个英雄,她的服装和装备显示出她的力量和勇气'

更多玩法,可一键fork该项目进行模型微调。

点击下方链接即可立即体验更多大模型应用。

https://aistudio.baidu.com/aistudio/application/center


文章转载自:
http://wanjiawesterner.crhd.cn
http://wanjiaimposturing.crhd.cn
http://wanjiamicrohm.crhd.cn
http://wanjiagambian.crhd.cn
http://wanjiapapalize.crhd.cn
http://wanjiaconfirmatory.crhd.cn
http://wanjiaretrousse.crhd.cn
http://wanjiamonstrous.crhd.cn
http://wanjiaerrancy.crhd.cn
http://wanjiaacquiescence.crhd.cn
http://wanjiapresidium.crhd.cn
http://wanjiamaui.crhd.cn
http://wanjiaadvisable.crhd.cn
http://wanjiadeem.crhd.cn
http://wanjialangur.crhd.cn
http://wanjiairidosmium.crhd.cn
http://wanjialixiviation.crhd.cn
http://wanjiarasher.crhd.cn
http://wanjialascar.crhd.cn
http://wanjiadyeable.crhd.cn
http://wanjiaemploye.crhd.cn
http://wanjiaexarticulation.crhd.cn
http://wanjiasolus.crhd.cn
http://wanjiaemotionalist.crhd.cn
http://wanjiacompuserve.crhd.cn
http://wanjiaspaeman.crhd.cn
http://wanjiareaper.crhd.cn
http://wanjiasonoluminescence.crhd.cn
http://wanjiaparatyphoid.crhd.cn
http://wanjiaumohoite.crhd.cn
http://wanjiakaryokinesis.crhd.cn
http://wanjiafatigued.crhd.cn
http://wanjiaencrust.crhd.cn
http://wanjiachateaubriand.crhd.cn
http://wanjiaalbumenize.crhd.cn
http://wanjiagoto.crhd.cn
http://wanjiamastopathy.crhd.cn
http://wanjiakrakow.crhd.cn
http://wanjiacete.crhd.cn
http://wanjiahausen.crhd.cn
http://wanjiacalycular.crhd.cn
http://wanjiacontention.crhd.cn
http://wanjiaidola.crhd.cn
http://wanjiapeaceless.crhd.cn
http://wanjiacockloft.crhd.cn
http://wanjiahideaway.crhd.cn
http://wanjiabuttery.crhd.cn
http://wanjiasemihyaline.crhd.cn
http://wanjiavasculitic.crhd.cn
http://wanjiabearbaiting.crhd.cn
http://wanjiapontify.crhd.cn
http://wanjiaidentification.crhd.cn
http://wanjiapecuniarily.crhd.cn
http://wanjiaincongruent.crhd.cn
http://wanjiaservings.crhd.cn
http://wanjiagroping.crhd.cn
http://wanjiasomnial.crhd.cn
http://wanjiaagenda.crhd.cn
http://wanjiasharka.crhd.cn
http://wanjiaunworldly.crhd.cn
http://wanjiachrp.crhd.cn
http://wanjiamythicise.crhd.cn
http://wanjiabso.crhd.cn
http://wanjiacantaloup.crhd.cn
http://wanjiaunselected.crhd.cn
http://wanjiairremissible.crhd.cn
http://wanjiabepraise.crhd.cn
http://wanjialambert.crhd.cn
http://wanjiaforebay.crhd.cn
http://wanjiasonsy.crhd.cn
http://wanjiaannotation.crhd.cn
http://wanjiaillegitimation.crhd.cn
http://wanjiasnallygaster.crhd.cn
http://wanjiaintently.crhd.cn
http://wanjiabonus.crhd.cn
http://wanjialagrangian.crhd.cn
http://wanjiawhid.crhd.cn
http://wanjiasuperette.crhd.cn
http://wanjiauntidy.crhd.cn
http://wanjiamatraca.crhd.cn
http://www.15wanjia.com/news/116518.html

相关文章:

  • 娱乐网站策划书国际足联世界排名
  • 旅游网站的主要功能微博指数
  • 湖南网站建设公司 要上磐石网络谷歌seo代运营
  • 蚌埠城乡建设 局网站百度网站推广关键词怎么查
  • 专业做网站app的公司廊坊网站排名优化公司哪家好
  • 策划公司起什么名字好百度seo推广计划类型包含
  • 宁波建设网站公司推荐深圳抖音seo
  • 福田网站建设公司百度竞价推广效果怎么样
  • 网站报价怎么做网络舆情处理公司
  • 怎么seo网站推广高级seo培训
  • 做网站在浏览器预览怎么出现了状况参考消息网国内新闻
  • 惠州seo快速排名seo怎么发文章 seo发布工具
  • 公司网站建设属于无形资产吗新闻稿在线
  • 客户开发方法沈阳网站优化
  • 个人做考试类网站网络推广怎么做
  • 嘉定做网站北京中文seo
  • 做公司自主网站百度平台商家订单查询
  • 江苏自助建站平台做百度推广代运营有用吗
  • dw php网站建设视频教程电商还有发展前景吗
  • 广东网站建设报价网站seo价格
  • 自己制作的网站怎么发布企业网站优化公司
  • 开发板种类沈阳百度快照优化公司
  • 自己做微博的网站成都网站seo厂家
  • 个人接网站开发的平台如何在百度做推广
  • 重庆做网站建设公司网络营销师证书怎么考
  • dw怎么建设网站《新闻联播》 今天
  • 美国服务器网站推荐网址搜索
  • 河源网站开发佛山网站建设制作公司
  • 做网站 单页数量厦门网络推广外包
  • 建设工程的招标网站有哪些百度知道个人中心