Code Monkey home page Code Monkey logo

Comments (14)

vanga avatar vanga commented on May 27, 2024 1

Hi @lkeab without the background removed, these edges are not noticeable. I don't see the jagged edges even with my inference, atleast they are not noticeable this way I think.
000000008844

I simply do this to remove the background, so I don't think it is an issue with the background removal process.

from PIL import Image
img = Image.open(src_img_path)

np_img = np.copy(np.asarray(img))
neg_mask = ~mask
np_img[neg_mask] = 255
plt.imshow(np_img)

I wasn't setting VIS_PERIOD if it is not the default. I have set it now and I can confirm that the code is going to dilating step. Though, I am not sure if the output is any different.. I also tried with 7x7 kernel.. not much improvement.

000000008844-out

I see below logs during inference, not sure if they are of any significance

fpn input shapes: {'res2': ShapeSpec(channels=256, height=None, width=None, stride=4), 'res3': ShapeSpec(channels=512, height=None, width=None, stride=8), 'res4': ShapeSpec(channels=1024, height=None, width=None, stride=16), 'res5': ShapeSpec(channels=2048, height=None, width=None, stride=32)}
/home/ubuntu/vangap/transfiner/detectron2/structures/image_list.py:99: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  max_size = (max_size + (stride - 1)) // stride * stride
/home/ubuntu/miniconda3/envs/transfiner/lib/python3.7/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2228.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
dilating---------------------------------------
/home/ubuntu/vangap/transfiner/detectron2/modeling/roi_heads/mask_head.py:60: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  dim_t = temperature ** (2 * (dim_t // 2) / num_pos_feats)

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

Hi, have this line triggered during the inference process? You can try to increase the dilation kernel range to reduce the artifacts. This is the result of the woman running on my local machine.
image

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

I did't observe this warning when running my code.

from transfiner.

vanga avatar vanga commented on May 27, 2024

Could there be an issue with the pytorch/cuda versions?
I am using all the latest versions, and on A100.

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

Not sure. I am using the NVIDIA TITAN RTX, Pytorch 1.7.1 and Cuda 11.0.

from transfiner.

vanga avatar vanga commented on May 27, 2024

If you don't mind, is it possible to provide mask object for one of these images(and details on which model and setttings are used) or provide an option in huggingspaces to download it?

I would like to compare it with what I am seeing and confirm if it's an env issue or something else.

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

Hi, I am currently out for a traveling. I think one validation method is to that you report your AP results for our pretrained model (for example r50-fpn-1x) running on your machine. If it is exactly the same, then I think it can exclude the environment factors.

from transfiner.

anl13 avatar anl13 commented on May 27, 2024

Hi @lkeab without the background removed, these edges are not noticeable. I don't see the jagged edges even with my inference, atleast they are not noticeable this way I think. 000000008844

I simply do this to remove the background, so I don't think it is an issue with the background removal process.

from PIL import Image
img = Image.open(src_img_path)

np_img = np.copy(np.asarray(img))
neg_mask = ~mask
np_img[neg_mask] = 255
plt.imshow(np_img)

I wasn't setting VIS_PERIOD if it is not the default. I have set it now and I can confirm that the code is going to dilating step. Though, I am not sure if the output is any different.. I also tried with 7x7 kernel.. not much improvement.

000000008844-out

I see below logs during inference, not sure if they are of any significance

fpn input shapes: {'res2': ShapeSpec(channels=256, height=None, width=None, stride=4), 'res3': ShapeSpec(channels=512, height=None, width=None, stride=8), 'res4': ShapeSpec(channels=1024, height=None, width=None, stride=16), 'res5': ShapeSpec(channels=2048, height=None, width=None, stride=32)}
/home/ubuntu/vangap/transfiner/detectron2/structures/image_list.py:99: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  max_size = (max_size + (stride - 1)) // stride * stride
/home/ubuntu/miniconda3/envs/transfiner/lib/python3.7/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2228.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
dilating---------------------------------------
/home/ubuntu/vangap/transfiner/detectron2/modeling/roi_heads/mask_head.py:60: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  dim_t = temperature ** (2 * (dim_t // 2) / num_pos_feats)

I encountered the same warnings! My env setting: ubuntu 20.04, python 3.7.13, pytorch 1.11.0, cuda 11.3.

from transfiner.

vanga avatar vanga commented on May 27, 2024

@anl13 Do you also see the jagged edges?

from transfiner.

anl13 avatar anl13 commented on May 27, 2024

@vanga Yes, I observed exactly the same results. In fact, I have removed these warnings by replacing a//b with torch.div(a, b, rounding_mode='floor'). However, there is no help. See result below. By the way, my GPU for test is Nvidia Titan X.
demo

from transfiner.

vanga avatar vanga commented on May 27, 2024

@lkeab Can we keep this open until thee is a closure? considering it is not just me?

w.r.t checking AP results, could you please share some pointers on how I can do that?

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

Hi, for checking AP results, you can report the inference results on coco val set using our provided pretrained model, such as R50-FPN-1x or 3X. I will also look into this to see whether can help fix it. It's not that noticeable when drawing masks directly on images.

from transfiner.

lkeab avatar lkeab commented on May 27, 2024

Hi, we also updated the code. Please try the latest version to see whether it helps or not. These are the results obtained by me.
test_img_819
test_img_785
test_img_454
test_img_464
test_img_924

from transfiner.

anl13 avatar anl13 commented on May 27, 2024

Here are my results with updated code. There are improvements compared with previous code. I test three pretrained models for human segmentation.

model: output_3x_transfiner_r101_deform.pth:
output000000008844
output000000126137
output000000131444
output000000157365

model: output_3x_transfiner_r101.pth:
output2000000008844
output2000000126137
output2000000131444
output2000000157365

model: output_3x_transfiner_r50.pth:
output3000000008844
output3000000126137
output3000000131444
output3000000157365

from transfiner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.