darshan8950 commited on
Commit
b21b6cd
·
1 Parent(s): b37e35e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -5,7 +5,7 @@ from lavis.models import load_model_and_preprocess
5
 
6
 
7
  # Load the Blip-Caption model
8
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
9
  model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_type="base_coco", is_eval=True, device=device)
10
 
11
  # Define the input and output functions for Gradio
@@ -14,7 +14,7 @@ def generate_caption(image_file):
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).to(device)
18
 
19
  # Generate captions using the Blip-Caption model
20
  captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)
 
5
 
6
 
7
  # Load the Blip-Caption model
8
+
9
  model, vis_processors, _ = load_model_and_preprocess(name="blip_caption", model_type="base_coco", is_eval=True, device=device)
10
 
11
  # Define the input and output functions for Gradio
 
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)
18
 
19
  # Generate captions using the Blip-Caption model
20
  captions = model.generate({"image": image}, use_nucleus_sampling=True, num_captions=5)