Skip to content

Reliably uploading local files as inputs #396

@enzokro

Description

@enzokro

Hi everyone,

I'm struggling a bit with uploading/running local files to a hosted model. I am following the python instructions on this page: Input Files.

So far I have the input argument in my model's predict signature set to type of cog.Path. Next, I'll process my local file as so: contents = open("my_file.pdf", "rb").

But when I try sending that _io.BufferedReader as part of replicate.run("model_name", input={"file": contents}), it seems that only an empty file goes through. It's definitely not a Path that's arriving to the function.

The main question: what exactly happens to this buffered reader when it's sent to the model from a local file? How should I be processing the object in the Predictor's predict to appropriately handle this opened reader? Do I need to save it back out to a temp file?

Thanks in advance for the help!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions