Coder Social home page Coder Social logo

scf-gpu-inference-demo's Introduction

SCF GPU 推理 Demo

注意事项

镜像构建

基于腾讯云的TCR服务:

# 登录镜像仓库,$YOUR_REGISTRY_URL请替换为您所使用的镜像仓库,$USERNAME、$PASSWORD分别替换为您的登录凭证
docker login $YOUR_REGISTRY_URL --username $USERNAME --password $PASSWORD

# 镜像构建,$YOUR_IMAGE_NAME 请替换为您所使用的镜像地址
docker build -t scf_gpu_demo:latest .

# 添加Tag
docker tag scf_gpu_demo:latest xxxx.tencentcloudcr.com/yyyy/scf_gpu_demo:latest

# 镜像推送
docker push xxx.tencentcloudcr.com/yyyy/scf_gpu_demo:latest

部署

函数配置

注意:需要创建 Web 函数:

函数类型	Web函数
资源类型	GPU
资源规格	NVIDIA T4 计算型 | 1*T4 16GiB显存 20核 80GiB
初始化超时时间	300秒
执行超时时间	100秒

触发器配置

升级 Web 函数默认的触发器到专享版本之后,可以修改后端超时时间:

公网  https://service-xxx.sh.apigw.tencentcs.com/release/
协议支持	HTTP&HTTPS
请求方法	ANY
启用Base64编码	未启用
支持CORS	否
后端超时	330s

测试

使用默认的内容图片和风格图片:

curl -X GET https://service-xxxx.sh.apigw.tencentcs.com/release/ --output /tmp/transformed.png
open /tmp/transformed.png

迁移效果:

风格迁移

使用自定义的内容图片和风格图片

curl --location --request POST 'https://service-xxx.sh.apigw.tencentcs.com/release/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "content_image_path": "https://web-helloworld-1307427535.cos.ap-guangzhou.myqcloud.com/gpu_demo/woman.jpg",
    "style_image_path": "https://web-helloworld-1307427535.cos.ap-guangzhou.myqcloud.com/gpu_demo/snow.png"
}' \
--output /tmp/transformed.png

open /tmp/transformeded.png

迁移效果:

风格迁移

备注

  • 由于网络原因,SCF无法从 Tensforflow Hub 自动下载模型,建议离线下载之后存放到COS之后,通过COS地址访问
  • 可以通过 hub_model_path 配置事先下载的模型地址,例如 https://xxxx.cos.ap-guangzhou.myqcloud.com/gpu_demo/magenta%3Aarbitrary-image-stylization-v1-256_v2.tar
  • 图片链接需要可以公网可以访问,如果需要额外的权限认证会导致文件下载失败
  • 使用的模型:magenta/arbitrary-image-stylization-v1-256-v2

scf-gpu-inference-demo's People

Contributors

zhengquan avatar

Watchers

Woody avatar Kostas Georgiou avatar

scf-gpu-inference-demo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.