Spaces:
Sleeping
Sleeping
DariaKhot
commited on
Commit
·
6385041
1
Parent(s):
b7ad669
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
###################################################
|
| 6 |
+
pipe = pipeline("text-generation", model='all-MiniLM-L6-v2')
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
try:
|
| 11 |
+
st.title("Which Resort is best for you?")
|
| 12 |
+
|
| 13 |
+
weathers = ["Sunny", "Rainy", "Snowy"]
|
| 14 |
+
activities = ["Skiing", "Hiking", "Swimming", "Relaxing"]
|
| 15 |
+
weather = st.selectbox("What is the weather like?", weathers)
|
| 16 |
+
activity = st.selectbox("What activity do you prefer?", activities)
|
| 17 |
+
input_prompt = f"The weather is {weather.lower()} and I like {activity.lower()}."
|
| 18 |
+
|
| 19 |
+
if st.button('Recommend a Resort'):
|
| 20 |
+
with st.spinner('Generating recommendation...'):
|
| 21 |
+
# Generate text based on the input prompt
|
| 22 |
+
generated_texts = pipe(input_prompt, max_length=50, num_return_sequences=1)
|
| 23 |
+
recommendation = generated_texts[0]['generated_text']
|
| 24 |
+
|
| 25 |
+
# Displaying the generated recommendation
|
| 26 |
+
st.subheader("Recommended Resort:")
|
| 27 |
+
st.write(recommendation)
|
| 28 |
+
|
| 29 |
+
except Exception as e:
|
| 30 |
+
st.error(e)
|
| 31 |
+
|
| 32 |
+
###################################################
|
| 33 |
+
if __name__=="main":
|
| 34 |
+
main()
|
| 35 |
+
|
| 36 |
+
|