Update project_model.py
Browse files- project_model.py +8 -0
project_model.py
CHANGED
|
@@ -55,6 +55,7 @@ class VisualQAState:
|
|
| 55 |
"""
|
| 56 |
def __init__(self):
|
| 57 |
self.current_image: Image.Image = None
|
|
|
|
| 58 |
self.visual_context: str = ""
|
| 59 |
self.message_history = []
|
| 60 |
|
|
@@ -64,6 +65,7 @@ class VisualQAState:
|
|
| 64 |
Resets context and starts new message history.
|
| 65 |
"""
|
| 66 |
self.current_image = image
|
|
|
|
| 67 |
self.visual_context = visual_context
|
| 68 |
self.message_history = [
|
| 69 |
{
|
|
@@ -186,8 +188,14 @@ def process_inputs(
|
|
| 186 |
enable_tts: bool = True
|
| 187 |
):
|
| 188 |
if image:
|
|
|
|
| 189 |
visual_context, annotated_image = generate_visual_context(image)
|
|
|
|
|
|
|
| 190 |
session.reset(image, visual_context)
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
if audio_path:
|
| 193 |
audio_text = whisper_pipe(audio_path)["text"]
|
|
|
|
| 55 |
"""
|
| 56 |
def __init__(self):
|
| 57 |
self.current_image: Image.Image = None
|
| 58 |
+
self.annotated_image: Image.Image = None
|
| 59 |
self.visual_context: str = ""
|
| 60 |
self.message_history = []
|
| 61 |
|
|
|
|
| 65 |
Resets context and starts new message history.
|
| 66 |
"""
|
| 67 |
self.current_image = image
|
| 68 |
+
self.annotated_image = annotated_image
|
| 69 |
self.visual_context = visual_context
|
| 70 |
self.message_history = [
|
| 71 |
{
|
|
|
|
| 188 |
enable_tts: bool = True
|
| 189 |
):
|
| 190 |
if image:
|
| 191 |
+
# Generate visual context and annotated image
|
| 192 |
visual_context, annotated_image = generate_visual_context(image)
|
| 193 |
+
|
| 194 |
+
# Reset session with the current image and visual context
|
| 195 |
session.reset(image, visual_context)
|
| 196 |
+
|
| 197 |
+
# Set annotated image to session for future use (e.g., in follow-up)
|
| 198 |
+
session.annotated_image = annotated_image
|
| 199 |
|
| 200 |
if audio_path:
|
| 201 |
audio_text = whisper_pipe(audio_path)["text"]
|