Nachiketkapure commited on
Commit
761b70b
1 Parent(s): 4f56f57

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +56 -13
  2. main.py +45 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,56 @@
1
- ---
2
- title: Fitness Bot
3
- emoji: 🌍
4
- colorFrom: indigo
5
- colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.31.1
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FitPal: Interactive Fitness Coach
2
+ FitPal is an innovative chatbot designed to act as your personal fitness coach. Leveraging the power of advanced AI, FitPal offers workout advice, exercise recommendations, and video demonstrations, making it easier than ever to achieve your fitness goals.
3
+
4
+ ## Features
5
+ ### Engage with Your Personal Fitness Coach:
6
+ Chat with FitPal for personalized advice on your workout routines. Utilizing OpenAI's advanced text generation models, FitPal provides you with insights and guidance tailored to your fitness journey.
7
+
8
+ ### Tailored Fitness Guidance:
9
+ Share details such as your height, age, weight, and fitness goals to receive custom workout recommendations designed just for you.
10
+
11
+ ### Explore Video Demonstrations:
12
+ For visual learners or those seeking detailed exercise instructions, FitPal can search for and provide YouTube video links to ensure you have the best information at your fingertips.
13
+
14
+ ## Installation
15
+
16
+ ### Clone the Repository
17
+
18
+ Start by cloning the FitPal repository to your local machine:
19
+
20
+ ```bash
21
+ git clone https://github.com/YourUsername/FitPal-Interactive-Fitness-Coach.git
22
+ cd FitPal-Interactive-Fitness-Coach
23
+ ```
24
+
25
+ ### Install Dependencies
26
+ Install all necessary libraries by running:
27
+
28
+ ```bash
29
+ pip install -r requirements.txt
30
+ ```
31
+
32
+ ### Launch FitPal
33
+ Begin your fitness journey with FitPal:
34
+
35
+ ```bash
36
+ streamlit run fitpal.py
37
+ ```
38
+ ## How to Use FitPal
39
+ - **Starting the Conversation**: Initiate your dialogue with FitPal by entering your query in the "Talk with Fit" section for instant fitness advice.
40
+ - **Personalizing Your Experience**: Provide your personal details in the "Client Info" section to receive workout recommendations that meet your specific needs.
41
+ - **Finding Instructional Videos**: Input your video request in the "Search for Video" section to have FitPal find relevant YouTube videos for you.
42
+ - **Viewing Responses and Videos**: Interact with FitPal's advice and the video links provided directly within the Streamlit app interface.
43
+
44
+ ### Examples
45
+ FitPal comes with a variety of example prompts to help you get started. These examples cover common fitness queries to demonstrate how you can interact with the chatbot for insights and guidance.
46
+
47
+ ### License
48
+ This project is made available under the MIT License. For more details, see the LICENSE file.
49
+
50
+ ## Acknowledgments
51
+
52
+ FitPal is powered by the following technologies:
53
+
54
+ - **Hugging Face's Transformers**: Utilized for generating personalized fitness advice through the pretrained GPT-2 model.
55
+ - **Streamlit**: Employed to create an engaging web app interface for user interactions.
56
+ - **Youtube-Search-Python**: Integrated for seamless searching and retrieval of instructional fitness videos on YouTube.
main.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from youtube_search import YoutubeSearch
4
+
5
+ # Initialize the Hugging Face pipeline for text generation, using GPT-2 for example
6
+ generator = pipeline('text-generation', model='gpt2')
7
+
8
+ # Function to generate response using Hugging Face pipeline
9
+ def generate_response(prompt):
10
+ response = generator(prompt, max_length=150, num_return_sequences=1, truncation=True)
11
+ return response[0]['generated_text'].strip()
12
+
13
+ # Function to perform YouTube search and retrieve video links
14
+ def search_videos(query, max_results=5):
15
+ try:
16
+ results = YoutubeSearch(query, max_results=max_results).to_dict()
17
+ video_links = [f"https://www.youtube.com/watch?v={result['id']}" for result in results]
18
+ return video_links
19
+ except Exception as e:
20
+ st.error("An error occurred while searching for videos: " + str(e))
21
+ return []
22
+
23
+ # Streamlit App Layout
24
+ st.title("FitPal: Interactive Fitness Coach")
25
+
26
+ # Input fields
27
+ client_info = st.text_area("Talk with Fit", help="Enter your message here")
28
+ user_message = st.text_input("Client Info", help="Enter your height, age, weight, etc. for better personalized results")
29
+ video_query = st.text_input("Search for Video", help="Want to look up a video that explains more?")
30
+
31
+ # Button to generate response
32
+ if st.button("Submit"):
33
+ if user_message:
34
+ prompt = user_message + "\nClient Info: " + client_info
35
+ chatbot_output = generate_response(prompt)
36
+ st.write("Chatbot Response:")
37
+ st.write(chatbot_output)
38
+
39
+ if video_query:
40
+ video_links = search_videos(video_query)
41
+ if video_links:
42
+ st.write("Video Links:")
43
+ for link in video_links:
44
+ st.markdown(f"[{link}]({link})", unsafe_allow_html=True)
45
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit == 1.15.2
2
+ transformers== 4.37.0
3
+ youtube-search-python == 1.4.2