Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,13 @@ model_id = "Salesforce/blip-image-captioning-base"
|
|
10 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
11 |
processor = BlipProcessor.from_pretrained(model_id)
|
12 |
|
13 |
-
def
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
#inputsData = data.pop("inputs", data)
|
16 |
# decode base64 image to PIL
|
17 |
inputs = processor(image, return_tensors="pt")
|
|
|
10 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
11 |
processor = BlipProcessor.from_pretrained(model_id)
|
12 |
|
13 |
+
def decode_base64_image(image_string):
|
14 |
+
base64_image = base64.b64decode(image_string)
|
15 |
+
buffer = BytesIO(base64_image)
|
16 |
+
return Image.open(buffer)
|
17 |
+
|
18 |
+
def launch(input_b64):
|
19 |
+
image = decode_base64_image(input_b64)
|
20 |
#inputsData = data.pop("inputs", data)
|
21 |
# decode base64 image to PIL
|
22 |
inputs = processor(image, return_tensors="pt")
|