微软开源神器OmniParser-v2.0本地部署教程

安装python环境

我这里是以前安装好的版本:python 3.11.5,这里不再介绍,有需要的可以在网上找教程。

安装Anaconda

我这里是以前安装好的版本:conda 23.7.4,这里也不再介绍,有需要的可以在网上找教程。

安装OmniParser

git clone https://github.com/microsoft/OmniParser.git
cd OmniParser

创建专属环境

conda create -n "omni" python==3.11
conda activate omni

执行下面命令,下载所需要的依赖包。

pip install -r requirements.txt

下载 microsoft/OmniParser-v2.0 模型文件,但是一直进不去网址(https://huggingface.co),所以我选择了https://hf-mirror.com/。

在这里插入图片描述

找到microsoft/OmniParser-v2.0

在这里插入图片描述

进去之后点击icon_caption和icon_detect)文件夹,分别下载里面文件。

在这里插入图片描述

主要为下面6个文件。

icon_detect/train_args.yaml
icon_detect/model.pt
icon_detect/model.yaml
icon_caption/config.json
icon_caption/generation_config.json
icon_caption/model.safetensors

在项目目录下新建目录,具体如下

mkdir -p weights/icon_detect
mkdir -p weights/icon_caption_florence

完成效果如下:

在这里插入图片描述

将前面下载好的文件分别对应的文件夹。

在这里插入图片描述

运行 python gradio_demo.py 命令,稍等之后出现如下面报错。

[2025-02-25 20:11:26,669] [ WARNING] easyocr.py:80 - Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
Traceback (most recent call last):File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connection.py", line 203, in _new_connsock = connection.create_connection(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connectionraise errFile "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connectionsock.connect(sa)
TimeoutError: timed outThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopenresponse = self._make_request(^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_requestraise new_eFile "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_requestself._validate_conn(conn)File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connectionpool.py", line 1096, in _validate_connconn.connect()File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connection.py", line 611, in connectself.sock = sock = self._new_conn()^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connection.py", line 212, in _new_connraise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)')The above exception was the direct cause of the following exception:Traceback (most recent call last):File "D:\DevelopmentTools\Python\Lib\site-packages\requests\adapters.py", line 486, in sendresp = conn.urlopen(^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\connectionpool.py", line 844, in urlopenretries = retries.increment(^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\urllib3\util\retry.py", line 515, in incrementraise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /microsoft/Florence-2-base/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))During handling of the above exception, another exception occurred:Traceback (most recent call last):File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 1376, in _get_metadata_or_catch_errormetadata = get_hf_file_metadata(^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fnreturn fn(*args, **kwargs)^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 1296, in get_hf_file_metadatar = _request_wrapper(^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 280, in _request_wrapperresponse = _request_wrapper(^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 303, in _request_wrapperresponse = get_session().request(method=method, url=url, **params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\requests\sessions.py", line 589, in requestresp = self.send(prep, **send_kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\requests\sessions.py", line 703, in sendr = adapter.send(request, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\utils\_http.py", line 96, in sendreturn super().send(request, *args, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\requests\adapters.py", line 507, in sendraise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /microsoft/Florence-2-base/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000019B3B7505D0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 3ae795ae-e87f-45e3-8c1b-26c359494139)')The above exception was the direct cause of the following exception:Traceback (most recent call last):File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\utils\hub.py", line 342, in cached_fileresolved_file = hf_hub_download(^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fnreturn fn(*args, **kwargs)^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 862, in hf_hub_downloadreturn _hf_hub_download_to_cache_dir(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 969, in _hf_hub_download_to_cache_dir_raise_on_head_call_error(head_call_error, force_download, local_files_only)File "D:\DevelopmentTools\Python\Lib\site-packages\huggingface_hub\file_download.py", line 1489, in _raise_on_head_call_errorraise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.The above exception was the direct cause of the following exception:Traceback (most recent call last):File "E:\OmniParser\gradio_demo.py", line 16, in <module>caption_model_processor = get_caption_model_processor(model_name="florence2", model_name_or_path="weights/icon_caption_florence")^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "E:\OmniParser\util\utils.py", line 63, in get_caption_model_processorprocessor = AutoProcessor.from_pretrained("microsoft/Florence-2-base", trust_remote_code=True)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\models\auto\processing_auto.py", line 305, in from_pretrainedconfig = AutoConfig.from_pretrained(^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\models\auto\configuration_auto.py", line 1075, in from_pretrainedconfig_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\configuration_utils.py", line 594, in get_config_dictconfig_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\configuration_utils.py", line 653, in _get_config_dictresolved_config_file = cached_file(^^^^^^^^^^^^File "D:\DevelopmentTools\Python\Lib\site-packages\transformers\utils\hub.py", line 385, in cached_fileraise EnvironmentError(
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like microsoft/Florence-2-base is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

看着错误很多,其实就是 https://huggingface.co 访问不到的原因。我们将constants.py文件里的 https://huggingface.co 替换为https://hf-mirror.com。

在这里插入图片描述

为此,还是不放心,网上找了教程,又在最前面加了一行设置。

在这里插入图片描述

再次输入 python gradio_demo.py 命令,运行成功如下图所示:

在这里插入图片描述

在浏览器输入:http://127.0.0.1:7861,显示结果如下:

在这里插入图片描述

截一张桌面的图,让他进行分析:

在这里插入图片描述
END

毋庸置疑,好的事情总会到来。而当它来晚时,也不失为一种惊喜。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/24011.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

LLM+多智能体协作:基于CrewAI与DeepSeek的邮件自动化实践

文章目录 引言理解 Flows&#xff08;工作流&#xff09;与 Crews&#xff08;协作组&#xff09;一、环境准备与工具安装1.1 Python环境搭建1.2 创建并激活虚拟环境1.3 安装核心依赖库&#xff08;crewai、litellm&#xff09; 二、本地DeepSeek R1大模型部署2.1 Ollama框架安…

Linux——高级IO

一、前言概念 IO拷贝等待 1. 同步&#xff08;Synchronous&#xff09; vs 异步&#xff08;Asynchronous&#xff09; 核心区别&#xff1a;关注的是消息通知的机制。 同步&#xff1a;调用方主动等待结果&#xff0c;需持续检查任务是否完成。 异步&#xff1a;调用方发起…

Linux:基础IO

文章目录 一、理解"文件"1、狭义上的理解2、广义上的理解3、文件操作的认知4、系统角度 二、C语言文件接口1、ls /proc/[进程id] -l 命令查看当前正在运⾏进程的信息2、stdin 和 stdout 和 stderr 三、系统文件 I/O1、标志位传递的一种方法2、系统调用 open 三、文件…

zabbix数据采集以及自定义监控

目录 1.数据采集 2.自定义监控 2.1客户端 2.2服务端 ​​​​​​​1.数据采集 点击最新数据页面如下图 往下滑查看具体数据 并点击查看图像就可以看到图像了 就可以看到如下图内容 2.自定义监控 我们通过zabbix客户端任何模板就可以监控我们想要的任何资源 如果…

02.25 继承和多态

编写一个如下场景&#xff1a; 有一个英雄Hero类&#xff0c;私有成员&#xff0c;攻击&#xff0c;防御&#xff0c;速度&#xff0c;生命值&#xff0c;以及所有的set get 方法 编写一个 武器 Weapon 类&#xff0c;拥有私有成员攻击力&#xff0c;以及set get 方法 编写一个…

6. grafana的graph简介

1. Settings功能 2. Visualization功能 &#xff08;可视化的方式&#xff0c;后续会写一些&#xff09; 3. Display 功能&#xff08;显示方面的设置&#xff09; bars 柱状图方式显示 lines&#xff08;不选不会出功能&#xff09; line width 线条的粗细 staircase 会让折…

前缀和代码解析

前缀和是指数组一定范围的数的总和,常见的有两种,一维和二维,我会用两道题来分别解析 一维 DP34 【模板】前缀和 题目: 题目解析: 暴力解法 直接遍历数组,遍历到下标为 l 时,开始进行相加,直到遍历到下标为 r ,最后返回总和.这样做的时间复杂度为: O(n) public class Main …

RoCBert:具有多模态对比预训练的健壮中文BERT

摘要 大规模预训练语言模型在自然语言处理&#xff08;NLP&#xff09;任务上取得了最新的最优结果&#xff08;SOTA&#xff09;。然而&#xff0c;这些模型容易受到对抗攻击的影响&#xff0c;尤其是对于表意文字语言&#xff08;如中文&#xff09;。 在本研究中&#xff0…

【原创工具】文件清单生成器 By怜渠客

【原创工具】文件清单生成器 By怜渠客 刚在论坛看到了一个文件列表生成器 文件列表生成器 - 吾爱破解 - 52pojie.cn &#xff0c;和我去年写的一个软件很像&#xff0c;当时我也是有需求&#xff0c;要把一个文件夹里及其子文件夹里所有的文件列出来&#xff0c;就临时弄了个小…

深度学习-6.用于计算机视觉的深度学习

Deep Learning - Lecture 6 Deep Learning for Computer Vision 简介深度学习在计算机视觉领域的发展时间线 语义分割语义分割系统的类型上采样层语义分割的 SegNet 架构软件中的SegNet 架构数据标注 目标检测与识别目标检测与识别问题两阶段和一阶段目标检测与识别两阶段检测器…

【Linux】初始操作系统和进程(一)

目录 前言&#xff1a; 一、冯诺依曼体系结构&#xff1a; 二、操作系统&#xff1a; 1.操作系统是什么&#xff1f; 2.为什么要有操作系统&#xff1f; 3.操作系统是如何管理下层的&#xff1f; 4.操作系统是如何对上层提供服务的&#xff1f; 三、进程&#xff1a; …

【链 表】

【链表】 一级目录1. 基本概念2. 算法分析2.1 时间复杂度2.2 空间复杂度2.3 时空复杂度互换 线性表的概念线性表的举例顺序表的基本概念顺序表的基本操作1. 初始化2. 插入操作3. 删除操作4. 查找操作5. 遍历操作 顺序表的优缺点总结优点缺点 树形结构图形结构单链表基本概念链表…

python-leetcode-字符串解码

394. 字符串解码 - 力扣&#xff08;LeetCode&#xff09; class Solution:def decodeString(self, s: str) -> str:stack []num 0curr_str ""for char in s:if char.isdigit():num num * 10 int(char)elif char [:stack.append((curr_str, num))curr_str, …

力扣 下一个排列

交换位置&#xff0c;双指针&#xff0c;排序。 题目 下一个排列即在组成的排列中的下一个大的数&#xff0c;然后当这个排列为降序时即这个排列最大&#xff0c;因为大的数在前面&#xff0c;降序排列的下一个数即升序。所以&#xff0c;要是想找到当前排列的下一个排列&…

ProGuard加密混淆SpringBoot应用代码

背景 我们的项目是基于SpringCloud架构的微服务应用&#xff0c;采用Docker离线部署方式交付客户&#xff0c;通过授权证书来控制应用的许可功能模块和使用时间。我们已经在代码层已经实现&#xff1a; 基于多维度硬件指纹的绑定验证&#xff0c;cpu id、mac地址、磁盘序列、…

动态链接器(九):.init和.init_array

ELF文件中的.init和.init_array段是程序初始化阶段的重要组成部分&#xff0c;用于在main函数执行前完成必要的初始化操作。 1 .init段和.init_array 段 1.1 作用 .init段包含编译器生成的初始化代码&#xff0c;通常由运行时环境&#xff08;如C标准库的启动例程&#xff0…

Ollama微调

Ollama是一款开源工具&#xff0c;其目标是简化大语言模型在本地环境的部署和使用。它支持多种流行的开源大语言模型&#xff0c;如 Llama 2、Qwen2.5等。在上一篇文章中我们部署Ollama&#xff0c;并使用简单命令管理Ollama。接下来我们学习Ollama的高级应用。通过Ollama的Mod…

DeepSeek开源周Day1:FlashMLA引爆AI推理性能革命!

项目地址&#xff1a;GitHub - deepseek-ai/FlashMLA 开源日历&#xff1a;2025-02-24起 每日9AM(北京时间)更新&#xff0c;持续五天&#xff01; ​ 一、开源周震撼启幕 继上周预告后&#xff0c;DeepSeek于北京时间今晨9点准时开源「FlashMLA」&#xff0c;打响开源周五连…

(七)懒加载预加载

&#xff08;一&#xff09;懒加载 1. 什么是懒加载 懒加载&#xff0c;即延迟加载。在访问页面时&#xff0c;先将 img 元素或其他元素的背景图片路径替换为占位图&#xff08;通常是 1*1px 的小图片&#xff09;&#xff0c;仅当元素进入浏览器可视区域时&#xff0c;才设置…

Revisiting Reverse Distillation for Anomaly Detection

重新审视反向蒸馏在异常检测中的应用 文章链接&#xff1a;点这里 源码链接&#xff1a;点这里 前言 此篇文章是在 Anomaly detection via reverse distillation from one-class embedding 这篇的基础上改进创新的。重新审视了反向蒸馏&#xff08;KD&#xff09;这一想法&am…