Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ vision_model = AutoModelForCausalLM.from_pretrained(
|
|
| 47 |
vision_processor = AutoProcessor.from_pretrained(VISION_MODEL_ID, trust_remote_code=True)
|
| 48 |
|
| 49 |
# Helper functions
|
| 50 |
-
@spaces.GPU
|
| 51 |
def stream_text_chat(message, history, system_prompt, temperature=0.8, max_new_tokens=1024, top_p=1.0, top_k=20):
|
| 52 |
conversation = [{"role": "system", "content": system_prompt}]
|
| 53 |
for prompt, answer in history:
|
|
@@ -78,7 +78,7 @@ def stream_text_chat(message, history, system_prompt, temperature=0.8, max_new_t
|
|
| 78 |
buffer = ""
|
| 79 |
for new_text in streamer:
|
| 80 |
buffer += new_text
|
| 81 |
-
yield buffer
|
| 82 |
|
| 83 |
@spaces.GPU # Add this decorator
|
| 84 |
def process_vision_query(image, text_input):
|
|
@@ -97,6 +97,7 @@ def process_vision_query(image, text_input):
|
|
| 97 |
response = vision_processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 98 |
return response
|
| 99 |
|
|
|
|
| 100 |
with gr.Blocks() as demo:
|
| 101 |
gr.HTML(TITLE)
|
| 102 |
gr.Markdown(DESCRIPTION)
|
|
|
|
| 47 |
vision_processor = AutoProcessor.from_pretrained(VISION_MODEL_ID, trust_remote_code=True)
|
| 48 |
|
| 49 |
# Helper functions
|
| 50 |
+
@spaces.GPU
|
| 51 |
def stream_text_chat(message, history, system_prompt, temperature=0.8, max_new_tokens=1024, top_p=1.0, top_k=20):
|
| 52 |
conversation = [{"role": "system", "content": system_prompt}]
|
| 53 |
for prompt, answer in history:
|
|
|
|
| 78 |
buffer = ""
|
| 79 |
for new_text in streamer:
|
| 80 |
buffer += new_text
|
| 81 |
+
yield history + [[message, buffer]]
|
| 82 |
|
| 83 |
@spaces.GPU # Add this decorator
|
| 84 |
def process_vision_query(image, text_input):
|
|
|
|
| 97 |
response = vision_processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 98 |
return response
|
| 99 |
|
| 100 |
+
# Update the Gradio interface part
|
| 101 |
with gr.Blocks() as demo:
|
| 102 |
gr.HTML(TITLE)
|
| 103 |
gr.Markdown(DESCRIPTION)
|