anaspro commited on
Commit
a535d94
·
1 Parent(s): f17cc40
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,13 +1,17 @@
1
  import gradio as gr
2
- from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
 
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 = AutoModelForCausalLM.from_pretrained(model_path)
9
- tokenizer = AutoTokenizer.from_pretrained(model_path)
10
- text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
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):