From 522ca4f3d31f7e694b38e3079deafb7cb01f6532 Mon Sep 17 00:00:00 2001 From: Jason Stone Date: Fri, 26 Jul 2024 14:47:44 +0300 Subject: [PATCH] checking if it works in my system --- runner/openapi.json | 31 +----- worker/runner.gen.go | 230 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 209 insertions(+), 52 deletions(-) diff --git a/runner/openapi.json b/runner/openapi.json index c103d2f6..2e2bb4e7 100644 --- a/runner/openapi.json +++ b/runner/openapi.json @@ -520,38 +520,17 @@ "title": "Model Id" }, "image1": { - "anyOf": [ - { - "type": "string", - "format": "binary" - }, - { - "type": "null" - } - ], + "type": "string", + "format": "binary", "title": "Image1" }, "image2": { - "anyOf": [ - { - "type": "string", - "format": "binary" - }, - { - "type": "null" - } - ], + "type": "string", + "format": "binary", "title": "Image2" }, "image_dir": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], + "type": "string", "title": "Image Dir", "default": "" }, diff --git a/worker/runner.gen.go b/worker/runner.gen.go index 0dbe8036..788a7e82 100644 --- a/worker/runner.gen.go +++ b/worker/runner.gen.go @@ -37,6 +37,15 @@ type BodyAudioToTextAudioToTextPost struct { ModelId *string `json:"model_id,omitempty"` } +// BodyFrameInterpolationFrameInterpolationPost defines model for Body_frame_interpolation_frame_interpolation_post. +type BodyFrameInterpolationFrameInterpolationPost struct { + Image1 *openapi_types.File `json:"image1,omitempty"` + Image2 *openapi_types.File `json:"image2,omitempty"` + ImageDir *string `json:"image_dir,omitempty"` + InterFrames *int `json:"inter_frames,omitempty"` + ModelId string `json:"model_id"` +} + // BodyImageToImageImageToImagePost defines model for Body_image_to_image_image_to_image_post. type BodyImageToImageImageToImagePost struct { GuidanceScale *float32 `json:"guidance_scale,omitempty"` @@ -155,6 +164,9 @@ type Chunk struct { // AudioToTextMultipartRequestBody defines body for AudioToText for multipart/form-data ContentType. type AudioToTextMultipartRequestBody = BodyAudioToTextAudioToTextPost +// FrameInterpolationMultipartRequestBody defines body for FrameInterpolation for multipart/form-data ContentType. +type FrameInterpolationMultipartRequestBody = BodyFrameInterpolationFrameInterpolationPost + // ImageToImageMultipartRequestBody defines body for ImageToImage for multipart/form-data ContentType. type ImageToImageMultipartRequestBody = BodyImageToImageImageToImagePost @@ -305,6 +317,9 @@ type ClientInterface interface { // AudioToTextWithBody request with any body AudioToTextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // FrameInterpolationWithBody request with any body + FrameInterpolationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // Health request Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -335,6 +350,18 @@ func (c *Client) AudioToTextWithBody(ctx context.Context, contentType string, bo return c.Client.Do(req) } +func (c *Client) FrameInterpolationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFrameInterpolationRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewHealthRequest(c.Server) if err != nil { @@ -436,6 +463,35 @@ func NewAudioToTextRequestWithBody(server string, contentType string, body io.Re return req, nil } +// NewFrameInterpolationRequestWithBody generates requests for FrameInterpolation with any type of body +func NewFrameInterpolationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/frame_interpolation") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewHealthRequest generates requests for Health func NewHealthRequest(server string) (*http.Request, error) { var err error @@ -636,6 +692,9 @@ type ClientWithResponsesInterface interface { // AudioToTextWithBodyWithResponse request with any body AudioToTextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AudioToTextResponse, error) + // FrameInterpolationWithBodyWithResponse request with any body + FrameInterpolationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FrameInterpolationResponse, error) + // HealthWithResponse request HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error) @@ -681,6 +740,32 @@ func (r AudioToTextResponse) StatusCode() int { return 0 } +type FrameInterpolationResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ImageResponse + JSON400 *HTTPError + JSON401 *HTTPError + JSON422 *HTTPValidationError + JSON500 *HTTPError +} + +// Status returns HTTPResponse.Status +func (r FrameInterpolationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FrameInterpolationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type HealthResponse struct { Body []byte HTTPResponse *http.Response @@ -816,6 +901,15 @@ func (c *ClientWithResponses) AudioToTextWithBodyWithResponse(ctx context.Contex return ParseAudioToTextResponse(rsp) } +// FrameInterpolationWithBodyWithResponse request with arbitrary body returning *FrameInterpolationResponse +func (c *ClientWithResponses) FrameInterpolationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FrameInterpolationResponse, error) { + rsp, err := c.FrameInterpolationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFrameInterpolationResponse(rsp) +} + // HealthWithResponse request returning *HealthResponse func (c *ClientWithResponses) HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error) { rsp, err := c.Health(ctx, reqEditors...) @@ -930,6 +1024,60 @@ func ParseAudioToTextResponse(rsp *http.Response) (*AudioToTextResponse, error) return response, nil } +// ParseFrameInterpolationResponse parses an HTTP response from a FrameInterpolationWithResponse call +func ParseFrameInterpolationResponse(rsp *http.Response) (*FrameInterpolationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FrameInterpolationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ImageResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest HTTPError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest HTTPError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 422: + var dest HTTPValidationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON422 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest HTTPError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseHealthResponse parses an HTTP response from a HealthWithResponse call func ParseHealthResponse(rsp *http.Response) (*HealthResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -1177,6 +1325,9 @@ type ServerInterface interface { // Audio To Text // (POST /audio-to-text) AudioToText(w http.ResponseWriter, r *http.Request) + // Frame Interpolation + // (POST /frame_interpolation) + FrameInterpolation(w http.ResponseWriter, r *http.Request) // Health // (GET /health) Health(w http.ResponseWriter, r *http.Request) @@ -1204,6 +1355,12 @@ func (_ Unimplemented) AudioToText(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } +// Frame Interpolation +// (POST /frame_interpolation) +func (_ Unimplemented) FrameInterpolation(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + // Health // (GET /health) func (_ Unimplemented) Health(w http.ResponseWriter, r *http.Request) { @@ -1260,6 +1417,23 @@ func (siw *ServerInterfaceWrapper) AudioToText(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r.WithContext(ctx)) } +// FrameInterpolation operation middleware +func (siw *ServerInterfaceWrapper) FrameInterpolation(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + ctx = context.WithValue(ctx, HTTPBearerScopes, []string{}) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.FrameInterpolation(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r.WithContext(ctx)) +} + // Health operation middleware func (siw *ServerInterfaceWrapper) Health(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -1459,6 +1633,9 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Post(options.BaseURL+"/audio-to-text", wrapper.AudioToText) }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/frame_interpolation", wrapper.FrameInterpolation) + }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/health", wrapper.Health) }) @@ -1481,32 +1658,33 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xZ227bOBN+FYL/f+nEhzabhe+SbLcNtoegdrsXRWAw0thmK5FaHtJ6A7/7gkNZomQp", - "cpDGC2R9Zcsaznxz+IZD+o5GMs2kAGE0Hd9RHS0hZfj17OrylVJSue+ZkhkowwHfpHrhPgw3CdAxfacX", - "tEfNKnMP2iguFnS97lEFf1muIKbjL7jkulcsKXQX6+TNV4gMXffouYxXM2ZjLmdGzgz8MLWnTGqzDQpl", - "3Je5VCkzdExvuGBqRQOrKLIFtUdTGUMy47FbHsOc2cStD1a+cwLkMu7006MIPN3Nm7Yw8JQtwIn6L7XH", - "5kAsLI+ZiGCmI+YgBC6dHp+UyF7ncmSCcgUEYdMbUA4CWrk/pJco0hBSj/AeLMMQC6oh3YgekageFbBg", - "ht/CLFMyzUyrjve5HLnyck2qbOpzoGcZqCaFw0CfTQk6qMkVqC2tXBhYePdQrZiDAoyZgUxXlQ4GNbUb", - "YTJB4SalJbjNyna/NJuDWc2iJUTfKpaNslCanqAYuUCxQs2NlAkwgXoA4tDixD03gdNGgViYZcXY4PjX", - "wNZGYqscatTLNl75sq1zcAcqdbLwlscg64/NLJzXUvdLCef3lkQtgS+W1So6OQ3WvfHvm5Y+hqmP4lQq", - "DZdidmOjb2DqSoaj01CLkyTnKFnRFhJAcg0zZhezlsIYjAICOGFyZhekvUa6OTU6eTil9k6T7zyuhWI4", - "GL0sLf2J77dX1ijSwYz28m5jhs2wsRefzVz416qzK/enJ8+qnT6sITbmriHRb6bTq5ZBMAbDeOK+/V/B", - "nI7p//rlONnPZ8l+MezVAebLA2ClrRYgn1nCY+Y6SSckbiDVXdjq+tYllt+8pgIIU4qt0IcQbV1BE25g", - "iVlebIqgilcbZmy1KumHP2i4/6FA0+BZbgylgQb7yK2PoDMpNLSwU+8csXcQcxbGyY82TXHaaj06zHUV", - "VgNub2kLr9Dz7yEZ3rvnR3VXq5JQ7pNKOud8izLaa0REgWceeINHU/hh2hMRLa34tnsiUDxMxIVfX09E", - "j7pzRuigg9HpofFCOajAu4oTLU5OJWb3iinmHXmqI0o5M+0wJf3HTw8nz+3wUExFDxyDcqdqNV2t2YbC", - "7tx7EhlV2MvE6sOcjr/cbcXqbgvidUDktzJCMw1Url+9gNYtg5P/oRRFzGTqfu2ivvPDm8olg0jtsN99", - "dnNje5ubK5bW9psHbjz19rY5V3nFHRtRbj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ROy48zfG2Plc1rnjCC1Hh3g+phjcQkJu0G4FsN1atnxS0YWnmh+rh", + "npTPO6AbX9A684JwGDfAI52iXHGzvLZ5dMjtxuUcmAJVXuYiB91fpZGFMRldrfCebSYdpXWkeIbNOaZn", + "grAsS7jrVmIkUbkgZ5ck4xkkXLhirJua30EGoOzzz7kQ6OgOlHa2BsfD44HNlsxAsIzTMX2Bf/VoxswC", + "YffxSvTIyKN16tfnDVsWBHEZry9wJ7Koh80gaGP3vLjKSmFAoFaaJ4ZnTJm+PZgcxcyw6nK7qx23u7Fd", + "1WtoJyH+4ZoNoxoNBg1cXlL737VNz7agamsz+q5X7DqPItB6liekEuvRl78RQrWFD/g/ZzH57Orh/A73", + "4/eLYLlZSMX/hBgdD1/sx3ERLHktDDdLMpGSvGdq7rI+Gv1WEBtnmU04lQgpzzsn+yo+XsQLlpBrUHeg", + "SHUoXI8oXCv94fTtZnXTozpPU6aWa2aTiSTIbavaD9ypt08GXCIua7JPOyB2eguw52FRP4AdpkX7tDgQ", + "dVeiItFInWlI1wXeVeAhEAIEdVcZ9Am73r8s2bbnV35oBUSMBk9xdkNSXnGG5w5SrThgPPHE2eI9x2HO", + "HObMM5kz7sXxRLorkgYp8QVGJynx+LcvUra/YtkzKeuH3gMpD6R8AlI6aiEp7ZF4i4XSu4h7kJKPOyLX", + "r/oOy+GBec+Eeba5G6th8Xq3nXJfCoGnXQGDb5sPzDsw75kwb82ildOyZjQq1T2Vt+AXicxjciHTNBfc", + "LMlbZuAnW9LibTTevetxvx8rYOnR3D09Tgr148iq09XN6q8AAAD///BmUXaaLQAA", } // GetSwagger returns the content of the embedded swagger specification file