darshan8950 commited on
Commit
ca3ca09
·
1 Parent(s): 1b4b059

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -10,8 +10,10 @@ model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_
10
 
11
  # Define the input and output functions for Gradio
12
  def generate_caption(image_file):
13
- # Load the image from the file path
14
- raw_image = Image.open(image_file).convert("RGB")
 
 
15
 
16
  # Preprocess the image using the Blip-Caption model's visual processors
17
  image = vis_processors["eval"](raw_image).unsqueeze(0)
 
10
 
11
  # Define the input and output functions for Gradio
12
  def generate_caption(image_file):
13
+ image = cv2.imdecode(image_file.read(), cv2.IMREAD_COLOR)
14
+
15
+ # Preprocess the image using the Blip-Caption model's visual processors
16
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
17
 
18
  # Preprocess the image using the Blip-Caption model's visual processors
19
  image = vis_processors["eval"](raw_image).unsqueeze(0)