Spaces:
Running
on
Zero
Running
on
Zero
visheratin
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,6 +45,11 @@ def cached_vision_process(image, max_crops, num_tokens):
|
|
45 |
def answer_question(image, question, max_crops, num_tokens):
|
46 |
prompt = f"""<|im_start|>user
|
47 |
<image>
|
|
|
|
|
|
|
|
|
|
|
48 |
{question}<|im_end|>
|
49 |
<|im_start|>assistant
|
50 |
"""
|
@@ -65,11 +70,15 @@ def answer_question(image, question, max_crops, num_tokens):
|
|
65 |
thread.start()
|
66 |
|
67 |
buffer = ""
|
|
|
68 |
for new_text in streamer:
|
|
|
|
|
|
|
|
|
69 |
buffer += new_text
|
70 |
-
print(buffer)
|
71 |
if len(buffer) > 1:
|
72 |
-
yield buffer
|
73 |
|
74 |
|
75 |
with gr.Blocks() as demo:
|
|
|
45 |
def answer_question(image, question, max_crops, num_tokens):
|
46 |
prompt = f"""<|im_start|>user
|
47 |
<image>
|
48 |
+
{question}<|im_end|>
|
49 |
+
<|im_start|>assistant
|
50 |
+
"""
|
51 |
+
replace_prompt = f"""<|im_start|>user
|
52 |
+
|
53 |
{question}<|im_end|>
|
54 |
<|im_start|>assistant
|
55 |
"""
|
|
|
70 |
thread.start()
|
71 |
|
72 |
buffer = ""
|
73 |
+
output_started = False
|
74 |
for new_text in streamer:
|
75 |
+
if not output_started:
|
76 |
+
if "<assistant>" in new_text:
|
77 |
+
output_started = True
|
78 |
+
continue
|
79 |
buffer += new_text
|
|
|
80 |
if len(buffer) > 1:
|
81 |
+
yield buffer
|
82 |
|
83 |
|
84 |
with gr.Blocks() as demo:
|