first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.venv/
|
||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
12
.idea/checkHand.iml
generated
Normal file
12
.idea/checkHand.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (checkHand)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
||||
33
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
33
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,33 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="rumps" />
|
||||
<item index="1" class="java.lang.String" itemvalue="PyInstaller" />
|
||||
<item index="2" class="java.lang.String" itemvalue="py2app" />
|
||||
<item index="3" class="java.lang.String" itemvalue="pyobjc-framework-Quartz" />
|
||||
<item index="4" class="java.lang.String" itemvalue="PySide2" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="E301" />
|
||||
<option value="E303" />
|
||||
<option value="E501" />
|
||||
<option value="E302" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ShellCheck" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<shellcheck_settings value="SC2086" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (checkHand)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/checkHand.iml" filepath="$PROJECT_DIR$/.idea/checkHand.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM ai-modelscope:v1.0
|
||||
WORKDIR /code
|
||||
COPY . /code
|
||||
|
||||
# 运行网站
|
||||
CMD ["uvicorn", "main:app", "--proxy-headers","--host", "0.0.0.0", "--port", "9741"]
|
||||
19
Dockerfile_base
Normal file
19
Dockerfile_base
Normal file
@@ -0,0 +1,19 @@
|
||||
# 基本镜像,为个人ai项目提供运行环境
|
||||
|
||||
FROM python:3.10
|
||||
COPY ./requirements.txt /requirements.txt
|
||||
|
||||
# 换源为清华大学
|
||||
RUN sed -i s@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
# 解决python 库 cv2报错 libGL.so.1: cannot open shared object file: No such file or directory
|
||||
RUN apt-get clean && apt-get update && apt-get install -y libgl1
|
||||
|
||||
# 更换pip下载地址为阿里云镜像源
|
||||
RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
|
||||
RUN pip config set install.trusted-host mirrors.aliyun.com
|
||||
|
||||
# 从 requirements.txt 安装 python依赖
|
||||
RUN pip install --no-cache-dir -r /requirements.txt
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# ai 手势识别接口
|
||||
|
||||
基于 modelscope + fastapi
|
||||
|
||||
接口地址:http://127.0.0.1:9741/ai/check_hand
|
||||
参数:url 图片地址
|
||||
|
||||
案例:http://127.0.0.1:9741/ai/check_hand?url=http://bj-mc-prod-asset.oss-cn-beijing.aliyuncs.com/wiki-pic/Gesture13.jpg
|
||||
BIN
__pycache__/main.cpython-311.pyc
Normal file
BIN
__pycache__/main.cpython-311.pyc
Normal file
Binary file not shown.
1
ai/__init__.py
Normal file
1
ai/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .checkHandStatic import *
|
||||
BIN
ai/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
ai/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
ai/__pycache__/checkHandStatic.cpython-311.pyc
Normal file
BIN
ai/__pycache__/checkHandStatic.cpython-311.pyc
Normal file
Binary file not shown.
12
ai/checkHandStatic.py
Normal file
12
ai/checkHandStatic.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from modelscope.pipelines import pipeline
|
||||
from modelscope.utils.constant import Tasks
|
||||
|
||||
class checkHandStatic:
|
||||
modelName: str = 'damo/cv_mobileface_hand-static'
|
||||
|
||||
def check(self, url):
|
||||
hand_static = pipeline(
|
||||
task=Tasks.hand_static,
|
||||
model=self.modelName
|
||||
)
|
||||
return hand_static(url)
|
||||
9
main.py
Normal file
9
main.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from fastapi import FastAPI
|
||||
from ai.checkHandStatic import checkHandStatic
|
||||
app = FastAPI()
|
||||
|
||||
# http://0.0.0.0:9741/ai/check_hand?url=http://bj-mc-prod-asset.oss-cn-beijing.aliyuncs.com/wiki-pic/Gesture13.jpg
|
||||
@app.get("/ai/check_hand")
|
||||
async def checkHand(url: str = ''):
|
||||
hand = checkHandStatic()
|
||||
return hand.check(url)
|
||||
10
requirements.txt
Normal file
10
requirements.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
fastapi==0.113.0
|
||||
pydantic==2.8.0
|
||||
uvicorn==0.27.1
|
||||
|
||||
modelscope==1.12.0
|
||||
torch==2.2.0
|
||||
numpy==1.26.4
|
||||
torch==2.2.0
|
||||
opencv-python==4.9.0.80
|
||||
torchvision
|
||||
10
笔记.txt
Normal file
10
笔记.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
启动命令:uvicorn main:app --reload --host '0.0.0.0' --port 9741
|
||||
|
||||
|
||||
打包镜像:docker build -t ai_check_hand .
|
||||
打包镜像:docker build -t ai-modelscope:v1.0 .
|
||||
|
||||
docker tag ai-modelscope:v1.0 bmy/ai-modelscope:v1.0
|
||||
|
||||
运行镜像:docker run -d --name ai_check_hand -p 9741:9741 ai_check_hand
|
||||
运行镜像:docker run -d --name ai_check_hand -p 9741:9741 ai-hand-project
|
||||
Reference in New Issue
Block a user