wyysf-98 / CraftsMan

CraftsMan: High-fidelity Mesh Generation with 3D Native Diffusion and Interactive Geometry Refiner
https://craftsman3d.github.io/
430 stars 22 forks source link

Error running in a cloned space #9

Closed TheMich01 closed 5 months ago

TheMich01 commented 5 months ago

I copy the space from huggingface to run locally, but when it starts it give me this error:

File "/home/slate/pinokio/api/CraftsMan3D/app/gradio_app.py", line 406, in rmbg = RMBG(device) File "/home/slate/pinokio/api/CraftsMan3D/app/apps/utils.py", line 52, in init sam = sam_model_registry"vit_h".to(device) File "/home/slate/pinokio/api/CraftsMan3D/app/env/lib/python3.10/site-packages/segment_anything/build_sam.py", line 15, in build_sam_vit_h return _build_sam( File "/home/slate/pinokio/api/CraftsMan3D/app/env/lib/python3.10/site-packages/segment_anything/build_sam.py", line 105, in _build_sam state_dict = torch.load(f) File "/home/slate/pinokio/api/CraftsMan3D/app/env/lib/python3.10/site-packages/torch/serialization.py", line 1040, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/slate/pinokio/api/CraftsMan3D/app/env/lib/python3.10/site-packages/torch/serialization.py", line 1258, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, 'v'. (env) (base)

it looks like it starts from the output_module_obj that is gr.Model3D (line 355 in gradio_app.py) i do not think i've installed some wrong lirary, the requirements.txt installation didn't return any error

wyysf-98 commented 5 months ago

Hi, I think the error occurs then loading the ckpt of the SAM model. There are some possible reasons for it:

  1. you should use git lfs to clone a repo which contains large files;
  2. wrong version of transformer of segment_anything; Or you can remove this line and use rembg to remove the background, which is the default method we used in huggingface demo.
TheMich01 commented 5 months ago
2. wrong version of transformer of segment_anything;
   Or you can remove this line and use rembg to remove the background, which is the default method we used in huggingface demo.

thank's for your answer: this solution gave me an improvment, I've just commented line 406, then it started to donwnload some files, but after then I received the "rmbg-rembg" error:

File "/home/slate/pinokio/api/CraftsMan3D/app/gradio_app.py", line 412, in fn=rmbg.run, NameError: name 'rmbg' is not defined. Did you mean: 'rembg'?

so i change rmbg.run with rembg.run but it didn't work so I remove the ".run" and it doesn't work either, do you have any solution to suggest?

wyysf-98 commented 5 months ago
2. wrong version of transformer of segment_anything;
   Or you can remove this line and use rembg to remove the background, which is the default method we used in huggingface demo.

thank's for your answer: this solution gave me an improvment, I've just commented line 406, then it started to donwnload some files, but after then I received the "rmbg-rembg" error:

File "/home/slate/pinokio/api/CraftsMan3D/app/gradio_app.py", line 412, in fn=rmbg.run, NameError: name 'rmbg' is not defined. Did you mean: 'rembg'?

so i change rmbg.run with rembg.run but it didn't work so I remove the ".run" and it doesn't work either, do you have any solution to suggest?

Hi, I think you should not comment L406, and it would be better if remove this https://huggingface.co/spaces/wyysf/CraftsMan/blob/main/apps/utils.py#L52-L53 if you do not want to use SAM

TheMich01 commented 5 months ago

i've try to comment all the first part of the function and it start working, but the button "generate" doesn't, so first i have to generate the 2d image, and then the 3d image, instead of one clik i have to clik twice, but it stll remain the issue to remove the background, i can remove it from other tools, but not inside the space. This is what i've done:

    run_btn.click(fn=check_input_image, inputs=[image_input]
                ).success(
                        #fn=rmbg.run, 
                        #inputs=[rmbg_type, image_input, foreground_ratio, background_choice, backgroud_color],
                        #outputs=[image_input]
TheMich01 commented 5 months ago

commenting line 53 and 53 in utils.py doesn't work

Traceback (most recent call last): File "/home/slate/pinokio/api/CraftsMan3D/app/gradio_app.py", line 24, in from apps.utils import * File "/home/slate/pinokio/api/CraftsMan3D/app/apps/utils.py", line 55 def rmbg_sam(self, input_image): ^^^ IndentationError: expected an indented block after function definition on line 51

but commenting 406, 412,413,414 in gradio_app.py i can use the model, just i have to use from advanced option, first generating the 2d and then generating the 3d.

I'm usink PINOKIO AI to run the model, may be there is some issue to solve inside PINOKIO. Thanks a lot for your help.

wyysf-98 commented 5 months ago

commenting line 53 and 53 in utils.py doesn't work

Traceback (most recent call last): File "/home/slate/pinokio/api/CraftsMan3D/app/gradio_app.py", line 24, in from apps.utils import * File "/home/slate/pinokio/api/CraftsMan3D/app/apps/utils.py", line 55 def rmbg_sam(self, input_image): ^^^ IndentationError: expected an indented block after function definition on line 51

but commenting 406, 412,413,414 in gradio_app.py i can use the model, just i have to use from advanced option, first generating the 2d and then generating the 3d.

I'm usink PINOKIO AI to run the model, may be there is some issue to solve inside PINOKIO. Thanks a lot for your help.

Hi, try not to comment any code in gradio_app.py and only comment lines 52-53 and add pass to the code. It should work.

image
wyysf-98 commented 5 months ago

BTW, I think a better way is to use git lfs to clone the spaces in the hugging face.