Spaces:
Running
on
Zero
Running
on
Zero
visheratin
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -43,6 +43,12 @@ def cached_vision_process(image, max_crops, num_tokens):
|
|
43 |
|
44 |
@spaces.GPU(duration=20)
|
45 |
def answer_question(image, question, max_crops, num_tokens, sample, temperature, top_k):
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
prompt = f"""<|im_start|>user
|
47 |
<image>
|
48 |
{question}<|im_end|>
|
@@ -110,4 +116,4 @@ with gr.Blocks() as demo:
|
|
110 |
submit.click(answer_question, [img, prompt, max_crops, num_tokens, sample, temperature, top_k], output)
|
111 |
prompt.submit(answer_question, [img, prompt, max_crops, num_tokens, sample, temperature, top_k], output)
|
112 |
|
113 |
-
demo.queue().launch()
|
|
|
43 |
|
44 |
@spaces.GPU(duration=20)
|
45 |
def answer_question(image, question, max_crops, num_tokens, sample, temperature, top_k):
|
46 |
+
if question is None or question.strip() == "":
|
47 |
+
yield "Please ask a question"
|
48 |
+
return
|
49 |
+
if image is None:
|
50 |
+
yield "Please upload an image"
|
51 |
+
return
|
52 |
prompt = f"""<|im_start|>user
|
53 |
<image>
|
54 |
{question}<|im_end|>
|
|
|
116 |
submit.click(answer_question, [img, prompt, max_crops, num_tokens, sample, temperature, top_k], output)
|
117 |
prompt.submit(answer_question, [img, prompt, max_crops, num_tokens, sample, temperature, top_k], output)
|
118 |
|
119 |
+
demo.queue().launch(debug=True)
|