logicsame
commited on
Commit
·
75f1c35
1
Parent(s):
ecf4166
Initial commit
Browse files- app.py +17 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load the model and tokenizer from Hugging Face
|
5 |
+
model_id = "huggingface/llama-2-7b-chat"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
8 |
+
|
9 |
+
st.title("Food Nutrition Analysis with LLaMA")
|
10 |
+
|
11 |
+
user_input = st.text_area("Enter food label text:")
|
12 |
+
|
13 |
+
if st.button("Analyze"):
|
14 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
15 |
+
outputs = model.generate(**inputs)
|
16 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
17 |
+
st.write(response)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
streamlit # If you're using Streamlit
|