hustvl / Matte-Anything

[Image and Vision Computing (Vol.147 Jul. '24)] Interactive Natural Image Matting with Segment Anything Models
MIT License
465 stars 33 forks source link

AttributeError: 'FieldInfo' object has no attribute 'in_' #13

Closed Mason-McGough closed 1 year ago

Mason-McGough commented 1 year ago

Hello all, excited about this project!

I followed the setup instructions, downloaded the models, and executed python matte_anything.py to launch the server. That command fails with the following error:

Traceback (most recent call last):
  File "/home/bricklayer/Workspace/Matte-Anything/matte_anything.py", line 296, in <module>
    with gr.Blocks() as demo:
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/gradio/blocks.py", line 1478, in __exit__
    self.app = routes.App.create_app(self)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/gradio/routes.py", line 220, in create_app
    def login(form_data: OAuth2PasswordRequestForm = Depends()):
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 706, in decorator
    self.add_api_route(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 645, in add_api_route
    route = route_class(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 491, in __init__
    self.dependant = get_dependant(path=self.path_format, call=self.endpoint)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 268, in get_dependant
    sub_dependant = get_param_sub_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 111, in get_param_sub_dependant
    return get_sub_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 147, in get_sub_dependant
    sub_dependant = get_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 289, in get_dependant
    add_param_to_fields(field=param_field, dependant=dependant)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 462, in add_param_to_fields
    if field_info.in_ == params.ParamTypes.path:
AttributeError: 'FieldInfo' object has no attribute 'in_'

Seems that it might be related to Gradio/FastAPI, so I will try with a different version. I am currently using an Anaconda environment with the following versions:

Thanks for your help. Looking forward to trying this.

Mason-McGough commented 1 year ago

One more version that might be helpful: pydantic==2.1.0

YeL6 commented 1 year ago

Hello all, excited about this project!

I followed the setup instructions, downloaded the models, and executed python matte_anything.py to launch the server. That command fails with the following error:

Traceback (most recent call last):
  File "/home/bricklayer/Workspace/Matte-Anything/matte_anything.py", line 296, in <module>
    with gr.Blocks() as demo:
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/gradio/blocks.py", line 1478, in __exit__
    self.app = routes.App.create_app(self)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/gradio/routes.py", line 220, in create_app
    def login(form_data: OAuth2PasswordRequestForm = Depends()):
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 706, in decorator
    self.add_api_route(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 645, in add_api_route
    route = route_class(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/routing.py", line 491, in __init__
    self.dependant = get_dependant(path=self.path_format, call=self.endpoint)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 268, in get_dependant
    sub_dependant = get_param_sub_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 111, in get_param_sub_dependant
    return get_sub_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 147, in get_sub_dependant
    sub_dependant = get_dependant(
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 289, in get_dependant
    add_param_to_fields(field=param_field, dependant=dependant)
  File "/home/bricklayer/anaconda3/envs/matte-anything/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 462, in add_param_to_fields
    if field_info.in_ == params.ParamTypes.path:
AttributeError: 'FieldInfo' object has no attribute 'in_'

Seems that it might be related to Gradio/FastAPI, so I will try with a different version. I am currently using an Anaconda environment with the following versions:

  • python==3.10.12
  • gradio==3.38.0
  • fastapi==0.100.0

Thanks for your help. Looking forward to trying this.

Hello!I am really glad that you are interested in our work!Thank you for your asking! We consider this problem may be due to the different version of fastapi and pydantic. I solve this problem by updating them, with the code:

pip install --upgrade fastapi pydantic

At present, fastapi==0.100.1 pydantic==2.1.1. I hope this answer will help you.

Mason-McGough commented 1 year ago

Worked for me! Thanks a lot for your help.