cosmo3769 commited on
Commit
eadc99d
1 Parent(s): f79530d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -13,14 +13,21 @@ def process_image(image, prompt):
13
  # Process the image and prompt using the processor
14
  inputs = processor(image.convert("RGB"), prompt, return_tensors="pt")
15
 
16
- # Generate output from the model
17
- output = model.generate(**inputs, max_new_tokens=20)
18
 
19
- # Decode and return the output
20
- decoded_output = processor.decode(output[0], skip_special_tokens=True)
21
-
22
- # Return the answer (exclude the prompt part from output)
23
- return decoded_output[len(prompt):]
 
 
 
 
 
 
 
24
 
25
  # Define the Gradio interface
26
  inputs = [
 
13
  # Process the image and prompt using the processor
14
  inputs = processor(image.convert("RGB"), prompt, return_tensors="pt")
15
 
16
+ # Print the inputs to debug
17
+ print("Processor outputs:", inputs)
18
 
19
+ try:
20
+ # Generate output from the model
21
+ output = model.generate(**inputs, max_new_tokens=20)
22
+
23
+ # Decode and return the output
24
+ decoded_output = processor.decode(output[0], skip_special_tokens=True)
25
+
26
+ # Return the answer (exclude the prompt part from output)
27
+ return decoded_output[len(prompt):]
28
+ except IndexError as e:
29
+ print(f"IndexError: {e}")
30
+ return "An error occurred during processing."
31
 
32
  # Define the Gradio interface
33
  inputs = [