提交 2e03def0 编写于 作者: D dongdaxiang

refine package shoiw list

上级 c4d9418c
...@@ -20,76 +20,43 @@ from collections import OrderedDict ...@@ -20,76 +20,43 @@ from collections import OrderedDict
class ServingModels(object): class ServingModels(object):
def __init__(self): def __init__(self):
self.model_dict = OrderedDict() self.model_dict = OrderedDict()
#senta
for key in [
"senta_bilstm", "senta_bow", "senta_cnn", "senta_gru",
"senta_lstm"
]:
self.model_dict[ self.model_dict[
key] = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SentimentAnalysis/" + key + ".tar.gz" "SentimentAnalysis"] = ["senta_bilstm", "senta_bow", "senta_cnn"]
#image classification self.model_dict["SemanticRepresentation"] = ["ernie_base"]
for key in [ self.model_dict["ChineseWordSegmentation"] = ["lac"]
"alexnet_imagenet", self.model_dict["ObjectDetection"] = ["faster_rcnn", "yolov3"]
"darknet53-imagenet", self.model_dict["ImageSegmentation"] = ["unet", "deeplabv3"]
"densenet121_imagenet", self.model_dict["ImageClassification"] = [
"densenet161_imagenet", "resnet_v2_50_imagenet", "efficientnetb6_imagenet"
"densenet169_imagenet", ]
"densenet201_imagenet",
"densenet264_imagenet" image_class_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/ImageClassification/"
"dpn107_imagenet", image_seg_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/ImageSegmentation/"
"dpn131_imagenet", object_detection_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/ObjectDetection/"
"dpn68_imagenet", senta_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SentimentAnalysis/"
"dpn92_imagenet", semantic_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SemanticRepresentation/"
"dpn98_imagenet", wordseg_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/ChineseWordSegmentation/"
"efficientnetb0_imagenet",
"efficientnetb1_imagenet", self.url_dict = {}
"efficientnetb2_imagenet",
"efficientnetb3_imagenet", def pack_url(model_dict, key, url):
"efficientnetb4_imagenet", for i, value in enumerate(model_dict[key]):
"efficientnetb5_imagenet", self.url_dict[model_dict[key][i]] = url + model_dict[key][
"efficientnetb6_imagenet", i] + ".tar.gz"
"googlenet_imagenet",
"inception_v4_imagenet", pack_url(self.model_dict, "SentimentAnalysis", senta_url)
"inception_v2_imagenet", pack_url(self.model_dict, "SemanticRepresentation", semantic_url)
"nasnet_imagenet", pack_url(self.model_dict, "ChineseWordSegmentation", wordseg_url)
"pnasnet_imagenet", pack_url(self.model_dict, "ObjectDetection", object_detection_url)
"resnet_v2_101_imagenet", pack_url(self.model_dict, "ImageSegmentation", image_seg_url)
"resnet_v2_151_imagenet", pack_url(self.model_dict, "ImageClassification", image_class_url)
"resnet_v2_18_imagenet",
"resnet_v2_34_imagenet",
"resnet_v2_50_imagenet",
"resnext101_32x16d_wsl",
"resnext101_32x32d_wsl",
"resnext101_32x48d_wsl",
"resnext101_32x8d_wsl",
"resnext101_32x4d_imagenet",
"resnext101_64x4d_imagenet",
"resnext101_vd_32x4d_imagenet",
"resnext101_vd_64x4d_imagenet",
"resnext152_64x4d_imagenet",
"resnext152_vd_64x4d_imagenet",
"resnext50_64x4d_imagenet",
"resnext50_vd_32x4d_imagenet",
"resnext50_vd_64x4d_imagenet",
"se_resnext101_32x4d_imagenet",
"se_resnext50_32x4d_imagenet",
"shufflenet_v2_imagenet",
"vgg11_imagenet",
"vgg13_imagenet",
"vgg16_imagenet",
"vgg19_imagenet",
"xception65_imagenet",
"xception71_imagenet",
]:
self.model_dict[
key] = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/ImageClassification/" + key + ".tar.gz"
def get_model_list(self): def get_model_list(self):
return (self.model_dict.keys()) return self.model_dict
def download(self, model_name): def download(self, model_name):
if model_name in self.model_dict: if model_name in self.url_dict:
url = self.model_dict[model_name] url = self.url_dict[model_name]
r = os.system('wget ' + url + ' --no-check-certificate') r = os.system('wget ' + url + ' --no-check-certificate')
......
...@@ -20,6 +20,7 @@ Usage: ...@@ -20,6 +20,7 @@ Usage:
""" """
import argparse import argparse
import sys
from .models import ServingModels from .models import ServingModels
...@@ -36,13 +37,18 @@ if __name__ == "__main__": ...@@ -36,13 +37,18 @@ if __name__ == "__main__":
args = parse_args() args = parse_args()
if args.list_model != None: if args.list_model != None:
model_handle = ServingModels() model_handle = ServingModels()
model_names = model_handle.get_model_list() model_dict = model_handle.get_model_list()
for key in model_names: # Task level model list
print(key) # Text Classification, Semantic Representation
# Image Classification, Object Detection, Image Segmentation
for key in model_dict:
print("-----------------------------------------------")
print("{}: {}".format(key, " | ".join(model_dict[key])))
elif args.get_model != "": elif args.get_model != "":
model_handle = ServingModels() model_handle = ServingModels()
model_names = model_handle.get_model_list() model_dict = model_handle.url_dict
if args.get_model not in model_names: if args.get_model not in model_dict:
print( print(
"Your model name does not exist in current model list, stay tuned" "Your model name does not exist in current model list, stay tuned"
) )
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册