diamantrsd commited on
Commit
bc2751f
1 Parent(s): 4244f2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -9,16 +9,13 @@ model = BlipForConditionalGeneration.from_pretrained(model_id)
9
  processor = BlipProcessor.from_pretrained(model_id)
10
 
11
  def launch(input_image):
12
- # Convert Gradio image input to PIL Image
13
- image = Image.fromarray(input_image)
14
-
15
- # Process the image and generate a caption
16
  inputs = processor(image, return_tensors="pt")
17
  out = model.generate(**inputs)
18
  caption = processor.decode(out[0], skip_special_tokens=True)
19
-
20
  return caption
21
 
 
22
  iface = gr.Interface(
23
  launch,
24
  inputs=gr.inputs.Image(type="pil"), # Set input type to image
 
9
  processor = BlipProcessor.from_pretrained(model_id)
10
 
11
  def launch(input_image):
12
+ image = input_image.convert('RGB')
 
 
 
13
  inputs = processor(image, return_tensors="pt")
14
  out = model.generate(**inputs)
15
  caption = processor.decode(out[0], skip_special_tokens=True)
 
16
  return caption
17
 
18
+
19
  iface = gr.Interface(
20
  launch,
21
  inputs=gr.inputs.Image(type="pil"), # Set input type to image