back
ResNet
You can perform transfer learning of PyTorch's ResNet using your own dataset.
BaseURL
https://ml.api.utagoe.com/resnet
Dataset structure
Pack dataset in following directory structure.
(dataset_name)
│
├── property.json
└── data
│
├── (class_0)
│ ├── aaaa.jpg
│ ├── bbbb.jpg
│ └── ...
│
└── (class_1)
├── cccc.jpg
├── dddd.jpg
└── ...
property.json
You should prepare property.json, that have information of class label.
Example:
{
"class_num":3,
"classes":["dog", "cat", "hawk"],
"layers_num":18
}
- class_num: number of classes.
- classes: list of class label.
- layers_num: number of ResNet layers: either 18, 34, 50, 101, or 152.
Train ResNet
URL
POST /train
Header
| Key |
Value |
| Content-Type |
application/json |
Parameters
| Name |
Type |
Required |
In |
Description |
| access_key |
Text |
Yes |
Body |
|
| model_name |
Text |
Yes |
Body |
Name to identify the model |
| dataset |
Text |
Yes |
Body |
Dataset ID |
| lr |
Text |
|
Body |
Learning rate (0.001 as default) |
| batch_size |
Text |
|
Body |
Batch size (32 as default) |
| final_epoch |
Text |
|
Body |
Total epoch (500 as default) |
Code sample
Shell
curl https://ml.api.utagoe.com/resnet/train -H "Content-Type: application/json" --data-binary '{"access_key":"ExampleAccessKey1234", "model_name": "yourmodel", "dataset": "yourdata"}'
Response
Status: 200 OK
{
"url": "https://ml.api.utagoe.com/resnet/progress?model_name=yourmodel"
}
Stop the training process
URL
POST /stop
Header
| Key |
Value |
| Content-Type |
application/json |
Parameters
| Name |
Type |
Required |
In |
Description |
| access_key |
Text |
Yes |
Body |
|
| model_name |
Text |
Yes |
Body |
Name to identify the model |
Code sample
Shell
curl https://ml.api.utagoe.com/resnet/stop -H "Content-Type: application/json" --data-binary '{"access_key":"ExampleAccessKey1234", "model_name": "yourmodel"}'
Response
Status: 200 OK
{}
Restart the training process
URL
POST /restart
Header
| Key |
Value |
| Content-Type |
application/json |
Parameters
| Name |
Type |
Required |
In |
Description |
| access_key |
Text |
Yes |
Body |
|
| model_name |
Text |
Yes |
Body |
Name to identify the model |
Code sample
Shell
curl https://ml.api.utagoe.com/resnet/restart -H "Content-Type: application/json" --data-binary '{"access_key":"ExampleAccessKey1234", "model_name": "yourmodel"}'
Response
Status: 200 OK
{
"url": "https://ml.api.utagoe.com/resnet/progress?model_name=yourmodel"
}
Get a progress of the training
URL
GET /progress
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
| model_name |
Text |
Yes |
Query |
Name to identify the model |
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/progress?model_name=yourmodel" -H "Access-Key: ExampleAccessKey1234"
Response
Status: 200 OK
{
"model_name": "yourmodel",
"dataset": "yourdata",
"final_epoch": "500",
"current_epoch": "121",
"train_loss": "0.1026878623236524",
"val_loss": "0.22111114621162414",
"accuracy": "0.91375",
"running": true
}
Make a prediction using trained model
URL
POST /predict
Header
| Key |
Value |
| Content-Type |
application/json |
Parameters
| Name |
Type |
Required |
In |
Description |
| access_key |
Text |
Yes |
Body |
|
| model_name |
Text |
Yes |
Body |
Name to identify the model |
| dataset_id |
Text |
Yes |
Body |
Dataset ID |
Code sample
Shell
curl https://ml.api.utagoe.com/resnet/predict -H "Content-Type: application/json" --data-binary '{"access_key":"ExampleAccessKey1234", "model_name": "yourmodel", "dataset": "yourdata"}'
Response
Status: 200 OK
{
"url": "https://ml.api.utagoe.com/resnet/output?key=20210615120845",
"key": "20210615120845"
}
Get an output of the prediction
URL
GET /output
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
| key |
Text |
Yes |
Query |
Specific key string |
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/output?key=20210615120845" -H "Access-Key: ExampleAccessKey1234"
Response
Status: 200 OK
{
"progress": 37.5625,
"results": [
{
"filename": "cat.1004.jpg",
"class": "dog"
},
{
"filename": "cat.1005.jpg",
"class": "cat"
}
]
}
URL
GET /result
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
| key |
Text |
Yes |
Query |
Specific key string |
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/result?key=20210615120845" -H "Access-Key: ExampleAccessKey1234" --output 20210615120845.zip
Response
Status: 200 OK
Get a list of trained model
URL
GET /list
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
|
|
|
|
|
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/list" -H "Access-Key: ExampleAccessKey1234"
Response
Status: 200 OK
{
"model_list": [
{
"model_name": "yourmodel",
"dataset_id": "yourdata"
}
]
}
Delete the model
URL
POST /delete
Header
| Key |
Value |
| Content-Type |
application/json |
Parameters
| Name |
Type |
Required |
In |
Description |
| access_key |
Text |
Yes |
Body |
|
| model_name |
Text |
Yes |
Body |
Name to identify the model |
Code sample
Shell
curl https://ml.api.utagoe.com/resnet/delete -H "Content-Type: application/json" --data-binary '{"access_key":"ExampleAccessKey1234", "model_name": "yourmodel"}'
Response
Status: 200 OK
{}
Check if specific dataset is available
URL
GET /validate
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
| dataset |
Text |
Yes |
Query |
Dataset ID |
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/validate?dataset=yourdata" -H "Access-Key: ExampleAccessKey1234"
Response
Status: 200 OK
{
"valid": true,
"message": ""
}
Download the model
URL
GET /download
Header
| Key |
Value |
| Access-Key |
YourAccessKey |
Parameters
| Name |
Type |
Required |
In |
Description |
| model_name |
Text |
Yes |
Query |
Name to identify the model |
Code sample
Shell
curl "https://ml.api.utagoe.com/resnet/download?model_name=yourmodel" -H "Access-Key: ExampleAccessKey1234" --output yourmodel.zip
Response
Status: 200 OK