VQGAN-CLIP icon indicating copy to clipboard operation
VQGAN-CLIP copied to clipboard

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

Open abrichr opened this issue 3 years ago • 0 comments

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:

abrichr avatar Jan 15 '22 01:01 abrichr