Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import requests
|
|
| 4 |
import json
|
| 5 |
import base64
|
| 6 |
import re
|
| 7 |
-
from PIL import Image
|
| 8 |
from io import BytesIO
|
| 9 |
|
| 10 |
GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
|
@@ -60,6 +60,8 @@ def strip_latex(text):
|
|
| 60 |
|
| 61 |
|
| 62 |
def image_to_base64(pil_image):
|
|
|
|
|
|
|
| 63 |
buffered = BytesIO()
|
| 64 |
pil_image.save(buffered, format="PNG")
|
| 65 |
return base64.b64encode(buffered.getvalue()).decode("utf-8")
|
|
|
|
| 4 |
import json
|
| 5 |
import base64
|
| 6 |
import re
|
| 7 |
+
from PIL import Image, ImageOps
|
| 8 |
from io import BytesIO
|
| 9 |
|
| 10 |
GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def image_to_base64(pil_image):
|
| 63 |
+
# Flip horizontally to correct webcam mirror effect
|
| 64 |
+
pil_image = ImageOps.mirror(pil_image)
|
| 65 |
buffered = BytesIO()
|
| 66 |
pil_image.save(buffered, format="PNG")
|
| 67 |
return base64.b64encode(buffered.getvalue()).decode("utf-8")
|