Update src/app/model.py
Browse files- src/app/model.py +5 -0
src/app/model.py
CHANGED
@@ -3,6 +3,7 @@ import sys
|
|
3 |
import subprocess
|
4 |
from typing import Optional
|
5 |
from PIL import Image
|
|
|
6 |
import spaces
|
7 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
8 |
|
@@ -51,6 +52,10 @@ def run_example(
|
|
51 |
str: The parsed answer generated by the model.
|
52 |
"""
|
53 |
try:
|
|
|
|
|
|
|
|
|
54 |
# If there is no text input, use the task prompt as the prompt
|
55 |
prompt = task_prompt if text_input is None else task_prompt + text_input
|
56 |
|
|
|
3 |
import subprocess
|
4 |
from typing import Optional
|
5 |
from PIL import Image
|
6 |
+
import gradio as gr
|
7 |
import spaces
|
8 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
9 |
|
|
|
52 |
str: The parsed answer generated by the model.
|
53 |
"""
|
54 |
try:
|
55 |
+
# Check if image is None
|
56 |
+
if image is None:
|
57 |
+
raise gr.Error("Please provide an image.")
|
58 |
+
|
59 |
# If there is no text input, use the task prompt as the prompt
|
60 |
prompt = task_prompt if text_input is None else task_prompt + text_input
|
61 |
|