Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,16 @@ st.title("AI Accountant - Prompt-Based ERP Entry")
|
|
| 6 |
|
| 7 |
model_path = os.path.abspath("finetuned-flan-t5")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained(model_path, local_files_only=True)
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path, local_files_only=True)
|
| 11 |
|
|
|
|
| 6 |
|
| 7 |
model_path = os.path.abspath("finetuned-flan-t5")
|
| 8 |
|
| 9 |
+
# Check if tokenizer files exist β if not, download them
|
| 10 |
+
required_files = ["tokenizer_config.json", "special_tokens_map.json", "spiece.model"]
|
| 11 |
+
missing_files = [f for f in required_files if not os.path.exists(os.path.join(model_path, f))]
|
| 12 |
+
|
| 13 |
+
if missing_files:
|
| 14 |
+
st.info("Tokenizer files missing. Downloading tokenizer from base model...")
|
| 15 |
+
tokenizer_dl = AutoTokenizer.from_pretrained("google/flan-t5-large")
|
| 16 |
+
tokenizer_dl.save_pretrained(model_path)
|
| 17 |
+
st.success("Tokenizer files downloaded.")
|
| 18 |
+
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_path, local_files_only=True)
|
| 20 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_path, local_files_only=True)
|
| 21 |
|