Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to generate data.json and segmentation fault while running application #15

Open
kartik122 opened this issue May 23, 2024 · 1 comment

Comments

@kartik122
Copy link

I tried using the repo with changes in detectron2 and main.py suggested in issue@
And still getting the following error:

Get mask of cloth

Get openpose coordinate using posenet

Segmentation fault
Generate semantic segmentation using Graphonomy-Master library

Constructing DeepLabv3+ model...
Number of classes: 20
Output stride: 16
Number of Input Channels: 3
load model: ./inference.pth
Segmentation fault

Generate Densepose image using detectron2 library

[05/23 07:54:23 apply_net]: Loading config from detectron2/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml
[05/23 07:54:23 apply_net]: Loading model from https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl
[05/23 07:54:25 apply_net]: Loading data from origin.jpg
Segmentation fault
Traceback (most recent call last):
File "/home/deepk/Desktop/backend/virtual_tryon/TryYours-Virtual-Try-On/get_densepose.py", line 27, in
with open('./data.json', 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: './data.json'

Run HR-VITON to generate final image

Start to test! - HR-VITON
Network [SPADEGenerator] was created. Total number of parameters: 100.5 million. To see the architecture, do print(network).
Segmentation fault

@myinzack
Copy link

myinzack commented Dec 9, 2024

The issue is fixed.

  1. Go to file TryYours-Virtual-Try-On\detectron2\projects\DensePose\apply_net.py

  2. Go to @classmethod def postexecute
    In the existing code the output is saved as output.pkl ensure the output is saved to data.json as shown in next step

  3. change the code as follows

        def postexecute(cls: type, context: Dict[str, Any]):
    
               out_fname = context["out_fname"]
               out_dir = os.path.dirname(out_fname)
               if len(out_dir) > 0 and not os.path.exists(out_dir):
                   os.makedirs(out_dir)
               context = context["results"][0]
               with open('./data.json','w') as f:
                   json.dump([context["pred_densepose"][0].labels.cpu().tolist(), 
                   context["pred_densepose"][0].uv.cpu().tolist(), 
                   context["pred_boxes_XYXY"][0].cpu().tolist()], f)
               
               logger.info(f"Output saved to data.json")
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants