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

Few Tips and Swift Core ML version. #22

Open
john-rocky opened this issue Jan 18, 2024 · 2 comments
Open

Few Tips and Swift Core ML version. #22

john-rocky opened this issue Jan 18, 2024 · 2 comments

Comments

@john-rocky
Copy link

john-rocky commented Jan 18, 2024

Thank you for the great project.

3Tips for users of the pretrained models.

Tips0

Installation method that worked successfully

git clone https://github.com/hukenovs/easyportrait.git
cd easyportrait/pipelines/
pip install torch==1.13.1 torchvision==0.14.1
pip install -U openmim
mim install mmengine
mim install mmcv==1.7.1
mim install mmcv-full==1.7.1
pip install mmsegmentation==0.30.0
pip install ftfy

Tips1:

If you change line 281 of formatting.py, it will run smoothly.

# img_meta[key] = results[key]
img_meta[key] = results.get(key,None)

Tips2:

When plotting the results, set palette to None to plot the results.

show_result_pyplot(
   model,
   img,
   result,
   None,
   opacity=1,
   out_file=out)

Swift/iOS version

I converted segformer512fp to Core ML ( Swift / iOS format ).

https://github.com/john-rocky/easyportrait-coreml

And made Swift demo.

https://github.com/john-rocky/CoreML-Models?tab=readme-ov-file#easyportrait

Jan-18-2024 20-51-05

Thanks again!

@hradec
Copy link

hradec commented Feb 15, 2024

Thank you Thank you Thank you!!!

A couple more tips for others:


Tips3:

if you see this error:

File "./pipelines/demo/image_demo.py", line 40, in main
get_palette(args.palette),
File "/root/miniconda3/envs/easyportrait/lib/python3.8/site-packages/mmseg/core/evaluation/class_names.py", line 324, in get_palette
raise ValueError(f'Unrecognized dataset: {dataset}')
ValueError: Unrecognized dataset: easy_portrait

Set the pipelines folder of this depot to the top of your PYTHONPATH, for example:

export PYTHONPATH=./pipelines:$PYTHONPATH

This depot has a copy of the mmseg python module source in the pipelines folder, that was modified to include the easy_portrait palette, so python needs to load this local copy of mmseg instead of the one installed.


Tips4:

If you get an AssertionError like this:

File "pipelines/mmseg/models/segmentors/base.py", line 267, in show_result
    assert palette.shape[0] == len(self.CLASSES)
AssertionError

just add a # to the start of the line 267 of pipelines/mmseg/models/segmentors/base.py and it should run:

266         palette = np.array(palette)
267 #        assert palette.shape[0] == len(self.CLASSES)
268         assert palette.shape[1] == 3
269         assert len(palette.shape) == 2
270         assert 0 < opacity <= 1.0

@kleinsbotle
Copy link
Collaborator

Hi,
Thank you for sharing great tips!

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

3 participants