memegpt commited on
Commit
1aa9781
1 Parent(s): 32bb55d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
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 launch(input_image):
14
- image = Image.open(BytesIO(input_image)).convert('RGB')
 
 
 
 
 
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")