深度学习,图像标注,训练数据。
diffgram的Python项目详细描述
快速启动:
安装
pip install diffgram
在Linux上
pip3 install diffgram
- Get credentials from Diffgram.com
- 从github下载示例文件
- 配置凭据
from diffgram import Project
project = Project(project_string_id = "replace_with_project_string",
client_id = "replace_with_client_id",
client_secret = "replace_with_client_secret" )
file = project.file.from_local(path)
Help articles for Diffgram.com一些文档见下面。
需要python>;=3.5
默认的通过pip安装将安装依赖项
用于requirements.txt
中列出的局部预测(tensorflow opencv)。
大多数功能只需要requests
。
如果您正在寻找最小大小的安装,并且已经有请求使用
--no-dependencies
标志即pip install diffgram --no-dependencies
总流量
使用diffgram的主要流程是 导入数据、训练模型并更新这些模型, 主要是通过改变数据。利用深度学习 并收集反馈信息以返回Diffgram 在你的系统中More on this here.
教程和演练
Red Pepper Chef - from new training data to deployed system in a few lines of code
How to validate your model
Fast Annotation Net
代码示例
项目对象
from diffgram import Project
project = Project(project_string_id = "replace_with_project_string",
client_id = "replace_with_client_id",
client_secret = "replace_with_client_secret" )
project
表示主要起点。
下面的示例假设您有这样定义的项目。
Import data
导入单个本地文件:
file = project.file.from_local(path)
从url导入(ie云提供商)
result = project.file.from_url(url)
(有关已签名的URL,请参阅我们的帮助文章](https://intercom.help/diffgram/getting-started/uploading-media)
Importing existing instances
instance_bravo = {
'type': 'box',
'name': 'cat',
'x_max': 128,
'x_min': 1,
'y_min': 1,
'y_max': 128
}
# Combine into image packet
image_packet = {'instance_list' : [instance_alpha, instance_bravo],
'media' : {
'url' : "https://www.readersdigest.ca/wp-content/uploads/sites/14/2011/01/4-ways-cheer-up-depressed-cat.jpg",
'type' : 'image'
}
}
result = project.file.from_packet(image_packet)
Brain
通过diffgram brain使用预测的好处
- 不同深度学习方法、本地预测与联机预测以及文件类型的干净抽象
- 为改变模型和数据而设计调用.train()的同一对象也可以调用.predict()
- 许多型号的地面支持一个例子见本地摄像机。
当然,本地预测-你的模型就是你的模型。
注:我们计划在未来支持许多深度学习方法, 因此,虽然这相当集中在目标检测上,但是 概念转化为语义分割等方法。
Train
brain = project.train.start(method="object_detection",
name="my_model")
brain.check_status()
Predict Online
在线预测不需要高级设置,使用较少的本地计算资源。
对于在线预测,有三种发送文件的方法
本地文件路径
inference = brain.predict_from_local(path)
url,即远程云服务器
inference = brain.predict_from_url(url)
从diffgram文件
inference = brain.predict_from_file(file_id = 111546)
Predict Local
本地预测下载模型权重、图定义和相关标签。 它将设置模型-警告这可能会占用大量本地计算资源。 默认情况下,模型会下载到一个临时目录,尽管欢迎您下载 并将模型保存到磁盘。
Local prediction, with local file
与以前一样,只是我们将local
标志设置为True
brain = project.get_model(
name = None,
local = True)
然后我们可以致电
inference = brain.predict_from_local(path)
Local prediction, two models with visual
获得两个型号:
page_brain = project.get_model(
name = "page_example_name",
local = True)
graphs_brain = project.get_model(
name = "graph_example_name",
local = True)
这将从本地路径打开一个图像,并在同一个图像上运行两个大脑。 我们只读取一次图像,因此您可以堆叠尽可能多的网络 因为你需要这里
image = open(path, "rb")
image = image.read()
page_inference = page_brain.run(image)
graphs_inference = graphs_brain.run(image)
可选,渲染视觉效果
output_image = page_brain.visual(image_backup)
output_image = graphs_brain.visual(output_image)
想象一下“页面”的大脑,大多数页面看起来都一样,所以它需要的数据更少 减少再培训以达到可接受的绩效水平。 然后你可以有一个单独的网络,它经常被重新训练以检测页面上感兴趣的项目(即图形)。