ruslanmv commited on
Commit
d4ba9d9
·
1 Parent(s): 883cc41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -19,7 +19,7 @@ from transformers import AutoProcessor, LlavaForConditionalGeneration
19
  from transformers import BitsAndBytesConfig
20
  import torch
21
  from huggingface_hub import InferenceClient
22
-
23
  IS_SPACES_ZERO = os.environ.get("SPACES_ZERO_GPU", "0") == "1"
24
  IS_SPACE = os.environ.get("SPACE_ID", None) is not None
25
 
@@ -119,7 +119,6 @@ def find_nearby(place=None):
119
  print("The 5 closest locations are:\n")
120
  print(closest_hotels)
121
  return closest_hotels
122
-
123
  @spaces.GPU
124
  # Define the respond function
125
  def search_hotel(place=None):
@@ -142,11 +141,9 @@ def search_hotel(place=None):
142
  response = requests.get(image_url, verify=False)
143
  response.raise_for_status()
144
  img = Image.open(BytesIO(response.content))
145
-
146
  prompt = "USER: <image>\nAnalyze this image. Give me feedback on whether this hotel is worth visiting based on the picture. Provide a summary review.\nASSISTANT:"
147
  outputs = pipe_image_to_text(img, prompt=prompt, generate_kwargs={"max_new_tokens": 200})
148
  description = outputs[0]["generated_text"].split("\nASSISTANT:")[-1].strip()
149
-
150
  description_data.append({'hotel_name': hotel_name, 'hotel_id': hotel_id, 'image': img, 'description': description})
151
  except (requests.RequestException, UnidentifiedImageError):
152
  print(f"Skipping image at URL: {image_url}")
@@ -253,7 +250,6 @@ def llm_results(description_df):
253
  conversation = [[{"text": "Based on your search...", "files": []}, {"text": f"**My recommendation:** {result}", "files": []}]]
254
  return conversation
255
 
256
- @spaces.GPU
257
  def chatbot_response(user_input, conversation):
258
  bot_initial_message = {
259
  "text": f"Looking for hotels in {user_input}...",
 
19
  from transformers import BitsAndBytesConfig
20
  import torch
21
  from huggingface_hub import InferenceClient
22
+ import spaces
23
  IS_SPACES_ZERO = os.environ.get("SPACES_ZERO_GPU", "0") == "1"
24
  IS_SPACE = os.environ.get("SPACE_ID", None) is not None
25
 
 
119
  print("The 5 closest locations are:\n")
120
  print(closest_hotels)
121
  return closest_hotels
 
122
  @spaces.GPU
123
  # Define the respond function
124
  def search_hotel(place=None):
 
141
  response = requests.get(image_url, verify=False)
142
  response.raise_for_status()
143
  img = Image.open(BytesIO(response.content))
 
144
  prompt = "USER: <image>\nAnalyze this image. Give me feedback on whether this hotel is worth visiting based on the picture. Provide a summary review.\nASSISTANT:"
145
  outputs = pipe_image_to_text(img, prompt=prompt, generate_kwargs={"max_new_tokens": 200})
146
  description = outputs[0]["generated_text"].split("\nASSISTANT:")[-1].strip()
 
147
  description_data.append({'hotel_name': hotel_name, 'hotel_id': hotel_id, 'image': img, 'description': description})
148
  except (requests.RequestException, UnidentifiedImageError):
149
  print(f"Skipping image at URL: {image_url}")
 
250
  conversation = [[{"text": "Based on your search...", "files": []}, {"text": f"**My recommendation:** {result}", "files": []}]]
251
  return conversation
252
 
 
253
  def chatbot_response(user_input, conversation):
254
  bot_initial_message = {
255
  "text": f"Looking for hotels in {user_input}...",