chenfei-wu / TaskMatrix

Other
34.51k stars 3.32k forks source link

Remove Something From The Photo, 'NoneType' object has no attribute 'resize' #211

Open JihadAKl opened 1 year ago

JihadAKl commented 1 year ago

I am using python visual_chatgpt.py --load "ImageCaptioning_cuda:0,ImageEditing_cuda:0,Text2Image_cuda:0"

I am getting this error any idea?

Entering new AgentExecutor chain... Yes Action: Remove Something From The Photo Action Input: image/228cf7ef.png, everything except the couchTraceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/gradio/routes.py", line 384, in run_predict output = await app.get_blocks().process_api( File "/usr/local/lib/python3.9/dist-packages/gradio/blocks.py", line 1032, in process_api result = await self.call_function( File "/usr/local/lib/python3.9/dist-packages/gradio/blocks.py", line 844, in call_function prediction = await anyio.to_thread.run_sync( File "/usr/local/lib/python3.9/dist-packages/anyio/to_thread.py", line 31, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/usr/local/lib/python3.9/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.9/dist-packages/anyio/_backends/_asyncio.py", line 867, in run result = context.run(func, *args) File "/content/visual-chatgpt/visual_chatgpt.py", line 848, in run_text res = self.agent({"input": text}) File "/usr/local/lib/python3.9/dist-packages/langchain/chains/base.py", line 168, in call raise e File "/usr/local/lib/python3.9/dist-packages/langchain/chains/base.py", line 165, in call outputs = self._call(inputs) File "/usr/local/lib/python3.9/dist-packages/langchain/agents/agent.py", line 503, in _call next_step_output = self._take_next_step( File "/usr/local/lib/python3.9/dist-packages/langchain/agents/agent.py", line 420, in _take_next_step observation = tool.run( File "/usr/local/lib/python3.9/dist-packages/langchain/tools/base.py", line 71, in run raise e File "/usr/local/lib/python3.9/dist-packages/langchain/tools/base.py", line 68, in run observation = self._run(tool_input) File "/usr/local/lib/python3.9/dist-packages/langchain/agents/tools.py", line 17, in _run return self.func(tool_input) File "/content/visual-chatgpt/visual_chatgpt.py", line 169, in inference_remove return self.inference_replace(f"{image_path},{to_be_removed_txt},background") File "/content/visual-chatgpt/visual_chatgpt.py", line 182, in inference_replace mask_image=mask_image.resize((512, 512))).images[0] AttributeError: 'NoneType' object has no attribute 'resize'

Wang-Xiaodong1899 commented 1 year ago

Can you try it again? It seems the output mask_image of MaskFormer is None unfortunately at https://github.com/microsoft/visual-chatgpt/blob/main/visual_chatgpt.py#L180. What is the object you want to remove? maybe this MaskFormer cannot find the object in this image. More details?

chenfei-wu commented 1 year ago

Hi @JihadAKl , could you share your input image 'image/228cf7ef.png' and your dialogue, so we can debug that.

JihadAKl commented 1 year ago

h1 I am using this image and the prompt is remove everything except the couch from the image

JihadAKl commented 1 year ago

I use this prompt: Change the color of the couch to white i get this:

image

so, the couch is masked. I am getting another couch tho.

chenfei-wu commented 1 year ago

This is a foundation model issue, since the ImageEditing model failed to remove everything except the sofa.

image

The log is: Processed ImageEditing, Input Image: image/7908da62.png, Replace everything except the sofa to background, Output Image: image/b7ab_replace-something_7908da62_7908da62.png To solve this issue, we need to leverage more accurate Visual Foundation Models (VFM).

JihadAKl commented 1 year ago

Did you get my error? AttributeError: 'NoneType' object has no attribute 'resize'

are you using other models than ImageCaptioning, ImageEditing and Text2Image?

FJGEODEV commented 1 year ago

Did you get my error? AttributeError: 'NoneType' object has no attribute 'resize'

are you using other models than ImageCaptioning, ImageEditing and Text2Image?

I have the exactly same error. Looking for solutions. Thanks.

johnseed commented 1 year ago

I have the same issue. After debugging, it appears that the area_ratio is too small, which indicates that the replacement failed. https://github.com/microsoft/visual-chatgpt/blob/3cfc0a052d67d29e96065b3ea2bf8e22690da785/visual_chatgpt.py#L201