amazon-science / polygon-transformer

Apache License 2.0
131 stars 9 forks source link

Hugging face demonstrator not working #6

Closed samhodge-aiml closed 1 year ago

samhodge-aiml commented 1 year ago

I am getting this error

Traceback (most recent call last):
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/gradio/routes.py", line 439, in run_predict
    output = await app.get_blocks().process_api(
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/gradio/blocks.py", line 1384, in process_api
    result = await self.call_function(
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/gradio/blocks.py", line 1089, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/gradio/utils.py", line 700, in wrapper
    response = f(*args, **kwargs)
  File "/media/sam/aimlwork/huggingface/PolyFormer/demo.py", line 255, in visual_grounding
    encoder_out = model.encoder(
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/sam/aimlwork/huggingface/PolyFormer/models/polyformer/unify_transformer.py", line 683, in forward
    return self.forward_scriptable(src_tokens,
  File "/media/sam/aimlwork/huggingface/PolyFormer/models/polyformer/unify_transformer.py", line 734, in forward_scriptable
    self.get_patch_images_info(patch_images, sample_patch_num, src_tokens.device)
  File "/media/sam/aimlwork/huggingface/PolyFormer/models/polyformer/unify_transformer.py", line 580, in get_patch_images_info
    image_embed = self.embed_images(patch_images)
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/sam/aimlwork/huggingface/PolyFormer/models/polyformer/swin.py", line 736, in forward
    x = self.patch_embed(x)
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/sam/aimlwork/huggingface/PolyFormer/models/polyformer/swin.py", line 580, in forward
    x = self.proj(x)  # B C Wh Ww
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/media/sam/aimlwork/github/polygon-transformer/env/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (c10::Half) and bias type (float) should be the same

See python modules attached

modules.txt

Running on Ubuntu 22.04 with NVIDIA RTX 3090.

samhodge-aiml commented 1 year ago

Will try from docker now.

samhodge-aiml commented 1 year ago

Working fine on CPU.

joellliu commented 1 year ago

Hi, since Huggingface only provides free CPU machines, the demo codes on Huggingface are modified to work on CPU. @huidingai will upload demo codes for GPU here soon.

huidingai commented 1 year ago

@samhodge-aiml The demo codes are pushed.