update sdk

This commit is contained in:
cdllp2 2022-11-09 20:46:52 +08:00
parent 17d2227d7f
commit 055c9d8f26
21 changed files with 77 additions and 29 deletions

View File

@ -9,7 +9,7 @@
"uuid": "animegan-v20221001",
"label": "动漫风格化",
"describe": "图片的全新动漫风格化宫崎骏或新海诚风格的动漫以及4种关于人脸的风格转换。",
"pic": "example.png",
"pic": "example.jpg",
"hot": "1",
"price": "0",
"dataset": {},

View File

@ -17,7 +17,7 @@ class APP1_Model(Model):
status='online'
version='v20221001'
doc='https://github.com/tencentmusic/cube-studio/tree/master/aihub' # 'https://帮助文档的链接地址'
pic='https://user-images.githubusercontent.com/20157705/170216784-91ac86f7-d272-4940-a285-0c27d6f6cd96.jpg' # https://应用描述的缩略图/可以直接使用应用内的图片文件地址
pic='result.jpg' # https://应用描述的缩略图/可以直接使用应用内的图片文件地址
inference_inputs = [
Field(type=Field_type.text, name='arg1', label='推理函数的输入参数arg1',

View File

@ -0,0 +1,22 @@
{
"doc": "https://github.com/tencentmusic/cube-studio/tree/master/aihub",
"field": "机器视觉",
"scenes": "图像识别",
"type": "dateset,notebook,train,inference",
"name": "app1",
"status": "online",
"version": "v20221001",
"uuid": "app1-v20221001",
"label": "示例应用中文名",
"describe": "ai示例应用详细描述都会显示应用描述上支持markdown",
"pic": "result.jpg",
"hot": "1",
"price": "0",
"dataset": {},
"notebook": {
"jupyter": [],
"appendix": []
},
"train": {},
"inference": {}
}

View File

@ -20,7 +20,7 @@ class DDDDOCR_Model(Model):
status='online'
version='v20221001'
doc='https://github.com/tencentmusic/cube-studio/tree/master/aihub/deep-learning/ddddocr'
pic='https://user-images.githubusercontent.com/20157705/191401572-43eb066c-e1cb-451b-8656-260df3a7b0e3.png'
pic='example.png'
inference_inputs = [
Field(type=Field_type.image, name='img_file_path', label='待识别图片', describe='用于验证码识别的图片')
@ -29,7 +29,7 @@ class DDDDOCR_Model(Model):
{
"label":"示例1",
"input":{
"img_file_path": "test.png"
"img_file_path": "test.jpg"
}
}
]
@ -78,7 +78,7 @@ class DDDDOCR_Model(Model):
model=DDDDOCR_Model()
# model.load_model()
# result = model.inference(img_file_path='test.png') # 测试
# result = model.inference(img_file_path='test.jpg') # 测试
# print(result)
# # 启动服务

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

View File

@ -9,7 +9,7 @@
"uuid": "ddddocr-v20221001",
"label": "验证码识别",
"describe": "ai识别验证码文字和验证码目标",
"pic": "https://user-images.githubusercontent.com/20157705/191401572-43eb066c-e1cb-451b-8656-260df3a7b0e3.png",
"pic": "example.png",
"hot": "1",
"price": "0",
"dataset": {},

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 KiB

View File

@ -9,7 +9,7 @@
"uuid": "humanseg-v20221001",
"label": "人体分割背景替换",
"describe": "人体分割背景替换,视频会议背景替换",
"pic": "https://github.com/juncaipeng/raw_data/blob/master/images/portrait_bg_replace_1.gif?raw=true",
"pic": "example.jpg",
"hot": "1",
"price": "0",
"dataset": {},

View File

@ -9,7 +9,7 @@
"uuid": "panoptic-v20221001",
"label": "图片识别",
"describe": "resnet50 图像识别",
"pic": "test.png",
"pic": "test.jpg",
"hot": "1",
"price": "0",
"dataset": {},

View File

@ -9,7 +9,7 @@
"uuid": "yolov3-v20221001",
"label": "目标识别",
"describe": "darknet yolov3 目标识别",
"pic": "https://user-images.githubusercontent.com/20157705/170216784-91ac86f7-d272-4940-a285-0c27d6f6cd96.jpg",
"pic": "example.jpg",
"hot": "1",
"price": "0",
"dataset": {},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>星云数据平台</title>
<title>cube计算平台</title>
<style>
.loading-star {
animation: aniStar 2s infinite ease-in-out;

View File

@ -57,6 +57,14 @@ class Server():
self.model=model
self.docker=docker
self.pre_url=self.model.name
self.has_load_model=False
if self.model.pic and 'http' not in self.model.pic:
save_path = os.path.dirname(os.path.abspath(__file__)) + '/static/example/' + self.model.name + "/" + self.model.pic.strip('/')
if not os.path.exists(save_path):
os.makedirs(os.path.dirname(save_path), exist_ok=True)
shutil.copyfile(self.model.pic, save_path)
# 启动服务
# @pysnooper.snoop()
@ -88,7 +96,7 @@ class Server():
if not os.path.exists(save_path):
os.makedirs(os.path.dirname(save_path),exist_ok=True)
shutil.copyfile(file_path, save_path)
return request.host_url.strip('/') + f"/{self.pre_url}/static/example/"+self.model.name+"/" + file_path.strip('/')
return f"/{self.pre_url}/static/example/"+self.model.name+"/" + file_path.strip('/')
# 视频转流
def video_stram(self,video_path):
@ -99,8 +107,7 @@ class Server():
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + image + b'\r\n')
# 一次性加载模型
self.model.load_model()
# 定义认为放在的队列
def api_inference(name,version,data):
@ -315,6 +322,10 @@ class Server():
# 同步推理
# 一次性加载模型
if not self.has_load_model:
self.model.load_model()
self.has_load_model=True
result = api_inference(name=self.model.name, version=self.model.version, data=data)
return jsonify(result)
@ -385,7 +396,7 @@ class Server():
"web_examples":self.web_examples,
"inference_inputs": [input.to_json() for input in self.model.inference_inputs],
'inference_url':f'/{self.pre_url}/api/model/{self.model.name}/version/{self.model.version}/',
"aihub_url":"http://www.data-master.net/frontend/aihub/model_market/model_all",
"aihub_url":"http://www.data-master.net:8880/frontend/aihub/model_market/model_all",
"github_url":"https://github.com/tencentmusic/cube-studio",
"user":f"/{self.pre_url}/login",
"rec_apps":[

View File

@ -46,9 +46,9 @@ class Aihub(Model,ImportMixin,MyappModelBase):
service_url = "/aihub/api/service/" + self.uuid if self.status == 'online' and (self.service or self.inference) else ""
return Markup(f'''
<div style="border: 3px solid rgba({'29,152,29,.9' if self.status=='online' else '0,0,0,.2'});border-radius: 3px;">
<div style="border: 3px solid rgba({'29,152,29,.6' if self.status=='online' else '0,0,0,.2'});border-radius: 3px;">
<a href="{self.doc if self.status=='online' else ''}">
<img src="{self.pic}" style="height:200px;width:100%" alt="{self.describe}"/>
<img src="{self.pic}" onerror="this.src='https://img.zcool.cn/community/0131565aeff3c5a801219b7f6906a7.gif'" style="height:200px;width:100%" alt="{self.describe}"/>
</a>
<br>
<div>

View File

@ -110,6 +110,10 @@ class Service(Model,AuditMixinNullable,MyappModelBase,service_common):
SERVICE_EXTERNAL_IP = ip
if SERVICE_EXTERNAL_IP:
# 对于多网卡或者单域名模式这里需要使用公网ip或者域名打开
if '|' in SERVICE_EXTERNAL_IP:
SERVICE_EXTERNAL_IP = SERVICE_EXTERNAL_IP.split('|')[1].strip()
host = SERVICE_EXTERNAL_IP + ":" + str(port)
return Markup(f'<a target=_blank href="http://{host}/">{host}</a>')
else:
@ -250,6 +254,10 @@ class InferenceService(Model,AuditMixinNullable,MyappModelBase,service_common):
SERVICE_EXTERNAL_IP = ip
if SERVICE_EXTERNAL_IP:
# 对于多网卡或者单域名模式这里需要使用公网ip或者域名打开
if '|' in SERVICE_EXTERNAL_IP:
SERVICE_EXTERNAL_IP = SERVICE_EXTERNAL_IP.split('|')[1].strip()
host = SERVICE_EXTERNAL_IP + ":" + str(port)
return Markup(f'<a target=_blank href="http://{host}/">{host}</a>')
else:

View File

@ -29,6 +29,8 @@ class Myauthdbview(AuthDBView):
@expose("/login/", methods=["GET", "POST"])
# @pysnooper.snoop(watch_explode=('form',))
def login(self):
request_data = request.args.to_dict()
comed_url = request_data.get('login_url', '')
if 'rtx' in request.args:
if request.args.get('rtx'):
@ -38,7 +40,6 @@ class Myauthdbview(AuthDBView):
login_user(user, remember=True)
return redirect(self.appbuilder.get_url_for_index)
if g.user is not None and g.user.is_authenticated:
return redirect(self.appbuilder.get_url_for_index)
@ -74,9 +75,8 @@ class Myauthdbview(AuthDBView):
user = self.appbuilder.sm.auth_user_remote_org_user(username=form.username.data, org_name='',
password=form.password.data)
flash('发现用户%s不存在,已自动注册' % form.username.data, "warning")
login_user(user, remember=True)
return redirect(self.appbuilder.get_url_for_index)
return redirect(comed_url if comed_url else self.appbuilder.get_url_for_index)
return self.render_template(
self.login_template, title=self.title, form=form, appbuilder=self.appbuilder
)

View File

@ -1363,12 +1363,12 @@ def update_aihub(task):
aihub.status=data.get('status', '')
aihub.uuid=uuid
aihub.version=data.get('version', '')
aihub.dataset=json.dumps(data.get('dataset', {}))
aihub.notebook=json.dumps(data.get('notebook', {}))
aihub.job_template=json.dumps(data.get('job_template', {}))
aihub.pre_train_model=json.dumps(data.get('pre_train_model', {}))
aihub.inference=json.dumps(data.get('inference', {}))
aihub.service=json.dumps(data.get('service', {}))
aihub.dataset=json.dumps(data.get('dataset', {}),indent=4,ensure_ascii=False)
aihub.notebook=json.dumps(data.get('notebook', {}),indent=4,ensure_ascii=False)
aihub.job_template=json.dumps(data.get('job_template', {}),indent=4,ensure_ascii=False)
aihub.pre_train_model=json.dumps(data.get('pre_train_model', {}),indent=4,ensure_ascii=False)
aihub.inference=json.dumps(data.get('inference', {}),indent=4,ensure_ascii=False)
aihub.service=json.dumps(data.get('service', {}),indent=4,ensure_ascii=False)
aihub.hot=int(data.get('hot', '0'))
aihub.price=int(data.get('price', '0'))
aihub.source=data.get('source', '')

View File

@ -75,7 +75,7 @@ class InferenceService_ModelView_base():
"model_name_url":{"type": "ellip2", "width": 300},
"model_version": {"type": "ellip2", "width": 200},
"inference_host_url": {"type": "ellip2", "width": 500},
"ip": {"type": "ellip2", "width": 200},
"ip": {"type": "ellip2", "width": 250},
"model_status": {"type": "ellip2", "width": 100},
"modified": {"type": "ellip2", "width": 150},
"operate_html": {"type": "ellip2", "width": 350},
@ -917,6 +917,9 @@ output %s
if SERVICE_EXTERNAL_IP:
# 对于多网卡模式或者单域名模式代理需要配置内网ip界面访问需要公网ip或域名
SERVICE_EXTERNAL_IP = [ip.split('|')[0].strip() for ip in SERVICE_EXTERNAL_IP]
service_ports = [[20000+10*service.id+index,port] for index,port in enumerate(ports)]
service_external_name = (service.name + "-external").lower()[:60].strip('-')
print('deploy proxy ip')

View File

@ -55,7 +55,7 @@ class Service_ModelView_base():
cols_width={
"name_url":{"type": "ellip2", "width": 200},
"host_url": {"type": "ellip2", "width": 400},
"ip": {"type": "ellip2", "width": 200},
"ip": {"type": "ellip2", "width": 250},
"deploy": {"type": "ellip2", "width": 200},
"modified": {"type": "ellip2", "width": 150}
}
@ -226,7 +226,11 @@ class Service_ModelView_base():
SERVICE_EXTERNAL_IP=[ip]
if SERVICE_EXTERNAL_IP:
# 对于多网卡模式或者单域名模式代理需要配置内网ip界面访问需要公网ip或域名
SERVICE_EXTERNAL_IP = [ip.split('|')[0].strip() for ip in SERVICE_EXTERNAL_IP]
service_ports = [[30000+10*service.id+index,port] for index,port in enumerate(ports)]
service_external_name = (service.name + "-external").lower()[:60].strip('-')
k8s_client.create_service(