請根據以下內容創建 flask API var spec ={ "swagger": "2.0", "info": { "version": "1.0.0", "title":…
- User
請根據以下內容創建 flask API var spec ={ "swagger": "2.0", "info": { "version": "1.0.0", "title": "Training Platform" }, "paths": { "/dataset": { "post": { "tags": [ "dataset" ], "summary": "Create a dataset.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "dataset_name", "in": "formData", "description": "The name of dataset, only English alphabets (e.x. A, a, B, b, ...) or numbers (e.x. 1, 2, 3 ...).", "required": true, "type": "string" }, { "name": "train_gt", "in": "formData", "description": "Ground truth for training.", "required": true, "type": "file" }, { "name": "validation_gt", "in": "formData", "description": "Ground truth for validating.", "required": false, "type": "file" }, { "name": "type", "in": "formData", "description": "Select the detection type of the model (e.g Object_Detection, Attribute_Classification)", "required": true, "type": "string" } ], "responses": { "405": { "description": "Invalid input" } } }, "get": { "tags": [ "dataset" ], "summary": "Get dataset list.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "responses": { "405": { "description": "Invalid input" } } } }, "/dataset/{dataset_name}": { "delete":{ "tags":[ "dataset" ], "summary": "Delete a dataset.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "dataset_name", "in": "path", "description": "", "required": true, "type": "string" } ], "responses": { "200": { "description": "successful operation." } } } }, "/template": { "get": { "tags": [ "template" ], "summary": "Get template list.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "responses": { "200": { "description": "successful operation", "schema": { "ref": "#/definitions/Templates" } }, "405": { "description": "Invalid input" } } } }, "/train-project":{ "post": { "tags": [ "train-project" ], "summary": "Control a training project.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "formData", "description": "from POST /train.", "required": true, "type": "string" }, { "name": "order", "in": "formData", "description": "Only 'pause' and 'resume' commands are allowed.", "required": true, "type": "string" }, { "name": "gpu_id", "in": "formData", "description": "The ID of a GPU selected to resume a model training. (only for resume)", "required": false, "type": "string" }, { "name": "lr", "in": "formData", "description": "The base learning rate for model training. (only for resume)", "required": false, "type": "string" } ], "responses": { "200":{ "description": "successfula operation" } } } }, "/train-project/{training_id}": { "get": { "tags": [ "train-project" ], "summary": "Get a training task status.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "path", "description": "from POST /train.", "required": true, "type": "string", "maximum": 10, "minimum": 1 } ], "responses": { "200":{ "description": "status may contain 「train、pause、finished」", "schema": { "type": "string"} } } }, "delete": { "tags": [ "train-project" ], "summary": "Delete a training task.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "path", "description": "from POST /train.", "required": true, "type": "string" } ], "responses": { "200":{ "description": "successfula operation" } } } }, "/train": { "get": { "tags": [ "train" ], "summary": "Get training project list.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "responses": { "200":{ "description": "successfula operation", "schema": { "ref": "#/definitions/Train_projects"} } } }, "post": { "tags": [ "train" ], "summary": "Start a training task.", "description": "", "operationId": "addPet", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "formData", "description": "The name of work/project, only English alphabets (e.x. A, a, B, b, ...) or numbers (e.x. 1, 2, 3 ...).", "required": true, "type": "string" }, { "name": "class_num", "in": "formData", "description": "The number of classes or labels that a model will predict.", "required": true, "type": "string" }, { "name": "dataset", "in": "formData", "description": "A json file descripts train gt(s), test gt(s), and a names file.", "required": true, "type": "string" }, { "name": "template", "in": "formData", "description": "The name of the model template a user wishes to train.", "required": true, "type": "string" }, { "name": "gpu_id", "in": "formData", "description": "The ID of a GPU selected to train a model.", "required": true, "type": "string" } ], "responses": { "405": { "description": "Invalid input" } } } }, "/evaluate/{training_id}": { "get": { "tags": [ "evaluate" ], "summary": "Get evaluation results.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "path", "description": "from POST /train.", "required": true, "type": "string" } ], "responses": { "405": { "description": "Invalid input" } } }, }, "/evaluate": { "post": { "tags": [ "evaluate" ], "summary": "Evaluate the ODC model by training ID.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "formData", "description": "from POST /train.", "required": true, "type": "string" } ], "responses": { "200": { "description": "successful operation", "schema": { "ref": "#/definitions/Train_projects"} } } }, "post": { "tags": [ "annotation-model" ], "summary": "Upload an ODC model.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "model_id", "in": "formData", "description": "The name of work/project, only English alphabets (e.x. A, a, B, b, ...) or numbers (e.x. 1, 2, 3 ...).", "required": true, "type": "string" }, { "name": "model_data", "in": "formData", "description": "Compress ODC models into a zip file.", "required": true, "type": "file" }, { "name": "mapping_file", "in": "formData", "description": "The file describes the relationship of each model.", "required": true, "type": "file" } ], "responses": { "200": { "description": "successful operation", "schema": { "ref": "#/definitions/Train_projects"} } } } }, "/annotate": { "post": { "tags": [ "annotate" ], "summary": "Automatically annotate objects from images.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "model_id", "in": "formData", "description": "from POST /annotation-model.", "required": true, "type": "string" }, { "name": "image", "in": "formData", "description": "The image file.", "required": true, "type": "file" } ], "responses": { "200": { "description": "successful operation", "schema": { "$ref": "#/definitions/Inference_result" } }, "405": { "description": "Invalid input" } } } }, "/model-wrapper": { "post": { "tags": [ "model-wrapper" ], "summary": "Converting models and wrapping.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "formData", "description": "from POST /train.", "required": true, "type": "string" } ], "responses": { "405": { "description": "Invalid input" } } }, }, "/model-wrapper/{training_id}": { "get": { "tags": [ "model-wrapper" ], "summary": "Download a model from training service.", "description": "", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "parameters": [ { "name": "training_id", "in": "path", "description": "from POST /train.", "required": true, "type": "string" } ], "responses": { "405": { "description": "Invalid input" } } }, } }, "definitions": { "Templates": { "type": "object", "properties": { "Templates": { "type": "array", "items": { "type": "string" } } } }, "Train_projects": { "type": "object", "properties": { "Train_projects": { "type": "array", "items": { "type": "string" } } } }, "Inference_result": { "type": "object", "properties": { "object": { "type": "array", "items": { "type": "object", "properties": { "x1": { "type": "integer" }, "y1": { "type": "integer" }, "x2": { "type": "integer" }, "y2": { "type": "integer" }, "id": { "type": "integer" }, "confidence_score": { "type": "number" } } } }, "path": { "type":"string" }, "width": { "type": "integer" }, "height": { "type": "integer" } } } } }
- Assistant