Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = [
|