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

Documentation typo? Input and output types > Path() #1458

Closed
mcwongmc opened this issue Dec 30, 2023 · 1 comment · Fixed by #1464
Closed

Documentation typo? Input and output types > Path() #1458

mcwongmc opened this issue Dec 30, 2023 · 1 comment · Fixed by #1464

Comments

@mcwongmc
Copy link

mcwongmc commented Dec 30, 2023

Documentation link:
https://github.com/replicate/cog/blob/main/docs/python.md#path

Issue:
Should the command be "upscaled_image.save(output_path)" instead of "upscaled_image.save(output)" ?
I am a a bit confused by where does the "output" varaible comes from.
Thanks for clarifying.

Tutorial example code:

import tempfile
from cog import BasePredictor, Input, Path

class Predictor(BasePredictor):
def predict(self, image: Path = Input(description="Image to enlarge")) -> Path:
upscaled_image = do_some_processing(image)

      # To output `cog.Path` objects the file needs to exist, so create a temporary file first.
      # This file will automatically be deleted by Cog after it has been returned.
      output_path = Path(tempfile.mkdtemp()) / "upscaled.png"
      upscaled_image.save(output)
      return Path(output_path)

@zeke
Copy link
Member

zeke commented Jan 2, 2024

Hi @wongshumhei. The code in that example is pseudocode, but yes you're correct that it should be using output_path instead of output. I've opened a PR to correct that here: #1464

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

Successfully merging a pull request may close this issue.

2 participants