Skip to content

Commit

Permalink
Merge for Fooocus v2.1.755
Browse files Browse the repository at this point in the history
  • Loading branch information
konieshadow committed Nov 3, 2023
1 parent 5e7b0cf commit 30a9461
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 166 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FastAPI powered API for [Fooocus](https://github.com/lllyasviel/Fooocus)

Currently loaded Fooocus version: 2.1.741
Currently loaded Fooocus version: 2.1.755

### Run with Replicate
Now you can use Fooocus-API by Replicate, the model is in [konieshadow/fooocus-api](https://replicate.com/konieshadow/fooocus-api).
Expand Down
116 changes: 44 additions & 72 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,38 +548,6 @@
],
"title": "AllModelNamesResponse"
},
"AspectRatio": {
"type": "string",
"enum": [
"704×1408",
"704×1344",
"768×1344",
"768×1280",
"832×1216",
"832×1152",
"896×1152",
"896×1088",
"960×1088",
"960×1024",
"1024×1024",
"1024×960",
"1088×960",
"1088×896",
"1152×896",
"1152×832",
"1216×832",
"1280×768",
"1344×768",
"1344×704",
"1408×704",
"1472×704",
"1536×640",
"1600×640",
"1664×576",
"1728×576"
],
"title": "AspectRatio"
},
"AsyncJobResponse": {
"properties": {
"job_id": {
Expand Down Expand Up @@ -674,7 +642,7 @@
"negative_prompt": {
"type": "string",
"title": "Negative Prompt",
"default": ""
"default": "(embedding:unaestheticXLv31:0.8), low quality, watermark"
},
"style_selections": {
"items": {
Expand All @@ -685,7 +653,11 @@
"description": "Fooocus style selections, seperated by comma",
"default": [
"Fooocus V2",
"Default (Slightly Cinematic)"
"Fooocus Masterpiece",
"SAI Anime",
"SAI Digital Art",
"SAI Enhance",
"SAI Fantasy Art"
]
},
"performance_selection": {
Expand All @@ -697,12 +669,9 @@
"default": "Speed"
},
"aspect_ratios_selection": {
"allOf": [
{
"$ref": "#/components/schemas/AspectRatio"
}
],
"default": "1152×896"
"type": "string",
"title": "Aspect Ratios Selection",
"default": "896×1152"
},
"image_number": {
"type": "integer",
Expand Down Expand Up @@ -735,12 +704,12 @@
"base_model_name": {
"type": "string",
"title": "Base Model Name",
"default": "sd_xl_base_1.0_0.9vae.safetensors"
"default": "bluePencilXL_v050.safetensors"
},
"refiner_model_name": {
"type": "string",
"title": "Refiner Model Name",
"default": "sd_xl_refiner_1.0_0.9vae.safetensors"
"default": "DreamShaper_8_pruned.safetensors"
},
"l1": {
"anyOf": [
Expand Down Expand Up @@ -1034,7 +1003,7 @@
"negative_prompt": {
"type": "string",
"title": "Negative Prompt",
"default": ""
"default": "(embedding:unaestheticXLv31:0.8), low quality, watermark"
},
"style_selections": {
"items": {
Expand All @@ -1045,7 +1014,11 @@
"description": "Fooocus style selections, seperated by comma",
"default": [
"Fooocus V2",
"Default (Slightly Cinematic)"
"Fooocus Masterpiece",
"SAI Anime",
"SAI Digital Art",
"SAI Enhance",
"SAI Fantasy Art"
]
},
"performance_selection": {
Expand All @@ -1057,12 +1030,9 @@
"default": "Speed"
},
"aspect_ratios_selection": {
"allOf": [
{
"$ref": "#/components/schemas/AspectRatio"
}
],
"default": "1152×896"
"type": "string",
"title": "Aspect Ratios Selection",
"default": "896×1152"
},
"image_number": {
"type": "integer",
Expand Down Expand Up @@ -1095,12 +1065,12 @@
"base_model_name": {
"type": "string",
"title": "Base Model Name",
"default": "sd_xl_base_1.0_0.9vae.safetensors"
"default": "bluePencilXL_v050.safetensors"
},
"refiner_model_name": {
"type": "string",
"title": "Refiner Model Name",
"default": "sd_xl_refiner_1.0_0.9vae.safetensors"
"default": "DreamShaper_8_pruned.safetensors"
},
"l1": {
"anyOf": [
Expand Down Expand Up @@ -1228,7 +1198,7 @@
"negative_prompt": {
"type": "string",
"title": "Negative Prompt",
"default": ""
"default": "(embedding:unaestheticXLv31:0.8), low quality, watermark"
},
"style_selections": {
"items": {
Expand All @@ -1239,7 +1209,11 @@
"description": "Fooocus style selections, seperated by comma",
"default": [
"Fooocus V2",
"Default (Slightly Cinematic)"
"Fooocus Masterpiece",
"SAI Anime",
"SAI Digital Art",
"SAI Enhance",
"SAI Fantasy Art"
]
},
"performance_selection": {
Expand All @@ -1251,12 +1225,9 @@
"default": "Speed"
},
"aspect_ratios_selection": {
"allOf": [
{
"$ref": "#/components/schemas/AspectRatio"
}
],
"default": "1152×896"
"type": "string",
"title": "Aspect Ratios Selection",
"default": "896×1152"
},
"image_number": {
"type": "integer",
Expand Down Expand Up @@ -1289,12 +1260,12 @@
"base_model_name": {
"type": "string",
"title": "Base Model Name",
"default": "sd_xl_base_1.0_0.9vae.safetensors"
"default": "bluePencilXL_v050.safetensors"
},
"refiner_model_name": {
"type": "string",
"title": "Refiner Model Name",
"default": "sd_xl_refiner_1.0_0.9vae.safetensors"
"default": "DreamShaper_8_pruned.safetensors"
},
"l1": {
"anyOf": [
Expand Down Expand Up @@ -1557,7 +1528,7 @@
"negative_prompt": {
"type": "string",
"title": "Negative Prompt",
"default": ""
"default": "(embedding:unaestheticXLv31:0.8), low quality, watermark"
},
"style_selections": {
"items": {
Expand All @@ -1567,7 +1538,11 @@
"title": "Style Selections",
"default": [
"Fooocus V2",
"Default (Slightly Cinematic)"
"Fooocus Masterpiece",
"SAI Anime",
"SAI Digital Art",
"SAI Enhance",
"SAI Fantasy Art"
]
},
"performance_selection": {
Expand All @@ -1579,12 +1554,9 @@
"default": "Speed"
},
"aspect_ratios_selection": {
"allOf": [
{
"$ref": "#/components/schemas/AspectRatio"
}
],
"default": "1152×896"
"type": "string",
"title": "Aspect Ratios Selection",
"default": "896×1152"
},
"image_number": {
"type": "integer",
Expand Down Expand Up @@ -1617,12 +1589,12 @@
"base_model_name": {
"type": "string",
"title": "Base Model Name",
"default": "sd_xl_base_1.0_0.9vae.safetensors"
"default": "bluePencilXL_v050.safetensors"
},
"refiner_model_name": {
"type": "string",
"title": "Refiner Model Name",
"default": "sd_xl_refiner_1.0_0.9vae.safetensors"
"default": "DreamShaper_8_pruned.safetensors"
},
"loras": {
"items": {
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.3.6'
version = '0.3.7'
13 changes: 10 additions & 3 deletions fooocusapi/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from PIL import Image
from fooocusapi.file_utils import get_file_serve_url, output_file_to_base64img, output_file_to_bytesimg
from fooocusapi.models import AsyncJobResponse, AsyncJobStage, GeneratedImageResult, GenerationFinishReason, ImgInpaintOrOutpaintRequest, ImgPromptRequest, ImgUpscaleOrVaryRequest, Text2ImgRequest
from fooocusapi.parameters import ImageGenerationParams, ImageGenerationResult
from fooocusapi.task_queue import QueueTask, TaskType
from fooocusapi.parameters import ImageGenerationParams, ImageGenerationResult, available_aspect_ratios, default_aspect_ratio
from fooocusapi.task_queue import QueueTask
import modules.flags as flags
from modules.sdxl_styles import legal_style_names

Expand Down Expand Up @@ -50,7 +50,7 @@ def req_to_params(req: Text2ImgRequest) -> ImageGenerationParams:
style_selections = [
s for s in req.style_selections if s in legal_style_names]
performance_selection = req.performance_selection.value
aspect_ratios_selection = req.aspect_ratios_selection.value
aspect_ratios_selection = req.aspect_ratios_selection
image_number = req.image_number
image_seed = None if req.image_seed == -1 else req.image_seed
sharpness = req.sharpness
Expand All @@ -64,6 +64,13 @@ def req_to_params(req: Text2ImgRequest) -> ImageGenerationParams:
req, ImgUpscaleOrVaryRequest) else req.uov_method.value
outpaint_selections = [] if not isinstance(req, ImgInpaintOrOutpaintRequest) else [
s.value for s in req.outpaint_selections]

if aspect_ratios_selection not in available_aspect_ratios:
print(f"Invalid aspect ratios selection, using default: {default_aspect_ratio}")
aspect_ratios_selection = default_aspect_ratio

if refiner_model_name == '':
refiner_model_name = 'None'

inpaint_input_image = None
if isinstance(req, ImgInpaintOrOutpaintRequest):
Expand Down
Loading

0 comments on commit 30a9461

Please sign in to comment.