nerdyrodent / VQGAN-CLIP

Just playing with getting VQGAN+CLIP running locally, rather than having to use colab.
Other
2.59k stars 428 forks source link

400 Bad Request when passing in url as image argument via HTTP #113

Open abrichr opened 2 years ago

abrichr commented 2 years ago

When running the model via docker run, POSTing to the endpoint with the image parameter set to a url (with or without the leading @) returns HTTP 400:

{"message": "Could not convert file input image to Path"}

Changing the type to str resolves the issue. Also, the following import is missing:

from urllib.request import urlopen

Edit: we also need to check for an empty string:

--- a/predict.py
+++ b/predict.py
@@ -140,7 +140,7 @@ class Predictor(cog.Predictor):
         toksX, toksY = self.args.size[0] // f, self.args.size[1] // f
         sideX, sideY = toksX * f, toksY * f

-        if image is not None:
+        if image:
             self.args.init_image = str(image)
             self.args.step_size = 0.25
             if "http" in self.args.init_image: