Closed WaterKnight1998 closed 1 day ago
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.
I am using the following container: konieshadow/fooocus-api:v0.3.30
I am using next Code to do inpaint:
I get the following error on server: