Tech-Meld commited on
Commit
13bac9e
1 Parent(s): deff16b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -30,16 +30,17 @@ def modify_caption(caption: str) -> str:
30
  return re.sub(pattern, replace_fn, caption, count=1, flags=re.IGNORECASE)
31
 
32
  def create_captions_rich(images):
33
- """
34
- Generates captions for input images.
35
- Args:
36
- images (list): List of image file paths to generate captions for.
37
- Returns:
38
- list: List of captions, one for each input image.
39
- """
40
  captions = []
41
  for image_path in images:
42
  try:
 
43
  image = Image.open(image_path).convert("RGB")
44
  prompt = "caption en"
45
  model_inputs = processor(text=prompt, images=image, return_tensors="pt").to("cpu")
@@ -56,6 +57,7 @@ def create_captions_rich(images):
56
  captions.append(f"Error processing image: {e}")
57
  return captions
58
 
 
59
  css = """
60
  #mkd {
61
  height: 500px;
 
30
  return re.sub(pattern, replace_fn, caption, count=1, flags=re.IGNORECASE)
31
 
32
  def create_captions_rich(images):
33
+ # Debugging: Print out the type of 'images'
34
+ print(f"Type of 'images': {type(images)}")
35
+ if isinstance(images, tuple):
36
+ print("Received a tuple, expected a file-like object.")
37
+ # If it's a tuple, you can try accessing the first element as an example
38
+ print(f"Type of 'images[0]': {type(images[0])}")
39
+
40
  captions = []
41
  for image_path in images:
42
  try:
43
+ # If 'images' is a tuple, you might need to modify this part to extract the image file correctly
44
  image = Image.open(image_path).convert("RGB")
45
  prompt = "caption en"
46
  model_inputs = processor(text=prompt, images=image, return_tensors="pt").to("cpu")
 
57
  captions.append(f"Error processing image: {e}")
58
  return captions
59
 
60
+
61
  css = """
62
  #mkd {
63
  height: 500px;