Fooocus-API
Fooocus-API copied to clipboard
AttributeError: 'NoneType' object has no attribute 'mixing_image_prompt_and_inpaint'
I am using the following container: konieshadow/fooocus-api:v0.3.30
I am using next Code to do inpaint:
import requests
import json
# image_prompt v1 example
host = "http://127.0.0.1:8888"
image = open("/Users/david/Downloads/image.jpeg", "rb").read()
source = open("/Users/david/Downloads/image.jpeg", "rb").read()
mask = open("/Users/david/Downloads/mask.png", "rb").read()
def image_prompt(params: dict,
input_image: bytes=None,
input_mask: bytes=None,
cn_img1: bytes=None,
cn_img2: bytes=None,
cn_img3: bytes=None,
cn_img4: bytes=None,) -> dict:
"""
image prompt
"""
response = requests.post(url=f"{host}/v1/generation/image-prompt",
data=params,
files={
"input_image": input_image,
"input_mask": input_mask,
"cn_img1": cn_img1,
"cn_img2": cn_img2,
"cn_img3": cn_img3,
"cn_img4": cn_img4,
})
print(response.text)
return response.json()
params = {
"prompt": "1girl sitting on the chair",
"image_prompts": [], # required, can be empty list
"async_process": True
}
result = image_prompt(params=params, input_image=source, input_mask=mask)
print(json.dumps(result, indent=4, ensure_ascii=False))
I get the following error on server:
[Warning] Wrong base_model_name input: juggernautXL_version6Rundiffusion.safetensors, using default
[Warning] Wrong lora model_name input: sd_xl_offset_example-lora_1.0.safetensors, using 'None'
[INFO] Mixing image prompt and inpaint is set to True
INFO: 10.56.1.1:12051 - "POST /v1/generation/image-prompt HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/fastapi/applications.py", line 292, in __call__
await super().__call__(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 83, in __call__
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/opt/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/opt/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/venv/lib/python3.10/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/opt/venv/lib/python3.10/site-packages/fastapi/routing.py", line 192, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/opt/venv/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/opt/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/opt/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/opt/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/app/fooocusapi/api.py", line 236, in img_prompt
return call_worker(req, accept)
File "/app/fooocusapi/api.py", line 76, in call_worker
params = req_to_params(req)
File "/app/fooocusapi/api_utils.py", line 90, in req_to_params
req.advanced_params.mixing_image_prompt_and_inpaint = True
AttributeError: 'NoneType' object has no attribute 'mixing_image_prompt_and_inpaint'
With following code:
import requests
import json
# image_prompt v1 example
host = "http://127.0.0.1:8888"
image = open("/Users/david/Downloads/bear.jpg", "rb").read()
source = open("/Users/david/Downloads/s.jpg", "rb").read()
mask = open("/Users/david/Downloads/m.png", "rb").read()
def inpaint_outpaint(params: dict, input_image: bytes, input_mask: bytes = None) -> dict:
"""
Partial redraw v1 interface example
"""
response = requests.post(url=f"{host}/v1/generation/image-inpaint-outpaint",
data=params,
files={"input_image": input_image,
"input_mask": input_mask})
return response.json()
result = inpaint_outpaint(params={
"prompt": "a cat",
"async_process": True},
input_image=source,
input_mask=mask)
print(json.dumps(result, indent=4, ensure_ascii=False))
Logs:
INFO: 10.164.0.23:45393 - "GET / HTTP/1.1" 200 OK
INFO: 10.164.0.20:17503 - "POST /v1/generation/image-inpaint-outpaint HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/fastapi/applications.py", line 292, in __call__
await super().__call__(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 83, in __call__
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/opt/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/opt/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/opt/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/venv/lib/python3.10/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/opt/venv/lib/python3.10/site-packages/fastapi/routing.py", line 192, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/opt/venv/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/opt/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/opt/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/opt/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/app/fooocusapi/api.py", line 199, in img_inpaint_or_outpaint
return call_worker(req, accept)
File "/app/fooocusapi/api.py", line 75, in call_worker
task_type = get_task_type(req)
File "/app/fooocusapi/api.py", line 62, in get_task_type
return TaskType.img_inpaint_outpaiFnt
File "/usr/lib/python3.10/enum.py", line 437, in __getattr__
raise AttributeError(name) from None
AttributeError: img_inpaint_outpaiFnt
Unfortunately, the Fooocus-API docker images are not updated every time some fix is made and it's not the first time they contain a major bug until next version. The img_inpaint_outpaiFnt one is present there since https://github.com/mrhan1993/Fooocus-API/commit/cfe10124f8bd42dd77b1700a8cb180ee6351dbf5. The best you can do right now is to get the repo code and build your up-to-date image.