mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
512 stars 137 forks source link

Seed integer in Replicate response #184

Closed NicolasRoehm closed 5 months ago

NicolasRoehm commented 5 months ago

How can I get the generated seed back from Replicate after a successful generation ?

konieshadow commented 5 months ago

@NicolasRoehm If you generate image in the Playground page, you can get it from output logs bellow preview images. If you use it with API, you can't get the seed. I'll check if it is possible to modify the response schema.

NicolasRoehm commented 5 months ago

Thank you very much @konieshadow ! Could you please merge branch main into cog-anime-preset ? :)

konieshadow commented 5 months ago

Thank you very much @konieshadow ! Could you please merge branch main into cog-anime-preset ? :)

The new updates in main won't bring new features to replicate predict.

NicolasRoehm commented 5 months ago

Is it possible and / or planned to plug this feature to the replicate predict response ?

NicolasRoehm commented 5 months ago

Hi @konieshadow I really need this feature and I've never written code in python but maybe if you give me some insights, I can try to help and submit a pull request?

As far as I understand, this line : results = blocking_get_task_result(async_task.job_id) helps us to fulfil the list output_paths: List[Path] = [] which is the response of the predict function.

If we change the return type of the predict function from a list to an object as described in the cog documentation like for example :

from cog import BasePredictor, BaseModel, File

class Output(BaseModel):
    seed: str
    paths: List[Path]

class Predictor(BasePredictor):
    def predict(self) -> Output:
        return Output(seed=results[0]['seed'], paths=output_paths)

Do you think this can be a solution ? :) Thank you very much