Skip to main content

AI_HUB utils package

Project description

AI_HUB

AI utils for developer. such as notice、send massage when model training is over.Bind WeChat Official Account(AI_HUB) 插入在代码里的小工具,可以在模型训练结束时通过公众号及时发送微信消息给自己,提高科研效率。 inferServer: server your ai model as a API and match the tianchi eval 简单的操作把你训练好的模型变为服务API,并且支持天池大赛的流评测。

INSTALL

pip install ai-hub

SAMPLE

NOTICE

from ai_hub import notice
#到AGIHub微信公众号获取个人openid如(oM8pVuBWl8Rw_vFz7rZNgeO4T8H8),需替换为自己的openid
nc = notice("oM8pVuBWl8Rw_vFz7rZNgeO4T8H8")
#借助AGIHub公众号发送消息给自己
nc.sendmsg("hi,AI_HUB.I am su")

inferServer

'''
依赖:pip install ai-hub #(version>=0.1.7) 
测试用例:
model为y=2*x
请求数据为json:{"img":3}
-----------
post请求:
curl localhost:8080/tccapi -X POST -d '{"img":3}'
返回结果 6
'''
from ai_hub import inferServer
import json

class myInfer(inferServer):
    def __init__(self, model):
       	super().__init__(model)
        print("init_myInfer")

    #数据前处理
    def pre_process(self, data):
        print("my_pre_process")
        #json process
        json_data = json.loads(data.decode('utf-8'))
        img = json_data.get("img")
        print("processed data: ", img)
        return img

    #数据后处理
    def post_process(self, data):
        print("post_process")
        processed_data = data
        return processed_data

    #模型预测:默认执行self.model(preprocess_data),一般不用重写
    #如需自定义,可覆盖重写
    #def pridect(self, data):
    #    ret = self.model(data)
    #    return ret

if __name__ == "__main__":
    mymodel = lambda x: x * 2
    my_infer = myInfer(mymodel)
    my_infer.run(debuge=True) #默认为("127.0.0.1", 80),可自定义端口,如用于天池大赛请默认即可,指定debuge=True可获得更多报错信息

TccProgressBar

from ai_hub import TccProgressBar
#定义progress,显示名为training,在竞赛平台TCC上显示该进度条(tccBar_show=false 不影响本地打印进度条)
progress = TccProgressBar(title="training", tccBar_show=True)
for j in progress(range(100)):
    time.sleep(0.1)

TccTensorboard

from ai_hub import Logger
#Logger用法与tensorboard的logger包一致
info= {
    'loss': loss.data[0],
    'accuracy': accuracy.data[0]
}
for tag, value in info.items():
    logger.scalar_summary(tag, value, step)

获取OPENID

1.扫描关注公众号AGIHub

avatar

2.发送“openid”给公众号 即可获得openid

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_hub-0.5.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

ai_hub-0.5.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file ai_hub-0.5.3.tar.gz.

File metadata

  • Download URL: ai_hub-0.5.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ai_hub-0.5.3.tar.gz
Algorithm Hash digest
SHA256 d452c6e0747659491ddf3a58738650667e7cc06886219680ac8513167c56c32e
MD5 0ce92c6891a185620a0e3150482cd1ea
BLAKE2b-256 a75cff87471a72519800e6346a79e545f573e70bfeee06bb5422eb50ce266ad5

See more details on using hashes here.

File details

Details for the file ai_hub-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: ai_hub-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ai_hub-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c14189d8febd5f76de7cbd4cf64014b044a95624cb351d96c013c4c927c5efc5
MD5 dea87610a9913495592b24ff33b22b6e
BLAKE2b-256 db529be7019ea82b7b507c79ac645a6faea1089dec28eed8196fbba2a920f715

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page