更新一些配置与配置相关的代码
This commit is contained in:
46
README.md
Normal file
46
README.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
文件解释
|
||||||
|
-----------
|
||||||
|
|
||||||
|
样例包括:
|
||||||
|
|
||||||
|
* README.md - 本文件
|
||||||
|
* Dockerfile - 用以自动构建 Docker 镜像的脚本
|
||||||
|
* requirements.txt - 依赖包文件
|
||||||
|
* main.py - 主 Flask 服务器端源代码
|
||||||
|
* python-version : 3.9
|
||||||
|
|
||||||
|
快速开始
|
||||||
|
---------------
|
||||||
|
|
||||||
|
如下这些引导,假定你想在自己的电脑上开发本项目。
|
||||||
|
|
||||||
|
1. 安装依赖
|
||||||
|
|
||||||
|
$ conda create -n trinity_client_mixi python=3.9
|
||||||
|
$ conda create -n trinity_client_mixi -y
|
||||||
|
$ conda activate trinity_client_mixi
|
||||||
|
$ pip install -r requirements.txt
|
||||||
|
$ conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
|
||||||
|
$ pip install mmcv==1.4.2 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html
|
||||||
|
|
||||||
|
|
||||||
|
2. 启动服务器
|
||||||
|
|
||||||
|
$ uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||||
|
|
||||||
|
3. 打开 http://127.0.0.1:8000/docs
|
||||||
|
|
||||||
|
Docker 部署
|
||||||
|
---------------
|
||||||
|
1. 构建镜像
|
||||||
|
|
||||||
|
$ cd {workspace}
|
||||||
|
$ docker build -t trinity_client_mixi
|
||||||
|
|
||||||
|
2. 使用docker-compose 启动
|
||||||
|
|
||||||
|
$ docker-compose up -d
|
||||||
|
|
||||||
|
3. 查看日志
|
||||||
|
|
||||||
|
$ docker-compose logs -f
|
||||||
@@ -29,3 +29,16 @@ MINIO_SECRET = "uHfqJ7UkwA1PTDGfnA44Hp9ux5YkZTkzZLjeOYhE"
|
|||||||
|
|
||||||
OM_TRITON_IP = "10.1.1.150"
|
OM_TRITON_IP = "10.1.1.150"
|
||||||
OM_TRITON_PORT = "7000"
|
OM_TRITON_PORT = "7000"
|
||||||
|
|
||||||
|
ATT_TRITON_IP = "10.1.1.150"
|
||||||
|
ATT_TRITON_PORT = "6000"
|
||||||
|
|
||||||
|
# service env
|
||||||
|
# LOGSPATH = "logs/errors.log"
|
||||||
|
# FASHION_CATEGORIES = "app/service/outfit_matcher/config/fashion_categories.json"
|
||||||
|
# FASHION_CATEGORIES_MAPPING = "app/service/outfit_matcher/config/fashion_category_mapping.json"
|
||||||
|
|
||||||
|
# pycharm debug
|
||||||
|
LOGSPATH = "logs/errors.log"
|
||||||
|
FASHION_CATEGORIES = "service/outfit_matcher/config/fashion_categories.json"
|
||||||
|
FASHION_CATEGORIES_MAPPING = "service/outfit_matcher/config/fashion_category_mapping.json"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from torchvision import transforms
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from minio import Minio
|
from minio import Minio
|
||||||
|
|
||||||
from app.core.config import MINIO_IP, MINIO_PORT, MINIO_SECURE, MINIO_ACCESS, MINIO_SECRET
|
from app.core.config import MINIO_IP, MINIO_PORT, MINIO_SECURE, MINIO_ACCESS, MINIO_SECRET, ATT_TRITON_IP, ATT_TRITON_PORT
|
||||||
|
|
||||||
|
|
||||||
def Merge(dict1, dict2):
|
def Merge(dict1, dict2):
|
||||||
@@ -54,7 +54,7 @@ class Rescale(object):
|
|||||||
|
|
||||||
class AttributeRecognition:
|
class AttributeRecognition:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.httpclient = httpclient.InferenceServerClient(url="10.1.1.150:6000")
|
self.httpclient = httpclient.InferenceServerClient(url=f"{ATT_TRITON_IP}:{ATT_TRITON_PORT}")
|
||||||
self.minio_client = Minio(
|
self.minio_client = Minio(
|
||||||
f"{MINIO_IP}:{MINIO_PORT}",
|
f"{MINIO_IP}:{MINIO_PORT}",
|
||||||
access_key=MINIO_ACCESS,
|
access_key=MINIO_ACCESS,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import itertools
|
|||||||
import difflib
|
import difflib
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
from app.core.config import FASHION_CATEGORIES, FASHION_CATEGORIES_MAPPING
|
||||||
|
|
||||||
|
|
||||||
# Helper function to calculate the edit distance similarity between two file names
|
# Helper function to calculate the edit distance similarity between two file names
|
||||||
def sim_score(a, b):
|
def sim_score(a, b):
|
||||||
@@ -11,12 +13,8 @@ def sim_score(a, b):
|
|||||||
|
|
||||||
|
|
||||||
class FashionDataset(object):
|
class FashionDataset(object):
|
||||||
fashion_categories = json.load(open(r"app/service/outfit_matcher/config/fashion_categories.json", "r"))
|
fashion_categories = json.load(open(FASHION_CATEGORIES, "r"))
|
||||||
fashion_categories_mapping = json.load(open(r"app/service/outfit_matcher/config/fashion_category_mapping.json", "r"))
|
fashion_categories_mapping = json.load(open(FASHION_CATEGORIES_MAPPING, "r"))
|
||||||
|
|
||||||
# service debug
|
|
||||||
# fashion_categories = json.load(open(r"service/outfit_matcher/config/fashion_categories.json", "r"))
|
|
||||||
# fashion_categories_mapping = json.load(open(r"service/outfit_matcher/config/fashion_category_mapping.json", "r"))
|
|
||||||
|
|
||||||
def __init__(self, item_metadata):
|
def __init__(self, item_metadata):
|
||||||
self.item_metadat = item_metadata
|
self.item_metadat = item_metadata
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from app.service.utils.decorator import RunTime
|
|||||||
|
|
||||||
class OutfitMatcher(object):
|
class OutfitMatcher(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tritonclient = httpclient.InferenceServerClient(url="10.1.1.240:10010")
|
self.tritonclient = httpclient.InferenceServerClient(url=f"{OM_TRITON_IP}:{OM_TRITON_PORT}")
|
||||||
self.minio_client = Minio(
|
self.minio_client = Minio(
|
||||||
f"{MINIO_IP}:{MINIO_PORT}",
|
f"{MINIO_IP}:{MINIO_PORT}",
|
||||||
access_key=MINIO_ACCESS,
|
access_key=MINIO_ACCESS,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from app.core.config import LOGSPATH
|
||||||
|
|
||||||
LOGGER_CONFIG_DICT = {
|
LOGGER_CONFIG_DICT = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"disable_existing_loggers": False,
|
"disable_existing_loggers": False,
|
||||||
@@ -15,7 +17,7 @@ LOGGER_CONFIG_DICT = {
|
|||||||
"class": "logging.handlers.RotatingFileHandler",
|
"class": "logging.handlers.RotatingFileHandler",
|
||||||
"level": "INFO",
|
"level": "INFO",
|
||||||
"formatter": "simple",
|
"formatter": "simple",
|
||||||
"filename": "app/logs/info.log",
|
"filename": LOGSPATH,
|
||||||
"maxBytes": 10485760,
|
"maxBytes": 10485760,
|
||||||
"backupCount": 50,
|
"backupCount": 50,
|
||||||
"encoding": "utf8",
|
"encoding": "utf8",
|
||||||
@@ -24,7 +26,7 @@ LOGGER_CONFIG_DICT = {
|
|||||||
"class": "logging.handlers.RotatingFileHandler",
|
"class": "logging.handlers.RotatingFileHandler",
|
||||||
"level": "ERROR",
|
"level": "ERROR",
|
||||||
"formatter": "simple",
|
"formatter": "simple",
|
||||||
"filename": "app/logs/errors.log",
|
"filename": LOGSPATH,
|
||||||
"maxBytes": 10485760,
|
"maxBytes": 10485760,
|
||||||
"backupCount": 20,
|
"backupCount": 20,
|
||||||
"encoding": "utf8",
|
"encoding": "utf8",
|
||||||
@@ -33,7 +35,7 @@ LOGGER_CONFIG_DICT = {
|
|||||||
"class": "logging.handlers.RotatingFileHandler",
|
"class": "logging.handlers.RotatingFileHandler",
|
||||||
"level": "DEBUG",
|
"level": "DEBUG",
|
||||||
"formatter": "simple",
|
"formatter": "simple",
|
||||||
"filename": "app/logs/debug.log",
|
"filename": LOGSPATH,
|
||||||
"maxBytes": 10485760,
|
"maxBytes": 10485760,
|
||||||
"backupCount": 50,
|
"backupCount": 50,
|
||||||
"encoding": "utf8",
|
"encoding": "utf8",
|
||||||
|
|||||||
Reference in New Issue
Block a user