Skip to content

Commit

Permalink
Merge pull request #34 from konieshadow/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
konieshadow authored Oct 25, 2023
2 parents a795b21 + da6d273 commit 2bf700f
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 4 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ Query async generation request results, return job progress and generation resul
#### Query Job Queue Info
> GET /v1/generation/job-queue
Query job queue info, include running job count, finished job count and last job id.
Query job queue info, include running job count, finished job count and last job id.

#### Get All Model Names
> GET /v1/engines/all-models
Get all filenames of base model and lora.

#### Refresh Models
> POST /v1/engines/refresh-models
#### Get All Fooocus Styles
> GET /v1/engines/styles
Get all legal Fooocus styles.
85 changes: 85 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,95 @@
}
}
}
},
"/v1/engines/all-models": {
"get": {
"summary": "All Models",
"description": "Get all filenames of base model and lora",
"operationId": "all_models_v1_engines_all_models_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AllModelNamesResponse"
}
}
}
}
}
}
},
"/v1/engines/refresh-models": {
"post": {
"summary": "Refresh Models",
"description": "Refresh local files and get all filenames of base model and lora",
"operationId": "refresh_models_v1_engines_refresh_models_post",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AllModelNamesResponse"
}
}
}
}
}
}
},
"/v1/engines/styles": {
"get": {
"summary": "All Styles",
"description": "Get all legal Fooocus styles",
"operationId": "all_styles_v1_engines_styles_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"items": {
"type": "string"
},
"type": "array",
"title": "Response All Styles V1 Engines Styles Get"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"AllModelNamesResponse": {
"properties": {
"model_filenames": {
"items": {
"type": "string"
},
"type": "array",
"title": "Model Filenames"
},
"lora_filenames": {
"items": {
"type": "string"
},
"type": "array",
"title": "Lora Filenames"
}
},
"type": "object",
"required": [
"model_filenames",
"lora_filenames"
],
"title": "AllModelNamesResponse"
},
"AspectRatio": {
"type": "string",
"enum": [
Expand Down
2 changes: 1 addition & 1 deletion fooocus_api_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.2.2'
version = '0.2.4'
20 changes: 19 additions & 1 deletion fooocusapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi.params import File
import uvicorn
from fooocusapi.api_utils import generation_output, req_to_params
from fooocusapi.models import AsyncJobResponse, GeneratedImageBase64, ImgInpaintOrOutpaintRequest, ImgPromptRequest, ImgUpscaleOrVaryRequest, JobQueueInfo, Text2ImgRequest
from fooocusapi.models import AllModelNamesResponse, AsyncJobResponse, GeneratedImageBase64, ImgInpaintOrOutpaintRequest, ImgPromptRequest, ImgUpscaleOrVaryRequest, JobQueueInfo, Text2ImgRequest
from fooocusapi.parameters import GenerationFinishReason, ImageGenerationResult
from fooocusapi.task_queue import TaskType
from fooocusapi.worker import process_generate, task_queue
Expand Down Expand Up @@ -152,6 +152,24 @@ def job_queue():
return JobQueueInfo(running_size=len(task_queue.queue), finished_size=len(task_queue.history), last_job_id=task_queue.last_seq)


@app.get("/v1/engines/all-models", response_model=AllModelNamesResponse, description="Get all filenames of base model and lora")
def all_models():
import modules.path as path
return AllModelNamesResponse(model_filenames=path.model_filenames, lora_filenames=path.lora_filenames)


@app.post("/v1/engines/refresh-models", response_model=AllModelNamesResponse, description="Refresh local files and get all filenames of base model and lora")
def refresh_models():
import modules.path as path
path.update_all_model_names()
return AllModelNamesResponse(model_filenames=path.model_filenames, lora_filenames=path.lora_filenames)


@app.get("/v1/engines/styles", response_model=List[str], description="Get all legal Fooocus styles")
def all_styles():
from modules.sdxl_styles import legal_style_names
return legal_style_names

def start_app(args):
uvicorn.run("fooocusapi.api:app", host=args.host,
port=args.port, log_level=args.log_level)
7 changes: 6 additions & 1 deletion fooocusapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,9 @@ class AsyncJobResponse(BaseModel):
class JobQueueInfo(BaseModel):
running_size: int = Field(description="The current running and waiting job count")
finished_size: int = Field(description="Finished job cound (after auto clean)")
last_job_id: int = Field(description="Last submit generation job id")
last_job_id: int = Field(description="Last submit generation job id")


class AllModelNamesResponse(BaseModel):
model_filenames: List[str]
lora_filenames: List[str]

0 comments on commit 2bf700f

Please sign in to comment.