cog icon indicating copy to clipboard operation
cog copied to clipboard

Does cog support multiple Path input? e.g. List[Path] as input?

Open peter65374 opened this issue 1 year ago • 8 comments

  File "/root/.pyenv/versions/3.9.18/lib/python3.9/site-packages/cog/predictor.py", line 239, in get_input_type
    raise TypeError(
TypeError: Unsupported input type list for parameter `model_faces`. Supported input types are: str, int, float, bool, cog.File, cog.Path.

ⅹ Failed to get type signature: exit status 1

I got error as above when I try to build the below Predictor(...)

def predict(
        self,
        target_image: Path = Input(
            description="Faces in target image would be changed.",
        ),
        model_faces: list[Path] = Input(
            description="Model Faces would be swapped into target image.", 
            default=None,
        ),
        inference_mode: str = Input(
            default="swap",
            choices=["swap", "detect"],
            description="Face swap mode or detection mode. Default is swap.",
        ),
    ) -> Union[List[tuple], List[Path]]:
        """Run a single prediction on the model"""

Does cog support a List of Path as input in any method? In my scenario, I wish to make multiple faces processing in one HTTP API calling instead of 6-7 times HTTP latency.

peter65374 avatar Oct 20 '23 16:10 peter65374

Which cog version are you using? You may have more luck with one of the 0.9 beta's, which support list and union inputs.

yorickvP avatar Nov 03 '23 14:11 yorickvP

@yorickvP how do you use that?

alexblattner avatar Nov 03 '23 16:11 alexblattner

Which cog version are you using? You may have more luck with one of the 0.9 beta's, which support list and union inputs.

0.8.3. I am going to upgrade cog to 0.9 beta. Thank you.😄

peter65374 avatar Nov 03 '23 16:11 peter65374

@peter65374 @yorickvP it didn't work for me...

Version: 0.9.0b9

TypeError: Unsupported input type typing.List for parameter `liked_images`. Supported input types are: str, int, float, bool, cog.File, cog.Path.
ⅹ Failed to get container status: exit status 1
TypeError: Unsupported input type list for parameter `liked_images`. Supported input types are: str, int, float, bool, cog.File, cog.Path.
ⅹ Failed to get container status: exit status 1

alexblattner avatar Nov 06 '23 10:11 alexblattner

I'm also running into this, but I swear it was working yesterday...

jonhilgart22 avatar Dec 12 '23 23:12 jonhilgart22

This should work

❯ sudo curl -o /usr/local/bin/cog -L "https://github.com/replicate/cog/releases/download/v0.9.0-beta11/default.cog_darwin_arm64"

jonhilgart22 avatar Dec 12 '23 23:12 jonhilgart22

@jonhilgart22

sudo cog predict -i prompt='mona lisa eating ice cream' -i seed=4 -i [email protected] -i auto_depth=True -i ddim_steps=28
/usr/local/bin/cog: 1: Syntax error: "(" unexpected

alexblattner avatar Dec 25 '23 14:12 alexblattner

That's weird. Looks like something installed wrongly. The official instructions are as follows:

sudo curl -o /usr/local/bin/cog -L "https://github.com/replicate/cog/releases/latest/download/cog_$(uname -s)_$(uname -m)"
sudo chmod +x /usr/local/bin/cog

Alternatively, try sudo rm /usr/local/bin/cog; brew install cog

yorickvP avatar Jan 10 '24 10:01 yorickvP