Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
import torch | |
# Load the model | |
model_name = "Tom158/Nutri_Assist" | |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16) | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
# Streamlit App Interface | |
st.title("Nutrition Chatbot") | |
user_input = st.text_input("Ask me about nutrition:") | |
if user_input: | |
# Process user input | |
inputs = tokenizer.encode(user_input, return_tensors="pt") | |
outputs = model.generate(inputs, max_length=50) | |
answer = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
# Display answer | |
st.write("Answer:", answer) | |