kadirnar/codeformer-pip

inference_app to return image data instead of path?

marcd123 opened this issue · 2 comments

https://github.com/kadirnar/codeformer-pip/blob/2137ec09acb3eb219ca3126432822b7dae336183/codeformer/app.py#L177C7-L177C7

Can we get an option to return the image data itself instead of the path, or at least be able to set the save path, perhaps set as an input parameter to the function?

Also thank you so much for creating this repo - I've installed codeformer in a project manually before and it was not fun.

Hi, i made a pull request: PR

Add a judgment to the input, weather input is path string or a numpy array. change return to numpy array instead of save path, thus you can change save path easily.

you can use below to install:
method 1
you can download :

git clone https://github.com/samggggflynn/codeformer-pip.git
cd codeformer-pip
pip install -e .

method 2
or just install by :

pip install git+https://github.com/samggggflynn/codeformer-pip.git

pip install git+https://github.com/samggggflynn/codeformer-pip.git

a use sample as below:

    import cv2
    from codeformer.app import inference_app
    
    target_img = cv2.imread('inswap_res.png')

    res_img = inference_app(
    image=target_img,  # array / path
    background_enhance=True,
    face_upsample=True,
    upscale=2,
    codeformer_fidelity=0.5,
    ) # return array
    cv2.imwrite('final_res_with_codeformer.png', res_img)