patch 執行訓練
This commit is contained in:
15
README.md
15
README.md
@@ -4,6 +4,7 @@ ai 繪圖服務端(快速重構)
|
||||
|
||||
|
||||
列表接口:
|
||||
|
||||
- [ ] /api/tags [#標籤詳情](#標籤列表)
|
||||
- [ ] /api/users [#用戶詳情](#用戶列表)
|
||||
- [ ] /api/tasks [#任務詳情](#任務列表)
|
||||
@@ -16,6 +17,7 @@ ai 繪圖服務端(快速重構)
|
||||
- [ ] /api/params [#參數列表](#參數列表)
|
||||
|
||||
列表接口-請求方式
|
||||
|
||||
Method | URL | Info
|
||||
-------|--------------------------------|------------------
|
||||
GET | /api/{name} | 分頁:顺序查询
|
||||
@@ -29,6 +31,7 @@ POST | /api/{name} | 篩選:創建新對象
|
||||
* 過濾條件有多個的,複寫query(交集)
|
||||
|
||||
詳情接口:
|
||||
|
||||
- [ ] /api/tags/{tag_id} [#標籤詳情](#標籤詳情)
|
||||
- [ ] /api/users/{user_id} [#用戶詳情](#用戶詳情)
|
||||
- [ ] /api/tasks/{task_id} [#任務詳情](#任務詳情)
|
||||
@@ -37,6 +40,7 @@ POST | /api/{name} | 篩選:創建新對象
|
||||
- [ ] /api/params/{params_id} [#參數詳情](#參數詳情)
|
||||
|
||||
詳情接口-請求方式:
|
||||
|
||||
Method | URL | Info
|
||||
-------|--------------------------------|------------------
|
||||
GET | /api/{name}/{item_id} | 獲取對象詳情
|
||||
@@ -65,7 +69,7 @@ type Model struct {
|
||||
TriggerWords string `json:"trigger_words"` // 觸發詞
|
||||
BaseModel string `json:"base_model"` // (SD1.5|SD2)
|
||||
ModelPath string `json:"model_path"` // 模型路徑
|
||||
Status string `json:"status"` // (waiting|running|success|error)
|
||||
Status string `json:"status"` // (initial|ready|waiting|running|success|error)
|
||||
Progress int `json:"progress"` // (0-100)
|
||||
Image string `json:"image"` // 封面圖片實際地址
|
||||
Tags string `json:"tags"`
|
||||
@@ -78,7 +82,7 @@ type Task struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // 任務類型(訓練|推理)
|
||||
Status string `json:"status"` // 任務狀態(waiting|running|success|error)
|
||||
Status string `json:"status"` // 任務狀態(initial|ready|waiting|running|success|error)
|
||||
Progress int `json:"progress"` // 任務進度(0-100)
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
@@ -264,7 +268,6 @@ POST | /api/models | 創建一個模型
|
||||
* 如果未登錄, 返回的結果將過濾掉無權限查看的內容
|
||||
* 如果已登錄, 返回的結果將包含私有的
|
||||
|
||||
|
||||
POST /api/models
|
||||
```javascript
|
||||
// 發送數據
|
||||
@@ -306,9 +309,15 @@ PATCH /api/models/{model_id}
|
||||
```javascript
|
||||
{
|
||||
name: 'xxx', // 修改模型名稱
|
||||
status: 'ready', // (initial|ready|waiting|running|success|error)
|
||||
}
|
||||
```
|
||||
* 修改指定字段, 只傳遞需要修改的字段
|
||||
* status 初始默認爲 'initial', 修改爲 'ready' 即就緒狀態, 服務器將爲此任務自動排期
|
||||
* 當模型訓練任務被加入等待隊列時, 其狀態自動變更爲 'waiting'
|
||||
* 當模型訓練任務被執行時, 其狀態自動變更爲 'running', 並開始更新進度條 Progress
|
||||
* 當模型訓練完成時狀態自動變更爲'success', 失敗時爲'error'
|
||||
* 訓練中的模型將被鎖定, 無法修改刪除等操作
|
||||
|
||||
DELETE /api/models/{model_id}
|
||||
* 刪除指定模型
|
||||
|
1
go.mod
1
go.mod
@@ -8,4 +8,5 @@ require (
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
github.com/russross/blackfriday v1.6.0
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@@ -8,3 +8,5 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
|
||||
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
|
||||
|
14
main.go
14
main.go
@@ -1,16 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"main/routers"
|
||||
"main/utils"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/russross/blackfriday"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -35,8 +36,15 @@ func main() {
|
||||
|
||||
// 設定路由
|
||||
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
t, _ := template.ParseFiles("templates/index.html")
|
||||
t.Execute(w, nil)
|
||||
// 從本地讀取Markdown文件
|
||||
input, err := ioutil.ReadFile("./README.md")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
//output := blackfriday.MarkdownBasic(input)
|
||||
output := blackfriday.Markdown(input, blackfriday.HtmlRenderer(0, "", ""), blackfriday.EXTENSION_TABLES|blackfriday.EXTENSION_FENCED_CODE|blackfriday.EXTENSION_AUTOLINK)
|
||||
w.Write(output)
|
||||
})
|
||||
r.HandleFunc("/api/models", routers.ModelsGet).Methods("GET")
|
||||
r.HandleFunc("/api/models", routers.ModelsPost).Methods("POST")
|
||||
|
@@ -12,7 +12,7 @@ type Model struct {
|
||||
TriggerWords string `json:"trigger_words"` // 觸發詞
|
||||
BaseModel string `json:"base_model"` // (SD1.5|SD2)
|
||||
ModelPath string `json:"model_path"` // 模型路徑
|
||||
Status string `json:"status"` // (waiting|running|success|error)
|
||||
Status string `json:"status"` // (initial|ready|waiting|running|success|error)
|
||||
Progress int `json:"progress"` // (0-100)
|
||||
Image string `json:"image"` // 封面圖片實際地址
|
||||
Tags string `json:"tags"`
|
||||
|
@@ -9,7 +9,7 @@ type Task struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // 任務類型(訓練|推理)
|
||||
Status string `json:"status"` // (waiting|running|success|error)
|
||||
Status string `json:"status"` // (initial|ready|waiting|running|success|error)
|
||||
Progress int `json:"progress"` // (0-100)
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
|
@@ -1,26 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Home</h1>
|
||||
<p>Hi, {{ .Name }}!</p>
|
||||
<!-- 列出所有API路徑 -->
|
||||
<ul>
|
||||
<li><a href="/api/models">/api/models</a></li>
|
||||
<li><a href="/api/images">/api/images</a></li>
|
||||
<li><a href="/api/users">/api/users</a></li>
|
||||
<li><a href="/api/tasks">/api/tasks</a></li>
|
||||
<li><a href="/api/tags">/api/tags</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="/api/models/1">/api/models/1</a></li>
|
||||
<li><a href="/api/images/1">/api/images/1</a></li>
|
||||
<li><a href="/api/users/1">/api/users/1</a></li>
|
||||
<li><a href="/api/tasks/1">/api/tasks/1</a></li>
|
||||
<li><a href="/api/tags/1">/api/tags/1</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user