Hady Rashwan commited on
Commit
c0f3fbd
·
1 Parent(s): 5b4c4b1

move to thenlper/gte-small

Browse files
Files changed (4) hide show
  1. 50_weather_quotes.txt +0 -15
  2. app.py +55 -4
  3. orginal_50_weather_quotes.txt +0 -104
  4. setup_db.py +1 -1
50_weather_quotes.txt CHANGED
@@ -2,7 +2,6 @@
2
 
3
  2. “Weather forecast for tonight: dark.” — George Carlin
4
 
5
- Related 50 Currency Quotes About Standardized Money
6
  3. “I love the rain. It’s my favorite weather.” — Kristen Wiig
7
 
8
  4. “I love being in a city with great weather.” — Sean McVay
@@ -19,9 +18,6 @@ Related 50 Currency Quotes About Standardized Money
19
 
20
  10. “A change in the weather is sufficient to recreate the world and ourselves.” — Marcel Proust
21
 
22
- Stormy weather quotes
23
- The storm is not just a metaphor for extreme weather but also for trying times. The quotes in this section serve as an excellent example of this.
24
-
25
  11. “If you want to see the sunshine, you have to weather the storm.” — Frank Lane
26
 
27
  12. “Faith is not a delicate flower which would wither away under the slightest stormy weather.” — Mahatma Gandhi
@@ -42,10 +38,6 @@ The storm is not just a metaphor for extreme weather but also for trying times.
42
 
43
  20. “I have seen many storms in my life. Most storms have caught me by surprise, so I had to learn very quickly to look further and understand that I am not capable of controlling the weather, to exercise the art of patience, and to respect the fury of nature.” — Paulo Coelho
44
 
45
- Related 50 Expectation Quotes To Fuel Your Mind And Spirit
46
- Good weather quotes
47
- Make use of the best weather quotes to appreciate good weather. Go nowhere else; find them right here in this section.
48
-
49
  21. “He was sunshine most always-I mean, he made it seem like good weather.” — Mark Twain
50
 
51
  22. “My wife Danielle and I love traveling, different cultures, and good weather.” — Gary Lineker
@@ -66,9 +58,6 @@ Make use of the best weather quotes to appreciate good weather. Go nowhere else;
66
 
67
  30. “And so we stayed out in the garden of the old house until we couldn’t kick a ball, laughing in the gathering twilight, making the most of the good weather and all the days that were left, our little game watched only by next door’s cat, and every star in the heavens.” — Tony Parsons
68
 
69
- Bad weather quotes
70
- When the weather doesn’t go your way, it’s sometimes called “bad weather.” These weather quotes provide insight into the weather-related views of those around us.
71
-
72
  31. “Bad weather always looks worse through a window.” — Tom Lehrer
73
 
74
  32. “Concrete is, essentially, the color of bad weather.” — William Hamilton
@@ -81,7 +70,6 @@ When the weather doesn’t go your way, it’s sometimes called “bad weather.
81
 
82
  36. “We may have bad weather in Ireland, but the sun shines in the hearts of the people, and that keeps us all warm.” — Marianne Williamson
83
 
84
- Related 25 Thomas Mann Quotes About The Nature Of The Soul
85
  37. “As a mountain walker, one of the most frustrating mistakes one can make in bad weather is taking the wrong route down.” — Dominic Grieve
86
 
87
  38. “Everyone knows, at some level, that the sharp line between “good weather” and “bad weather” is a fiction, that we need rain as surely as we need sun.” — Bill McKibben
@@ -90,9 +78,6 @@ Related 25 Thomas Mann Quotes About The Nature Of The Soul
90
 
91
  40. “We often hear of bad weather, but in reality no weather is bad. It is all delightful, though in different ways. Some weather may be bad for farmers or crops, but for man, all kinds are good. Sunshine is delicious, rain is refreshing, wind braces us up, snow is exhilarating.” — John Lubbock
92
 
93
- Some more weather quotes
94
- Here are a few other interesting weather quotes.
95
-
96
  41. “I’m not a fan of cold weather.” — Ravyn Lenae
97
 
98
  42. “I like the cold weather. It means you get work done.” — Noam Chomsky
 
2
 
3
  2. “Weather forecast for tonight: dark.” — George Carlin
4
 
 
5
  3. “I love the rain. It’s my favorite weather.” — Kristen Wiig
6
 
7
  4. “I love being in a city with great weather.” — Sean McVay
 
18
 
19
  10. “A change in the weather is sufficient to recreate the world and ourselves.” — Marcel Proust
20
 
 
 
 
21
  11. “If you want to see the sunshine, you have to weather the storm.” — Frank Lane
22
 
23
  12. “Faith is not a delicate flower which would wither away under the slightest stormy weather.” — Mahatma Gandhi
 
38
 
39
  20. “I have seen many storms in my life. Most storms have caught me by surprise, so I had to learn very quickly to look further and understand that I am not capable of controlling the weather, to exercise the art of patience, and to respect the fury of nature.” — Paulo Coelho
40
 
 
 
 
 
41
  21. “He was sunshine most always-I mean, he made it seem like good weather.” — Mark Twain
42
 
43
  22. “My wife Danielle and I love traveling, different cultures, and good weather.” — Gary Lineker
 
58
 
59
  30. “And so we stayed out in the garden of the old house until we couldn’t kick a ball, laughing in the gathering twilight, making the most of the good weather and all the days that were left, our little game watched only by next door’s cat, and every star in the heavens.” — Tony Parsons
60
 
 
 
 
61
  31. “Bad weather always looks worse through a window.” — Tom Lehrer
62
 
63
  32. “Concrete is, essentially, the color of bad weather.” — William Hamilton
 
70
 
71
  36. “We may have bad weather in Ireland, but the sun shines in the hearts of the people, and that keeps us all warm.” — Marianne Williamson
72
 
 
73
  37. “As a mountain walker, one of the most frustrating mistakes one can make in bad weather is taking the wrong route down.” — Dominic Grieve
74
 
75
  38. “Everyone knows, at some level, that the sharp line between “good weather” and “bad weather” is a fiction, that we need rain as surely as we need sun.” — Bill McKibben
 
78
 
79
  40. “We often hear of bad weather, but in reality no weather is bad. It is all delightful, though in different ways. Some weather may be bad for farmers or crops, but for man, all kinds are good. Sunshine is delicious, rain is refreshing, wind braces us up, snow is exhilarating.” — John Lubbock
80
 
 
 
 
81
  41. “I’m not a fan of cold weather.” — Ravyn Lenae
82
 
83
  42. “I like the cold weather. It means you get work done.” — Noam Chomsky
app.py CHANGED
@@ -6,6 +6,10 @@ from huggingface_hub import InferenceClient
6
  from sentence_transformers import SentenceTransformer
7
  from supabase import create_client, Client
8
  from dotenv import load_dotenv
 
 
 
 
9
 
10
  # Load environment variables
11
  load_dotenv()
@@ -27,7 +31,21 @@ client = InferenceClient(token=HF_API_KEY)
27
  # Initialize Supabase
28
  supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
29
 
30
- model = SentenceTransformer('all-MiniLM-L6-v2')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  def get_weather(city):
33
  base_url = "http://api.openweathermap.org/data/2.5/weather"
@@ -47,7 +65,31 @@ def get_ai_clothing_suggestion(weather_data):
47
  Humidity: {weather_data['main']['humidity']}%
48
  Wind Speed: {weather_data['wind']['speed']} m/s
49
 
50
- Suggest appropriate clothing to wear, including top, bottom, and any necessary accessories.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  Make sure to stick to hugging faces free response size limit.
52
  """
53
 
@@ -70,7 +112,7 @@ def get_relevant_quote(weather_condition):
70
  response = supabase.rpc("match_quote_embeddings",{
71
  'query_embedding': weather_embedding,
72
  'match_threshold': 0.5,
73
- 'match_count': 1
74
  }).execute()
75
 
76
 
@@ -104,11 +146,20 @@ if st.button("Get Weather and Clothing Suggestion"):
104
  st.subheader("What to Wear (AI Suggestion):")
105
  st.write(clothing_suggestion)
106
  with st.spinner("Finding a relevant quote..."):
107
- quote = get_relevant_quote(f"{main_weather} {description}")
 
 
108
  st.subheader("Quote of the Day:")
109
  st.write(quote)
 
 
110
  else:
111
  st.error("City not found. Please check the spelling and try again.")
112
 
 
 
 
 
 
113
  # Display current date and time
114
  st.sidebar.write(f"Current Date and Time: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
 
6
  from sentence_transformers import SentenceTransformer
7
  from supabase import create_client, Client
8
  from dotenv import load_dotenv
9
+ import base64
10
+ from io import BytesIO
11
+ from PIL import Image
12
+
13
 
14
  # Load environment variables
15
  load_dotenv()
 
31
  # Initialize Supabase
32
  supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
33
 
34
+ model = SentenceTransformer('thenlper/gte-small')
35
+
36
+ def generate_outfit_image(clothing_suggestion):
37
+ prompt = f"A fashion illustration showing an outfit with {clothing_suggestion}. Stylized, colorful, no text."
38
+
39
+ # Generate image using Stable Diffusion via Hugging Face
40
+ image_bytes = client.text_to_image(
41
+ prompt,
42
+ model="stabilityai/stable-diffusion-2-1",
43
+ negative_prompt="blurry, low quality, text, words, labels",
44
+ )
45
+
46
+ # Convert bytes to PIL Image
47
+ image = Image.open(BytesIO(image_bytes))
48
+ return image
49
 
50
  def get_weather(city):
51
  base_url = "http://api.openweathermap.org/data/2.5/weather"
 
65
  Humidity: {weather_data['main']['humidity']}%
66
  Wind Speed: {weather_data['wind']['speed']} m/s
67
 
68
+ Suggest appropriate clothing to wear, including top, bottom.
69
+ Make sure to stick to hugging faces free response size limit.
70
+ """
71
+
72
+ # Using Mistral 7B Instruct model via Hugging Face
73
+ response = client.text_generation(
74
+ prompt,
75
+ model="mistralai/Mistral-7B-Instruct-v0.1",
76
+ max_new_tokens=150,
77
+ temperature=0.7,
78
+ top_k=50,
79
+ top_p=0.95,
80
+ )
81
+
82
+ return response
83
+
84
+ def get_ai_weather_explanation(weather_data):
85
+ prompt = f"""
86
+ Given the following weather conditions:
87
+ Temperature: {weather_data['main']['temp']}°C
88
+ Weather: {weather_data['weather'][0]['main']} ({weather_data['weather'][0]['description']})
89
+ Humidity: {weather_data['main']['humidity']}%
90
+ Wind Speed: {weather_data['wind']['speed']} m/s
91
+
92
+ Give me the description of the weather.
93
  Make sure to stick to hugging faces free response size limit.
94
  """
95
 
 
112
  response = supabase.rpc("match_quote_embeddings",{
113
  'query_embedding': weather_embedding,
114
  'match_threshold': 0.5,
115
+ 'match_count': 5
116
  }).execute()
117
 
118
 
 
146
  st.subheader("What to Wear (AI Suggestion):")
147
  st.write(clothing_suggestion)
148
  with st.spinner("Finding a relevant quote..."):
149
+ weather_description = get_ai_weather_explanation(weather_data)
150
+ quote = get_relevant_quote(f"{weather_description}")
151
+
152
  st.subheader("Quote of the Day:")
153
  st.write(quote)
154
+ st.subheader("Weather description:")
155
+ st.write(weather_description)
156
  else:
157
  st.error("City not found. Please check the spelling and try again.")
158
 
159
+ with st.spinner("Generating outfit image..."):
160
+ outfit_image = generate_outfit_image(clothing_suggestion)
161
+ st.subheader("Outfit Visualization:")
162
+ st.image(outfit_image, caption="AI-generated outfit based on the suggestion")
163
+
164
  # Display current date and time
165
  st.sidebar.write(f"Current Date and Time: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
orginal_50_weather_quotes.txt CHANGED
@@ -1,95 +1,4 @@
1
  50 Weather Quotes for Sunny and Rainy Days
2
- Norbert Juma
3
- By Norbert Juma
4
-
5
- Master quote curator and editor on a mission to inspire
6
-
7
- Published January 5, 2023
8
- Weather quotes offer a fresh and soothing feeling.
9
-
10
- If you are searching for these quotes, we have something to share with you.
11
-
12
- Here, we have arranged the best 50 weather quotes to inspire you.
13
-
14
- Besides, you can also learn about the different components of our weather.
15
-
16
- If interested, please continue reading.
17
-
18
- How is weather formed?
19
- There are six major components of weather. These include:
20
-
21
- Atmospheric pressure
22
- Temperature
23
- Clouds
24
- Humidity
25
- Wind
26
- Rain
27
- If any of these elements change, it results in changing the weather pattern.
28
-
29
- Here, all these factors are briefly discussed.
30
-
31
- Check out these weather balloon quotes for more information!
32
-
33
- Atmospheric pressure
34
- This factor relates to the density and weight of the air.
35
-
36
- With changing atmospheric pressure, the atmosphere could become cooler or warmer.
37
-
38
- This is because the change in air density affects its temperature.
39
-
40
- According to the law of physics, dense air molecules are colder and have less energy.
41
-
42
- Therefore, the high atmospheric weather system brings cooler air.
43
-
44
- Low-pressure systems increase the temperatures.
45
-
46
- Temperature
47
- Temperature refers to the coldness or hotness of the atmosphere.
48
-
49
- The heat absorbed by the sun is retained in our atmosphere, known as the greenhouse effect.
50
-
51
- The overall temperature of our atmosphere depends on the duration of the day and the intensity of the sunlight.
52
-
53
- The temperature on the poles is the lowest, as these areas are away from direct sunlight.
54
-
55
- Conversely, the temperature on the equator is higher, as this part receives maximum sunlight.
56
-
57
- Clouds
58
- Clouds are an essential part of our weather system.
59
-
60
- These are made of tiny droplets or water vapors.
61
-
62
- Clouds are formed when water evaporates from large bodies like seas, lakes, and rivers.
63
-
64
- Upon condensation, these water vapors cool down and form clouds.
65
-
66
- Humidity
67
- Humidity is defined as the amount of water vapors in the air.
68
-
69
- It increases with the increase in temperature.
70
-
71
- Besides, cooler air is less humid, as it cannot carry excessive water vapors.
72
-
73
- With increased humidity levels, the chances of precipitation are also higher.
74
-
75
- Wind
76
- We describe the wind as moving air.
77
-
78
- The speed of the wind depends on atmospheric pressure.
79
-
80
- When air flows from an area of high pressure to one with low pressure, it gains speed.
81
-
82
- Hence, the difference between the air pressure determines the wind speed.
83
-
84
- Rain
85
- When water vapors in the clouds cool down, they become tiny water droplets that are heavy and fall from the sky.
86
-
87
- This is how rain happens.
88
-
89
- Besides, tropical areas have more rain and a humid environment.
90
-
91
- Top 10 weather quotes
92
- Here are the best weather quotes your friends and followers on social media will surely appreciate.
93
 
94
  1. “In fair weather, prepare for foul.” — Thomas Fuller
95
 
@@ -112,9 +21,6 @@ Related 50 Currency Quotes About Standardized Money
112
 
113
  10. “A change in the weather is sufficient to recreate the world and ourselves.” — Marcel Proust
114
 
115
- Stormy weather quotes
116
- The storm is not just a metaphor for extreme weather but also for trying times. The quotes in this section serve as an excellent example of this.
117
-
118
  11. “If you want to see the sunshine, you have to weather the storm.” — Frank Lane
119
 
120
  12. “Faith is not a delicate flower which would wither away under the slightest stormy weather.” — Mahatma Gandhi
@@ -135,10 +41,6 @@ The storm is not just a metaphor for extreme weather but also for trying times.
135
 
136
  20. “I have seen many storms in my life. Most storms have caught me by surprise, so I had to learn very quickly to look further and understand that I am not capable of controlling the weather, to exercise the art of patience, and to respect the fury of nature.” — Paulo Coelho
137
 
138
- Related 50 Expectation Quotes To Fuel Your Mind And Spirit
139
- Good weather quotes
140
- Make use of the best weather quotes to appreciate good weather. Go nowhere else; find them right here in this section.
141
-
142
  21. “He was sunshine most always-I mean, he made it seem like good weather.” — Mark Twain
143
 
144
  22. “My wife Danielle and I love traveling, different cultures, and good weather.” — Gary Lineker
@@ -159,9 +61,6 @@ Make use of the best weather quotes to appreciate good weather. Go nowhere else;
159
 
160
  30. “And so we stayed out in the garden of the old house until we couldn’t kick a ball, laughing in the gathering twilight, making the most of the good weather and all the days that were left, our little game watched only by next door’s cat, and every star in the heavens.” — Tony Parsons
161
 
162
- Bad weather quotes
163
- When the weather doesn’t go your way, it’s sometimes called “bad weather.” These weather quotes provide insight into the weather-related views of those around us.
164
-
165
  31. “Bad weather always looks worse through a window.” — Tom Lehrer
166
 
167
  32. “Concrete is, essentially, the color of bad weather.” — William Hamilton
@@ -183,9 +82,6 @@ Related 25 Thomas Mann Quotes About The Nature Of The Soul
183
 
184
  40. “We often hear of bad weather, but in reality no weather is bad. It is all delightful, though in different ways. Some weather may be bad for farmers or crops, but for man, all kinds are good. Sunshine is delicious, rain is refreshing, wind braces us up, snow is exhilarating.” — John Lubbock
185
 
186
- Some more weather quotes
187
- Here are a few other interesting weather quotes.
188
-
189
  41. “I’m not a fan of cold weather.” — Ravyn Lenae
190
 
191
  42. “I like the cold weather. It means you get work done.” — Noam Chomsky
 
1
  50 Weather Quotes for Sunny and Rainy Days
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  1. “In fair weather, prepare for foul.” — Thomas Fuller
4
 
 
21
 
22
  10. “A change in the weather is sufficient to recreate the world and ourselves.” — Marcel Proust
23
 
 
 
 
24
  11. “If you want to see the sunshine, you have to weather the storm.” — Frank Lane
25
 
26
  12. “Faith is not a delicate flower which would wither away under the slightest stormy weather.” — Mahatma Gandhi
 
41
 
42
  20. “I have seen many storms in my life. Most storms have caught me by surprise, so I had to learn very quickly to look further and understand that I am not capable of controlling the weather, to exercise the art of patience, and to respect the fury of nature.” — Paulo Coelho
43
 
 
 
 
 
44
  21. “He was sunshine most always-I mean, he made it seem like good weather.” — Mark Twain
45
 
46
  22. “My wife Danielle and I love traveling, different cultures, and good weather.” — Gary Lineker
 
61
 
62
  30. “And so we stayed out in the garden of the old house until we couldn’t kick a ball, laughing in the gathering twilight, making the most of the good weather and all the days that were left, our little game watched only by next door’s cat, and every star in the heavens.” — Tony Parsons
63
 
 
 
 
64
  31. “Bad weather always looks worse through a window.” — Tom Lehrer
65
 
66
  32. “Concrete is, essentially, the color of bad weather.” — William Hamilton
 
82
 
83
  40. “We often hear of bad weather, but in reality no weather is bad. It is all delightful, though in different ways. Some weather may be bad for farmers or crops, but for man, all kinds are good. Sunshine is delicious, rain is refreshing, wind braces us up, snow is exhilarating.” — John Lubbock
84
 
 
 
 
85
  41. “I’m not a fan of cold weather.” — Ravyn Lenae
86
 
87
  42. “I like the cold weather. It means you get work done.” — Noam Chomsky
setup_db.py CHANGED
@@ -14,7 +14,7 @@ supabase_key = os.getenv("SUPABASE_KEY")
14
  supabase: Client = create_client(supabase_url, supabase_key)
15
 
16
  # Initialize SentenceTransformer
17
- model = SentenceTransformer('all-MiniLM-L6-v2')
18
 
19
  def process_text_file(file_path: str):
20
  # Read the file
 
14
  supabase: Client = create_client(supabase_url, supabase_key)
15
 
16
  # Initialize SentenceTransformer
17
+ model = SentenceTransformer('thenlper/gte-small')
18
 
19
  def process_text_file(file_path: str):
20
  # Read the file