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

[Feature Request]: Replicate support #36

Open
1 task done
platform-kit opened this issue May 26, 2024 · 3 comments
Open
1 task done

[Feature Request]: Replicate support #36

platform-kit opened this issue May 26, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@platform-kit
Copy link

platform-kit commented May 26, 2024

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What would your feature do?

Hi! Great work with this fork.

Putting in a request for adding replicate.com support.

Proposed workflow

It's as simple as adding two files - a cog.yaml that specifies underlying pip packages and other environment details (CUDA version etc)

https://github.com/mrhan1993/Fooocus-API/blob/main/cog.yaml

and a predict.py where the model is loaded and the input types are specified

https://github.com/mrhan1993/Fooocus-API/blob/main/predict.py

You would just have to copy these two files to the repo and then modify to add support for whatever changes you've made to enable InstantID, etc.

Additional information

Further info on the Cog package, which is a wrapper for docker, at https://cog.run

@platform-kit platform-kit added the enhancement New feature or request label May 26, 2024
@platform-kit
Copy link
Author

platform-kit commented Jun 7, 2024

@machineminded any chance of getting this on the roadmap? I am happy to implement it myself if you can point out what inputs/variables need to be passed.

@machineminded
Copy link
Owner

I haven't had a chance to look at this yet. But please, if you want to integrate this feel free. What inputs are you looking for? The inswapper stuff?

@platform-kit
Copy link
Author

@machineminded

I'll need to know what packages you added to the branch so I can list them in the requirements in
cog.yaml as well as what new input fields you're now passing to the API to enable/disable new features.

In a cog model (Replicate's format) you do all the prediction in a single file https://github.com/mrhan1993/Fooocus-API/blob/main/predict.py

You specify the possible input fields in def predict (line 50 in the above) which can then you can access when calling the underlying model code (fooocus, in this case) in the subsequent code.

For example in the above code they declare an input variable inpaint_input_image then use it on line 259, to pass to the Fooocus API like so:

     params = ImageGenerationParams(
            prompt=prompt,
            negative_prompt=negative_prompt,
            style_selections=style_selections_arr,
            performance_selection=performance_selection,
            aspect_ratios_selection=aspect_ratios_selection,
            image_number=image_number,
            image_seed=image_seed,
            sharpness=sharpness,
            guidance_scale=guidance_scale,
            base_model_name=base_model_name,
            refiner_model_name=refiner_model_name,
            refiner_switch=refiner_switch,
            loras=loras,
            uov_input_image=uov_input_image,
            uov_method=uov_method,
            upscale_value=uov_upscale_value,
            outpaint_selections=outpaint_selections_arr,
            inpaint_input_image=inpaint_input_image_dict,
            image_prompts=image_prompts,
            advanced_params=advanced_params,
            inpaint_additional_prompt=inpaint_additional_prompt,
            outpaint_distance_left=outpaint_distance_left,
            outpaint_distance_top=outpaint_distance_top,
            outpaint_distance_right=outpaint_distance_right,
            outpaint_distance_bottom=outpaint_distance_bottom,
            save_meta=True,
            meta_scheme='fooocus',
            save_extension='png',
            save_name='',
            require_base64=False,
        )

IMO the best course of action would be to do a minimal implementation of InstantID.

What would be the minimal input needed to invoke a generation with InstantID? I'd imagine you're using some kind of boolean like enable_instantid and an image field like instantid_input_image?

What are those fields and how do you pass them to the underlying Fooocus model?

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

No branches or pull requests

2 participants