anaspro
commited on
Commit
·
a535d94
1
Parent(s):
f17cc40
updatE
Browse files
app.py
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
# Load the model and tokenizer
|
| 5 |
model_path = "EzioDevio/iraqi_dialect_llm" # Use the Hugging Face Hub model path
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Load the model and tokenizer directly from Hugging Face
|
| 8 |
-
model =
|
| 9 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 10 |
-
text_generator = pipeline("
|
| 11 |
|
| 12 |
# Define the text generation function
|
| 13 |
def generate_text(input_text):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from transformers import pipeline, DiaForConditionalGeneration, AutoTokenizer
|
| 4 |
|
| 5 |
# Load the model and tokenizer
|
| 6 |
model_path = "EzioDevio/iraqi_dialect_llm" # Use the Hugging Face Hub model path
|
| 7 |
|
| 8 |
+
# Get token if available
|
| 9 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 10 |
+
|
| 11 |
# Load the model and tokenizer directly from Hugging Face
|
| 12 |
+
model = DiaForConditionalGeneration.from_pretrained(model_path, token=hf_token)
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, token=hf_token)
|
| 14 |
+
text_generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
| 15 |
|
| 16 |
# Define the text generation function
|
| 17 |
def generate_text(input_text):
|