Update app.py
Browse files
app.py
CHANGED
|
@@ -99,10 +99,10 @@ def analyze_construction_media(media):
|
|
| 99 |
if file_type in ['jpg', 'jpeg', 'png', 'gif']:
|
| 100 |
# Handle image
|
| 101 |
try:
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
|
| 107 |
messages = [
|
| 108 |
{
|
|
@@ -192,7 +192,6 @@ def analyze_construction_media(media):
|
|
| 192 |
logger.error(f"Error during analysis: {str(e)}")
|
| 193 |
logger.error(traceback.format_exc())
|
| 194 |
return [("Analysis error", f"Error during analysis: {str(e)}")]
|
| 195 |
-
|
| 196 |
|
| 197 |
def chat_about_image(message, chat_history):
|
| 198 |
try:
|
|
|
|
| 99 |
if file_type in ['jpg', 'jpeg', 'png', 'gif']:
|
| 100 |
# Handle image
|
| 101 |
try:
|
| 102 |
+
with Image.open(file_path) as image:
|
| 103 |
+
logger.info(f"Successfully opened image: {file_path}")
|
| 104 |
+
resized_image = resize_image(image)
|
| 105 |
+
image_data_url = f"data:image/png;base64,{encode_image(resized_image)}"
|
| 106 |
|
| 107 |
messages = [
|
| 108 |
{
|
|
|
|
| 192 |
logger.error(f"Error during analysis: {str(e)}")
|
| 193 |
logger.error(traceback.format_exc())
|
| 194 |
return [("Analysis error", f"Error during analysis: {str(e)}")]
|
|
|
|
| 195 |
|
| 196 |
def chat_about_image(message, chat_history):
|
| 197 |
try:
|