Update app.py
Browse files
app.py
CHANGED
|
@@ -156,19 +156,33 @@ def create_ui():
|
|
| 156 |
# Main interface function
|
| 157 |
@spaces.GPU()
|
| 158 |
def main_interface(user_prompt, image=None, audio=None, voice_only=False, websearch=False):
|
|
|
|
| 159 |
vqa_model.to(device='cuda', dtype=torch.bfloat16)
|
| 160 |
tts_model.to("cuda")
|
| 161 |
unet.to("cuda")
|
| 162 |
image_pipe.to("cuda")
|
| 163 |
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
if voice_only:
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
else:
|
| 170 |
return response, None
|
| 171 |
|
|
|
|
| 172 |
# Launch the UI
|
| 173 |
demo = create_ui()
|
| 174 |
demo.launch()
|
|
|
|
| 156 |
# Main interface function
|
| 157 |
@spaces.GPU()
|
| 158 |
def main_interface(user_prompt, image=None, audio=None, voice_only=False, websearch=False):
|
| 159 |
+
print("Starting main_interface function")
|
| 160 |
vqa_model.to(device='cuda', dtype=torch.bfloat16)
|
| 161 |
tts_model.to("cuda")
|
| 162 |
unet.to("cuda")
|
| 163 |
image_pipe.to("cuda")
|
| 164 |
|
| 165 |
+
print(f"user_prompt: {user_prompt}, image: {image}, audio: {audio}, voice_only: {voice_only}, websearch: {websearch}")
|
| 166 |
+
|
| 167 |
+
try:
|
| 168 |
+
response = handle_input(user_prompt, image=image, audio=audio, websearch=websearch)
|
| 169 |
+
print("handle_input function executed successfully")
|
| 170 |
+
except Exception as e:
|
| 171 |
+
print(f"Error in handle_input: {e}")
|
| 172 |
+
response = "Error occurred during processing."
|
| 173 |
|
| 174 |
if voice_only:
|
| 175 |
+
try:
|
| 176 |
+
audio_output = play_voice_output(response)
|
| 177 |
+
print("play_voice_output function executed successfully")
|
| 178 |
+
return "Response generated.", audio_output
|
| 179 |
+
except Exception as e:
|
| 180 |
+
print(f"Error in play_voice_output: {e}")
|
| 181 |
+
return "Error occurred during voice output.", None
|
| 182 |
else:
|
| 183 |
return response, None
|
| 184 |
|
| 185 |
+
|
| 186 |
# Launch the UI
|
| 187 |
demo = create_ui()
|
| 188 |
demo.launch()
|