dogutcu commited on
Commit
288a5fd
·
verified ·
1 Parent(s): 02e8cce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -95,22 +95,25 @@ def query_model(question):
95
  return "Could not find specific information. Please refine your question."
96
  response = generate_response(question, relevant_segment)
97
  return response
 
98
 
99
- with Image.open("composting.jpg") as img:
100
- # Print the current size of the image
101
- print("Original size:", img.size)
102
-
103
- # Define the new size
104
- new_size = (int(img.size[0] * 0.5), int(img.size[1] * 0.5)) # for example, reducing size by 50%
105
-
106
- # Resize the image
107
- resized_img = img.resize(new_size, Image.ANTIALIAS)
108
-
109
- # Print the new size of the image
110
- print("Resized size:", resized_img.size)
111
-
112
- # Save the resized image
113
- resized_img.save("composting_resized.jpg")
 
 
114
 
115
  # Define the welcome message and specific topics the chatbot can provide information about
116
  welcome_message = """
 
95
  return "Could not find specific information. Please refine your question."
96
  response = generate_response(question, relevant_segment)
97
  return response
98
+
99
 
100
+ # Path to the image
101
+ image_path = "composting.jpg"
102
+ resized_image_path = "composting_resized.jpg"
103
+
104
+ # Check if the image file exists
105
+ if os.path.exists(image_path):
106
+ # Open and resize the image
107
+ with Image.open(image_path) as img:
108
+ # Define the new size (e.g., reducing size by 50%)
109
+ new_size = (int(img.size[0] * 0.5), int(img.size[1] * 0.5))
110
+ # Resize the image
111
+ resized_img = img.resize(new_size, Image.ANTIALIAS)
112
+ # Save the resized image
113
+ resized_img.save(resized_image_path)
114
+ else:
115
+ print(f"Error: The image file '{image_path}' was not found.")
116
+ exit(1)
117
 
118
  # Define the welcome message and specific topics the chatbot can provide information about
119
  welcome_message = """